Home > Uncategorized > Maven 3, deploy file with scp

Maven 3, deploy file with scp

By default maven 3 will only allow you to upload files by means of http.

This mean that deploying through scp will not work. My settings.xml contains the servers to which I want to upload through scp.

Settings.xml

<settings>
    <servers>
        <server>
            <id>sample-server-id</id>
            <username>myUsername</username>
            <password>myPassword</password>
        </server>
    </servers>
    <profiles>
	<profile>
            <id>default-profile</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
	    <repositories>
		<repository>
			<id>sample-server-id</id>
			<name>A sample repository</name>
			<url>scp://builds.example.org/maven</url>
		</repository>
	    </repositories>
	</profile>
    </profiles>
</settings>

Deploying the file with mvn deploy:deploy-file will give an error when using scp as the protocol.

mvn deploy:deploy-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -DrepositoryId=sample-server-id -Dfile=ojdbc6.jar -Durl=scp://builds.example.org/maven
No connector available to access repository

To fix this we need to create a dummy pom.xml. The most important part is to add the ssh wagon to enable scp.

<project> 
	<modelVersion>4.0.0</modelVersion> 
	<groupId>com.oracle</groupId> 
	<artifactId>jdbc-driver</artifactId> 
	<version>11.2.0.4</version> 
	<build>
		<extensions>
			<extension>
				<groupId>org.apache.maven.wagon</groupId>
				<artifactId>wagon-ssh</artifactId>
				<version>2.6</version>
			</extension>
		</extensions>
	</build>
</project>

Now rerun the command:

mvn deploy:deploy-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -DrepositoryId=sample-server-id -Dfile=ojdbc6.jar -Durl=scp://builds.example.org/maven

Hopefully it will now show:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.

Time limit is exhausted. Please reload CAPTCHA.