I'm trying to copy a jar built by maven to a directory in a remote host, not a repository. I tried user1050755 answer here Using Maven for deployment which uses the maven-antrun-plugin and also I've tried the wagon-ssh plugin. Below is the hopefully relevant excerpt from my pom.xml
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.9</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>xd</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>target</fromDir>
<includes>xml-to-json-transformer-0.0.1-SNAPSHOT.jar</includes>
<excludes/>
<url>scp://spade.innoimm.local</url>
<toDir>/opt/xd/custom-modules/processor</toDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>scp</id>
<phase>deploy</phase>
<configuration>
<tasks>
<scp todir="root@spade:/opt/xd/custom-modules/processor"
sftp="true"
keyfile="C:\MerucurioVagrant\repo\mercurio-vagrant\insecure_private_key.ppk"
failonerror="false"
verbose="true"
passphrase="nopass"
>
<fileset dir="target">
<include
name="xml-to-json-transformer-0.0.1-SNAPSHOT.jar"/>
</fileset>
</scp>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
For both plugins I get the same error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xml-to-json-transformer: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
But I don't want to deploy to a repository, I thought the antrun-plugin would just let me copy a file to a remote host with no restrictions, what am I missing?
I ended up using the maven-antrun-plugin but used integration-test for the phase. The maven command I used was mvn package integration-test
. I also used the trust="true" attribute because I couldn't get rid of a jsch exception com.jcraft.jsch.JSchException: UnknownHostKey:
. I posted a question about that here JSch: UnknownHostKey exception even when the hostkey fingerprint is present in the known_hosts file
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<configuration>
<tasks>
<scp todir="vagrant@localhost:~/maven-scp"
port="2200" trust="true" keyfile="C:\keys\openSSH_pair1\open_ssh_private"
failonerror="false" verbose="true" passphrase="pass">
<fileset dir="target">
<include name="xml-to-json-transformer-0.0.1-SNAPSHOT.jar" />
</fileset>
</scp>
</tasks>
</configuration>
<executions>
<execution>
<id>scp</id>
<phase>integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.6</version>
</dependency>
</dependencies>
</plugin>
</plugins>