Site Deploy with Maven 3

von

When Simone Tripodi initiated the new Maven Skin Fluido, which is build on top of my favorite lib Bootstrap, I knew it is time to create an own site for JJSON. But when running site-deploy, Maven 3 reported me I have an “Unsupported protocol: ‘scp’”. This is because Maven 3 is not supporting scp by default anymore. Here are steps one need to make Maven 3 deploying your site via ssh.

First you need to add a dependency to your Site plugin. It is the well-known “wagon-ssh” artifact, currently available as version 2.0:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-site-plugin</artifactId>
	<version>3.0</version>
	<dependencies>
		<dependency>
			<groupId>org.apache.maven.wagon</groupId>
			<artifactId>wagon-ssh</artifactId>
			<version>2.0</version>
		</dependency>
	</dependencies>
</plugin>

Nested in your sites project element, you need to define this:

<distributionManagement>
   <site>
      <id>jjson.website</id>
      <url>scp://yourhost.com/absolute/path/to/your/deploy/directory/jjson</url>
   </site>
</distributionManagement>

Please note, the url is prefixed with scp (for the scp protocol of course) and after the host, you want connect to, you’ll need an absolute path. For example, if you are on a shared host go to the directory in which you want to deploy and type: pwd. The resulting path is what you need to enter.

The id you define here is used to lookup a matching server entry in settings.xml:

<server>
  <id>jjson.website</id>
  <username>myusername</username>
  <privateKey>/Users/myuser/keyfile.key</privateKey>
  <passphrase>mypassword</passphrase>
</server>

You’ll not necessary need a key and can use your holy master password. But of course it is recommended to store any passwords - not even the passphrase in the pom.xml. Better leave it out.

Tags: #Java #Maven #Open Source

Newsletter

ABMELDEN