Maven部署到远程主机ssh(scp)而不是存储库
我试图将maven构建的jar复制到远程主机中的目录,而不是存储库中。我在这里尝试了user1050755 answer,它使用了maven antrun插件,还尝试了Vang ssh插件。下面是我的pom.xml的相关摘录Maven部署到远程主机ssh(scp)而不是存储库,maven,ssh,scp,maven-antrun-plugin,maven-wagon-plugin,Maven,Ssh,Scp,Maven Antrun Plugin,Maven Wagon Plugin,我试图将maven构建的jar复制到远程主机中的目录,而不是存储库中。我在这里尝试了user1050755 answer,它使用了maven antrun插件,还尝试了Vang ssh插件。下面是我的pom.xml的相关摘录 <build> <extensions> <extension> <groupId>org.apache.maven.wagon</groupId&
<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>
但我不想部署到存储库,我认为antrun插件只会让我无限制地将文件复制到远程主机,我缺少什么?因为您使用phase deploy,所以需要distributionManagement或altDeploymentRepository: 在您的案例中,有两种解决方案:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>X.Y</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
org.apache.maven.plugins
maven部署插件
X.Y
真的
<phase>deploy</phase>
部署
安装
您解决了这个问题吗
我在使用ApacheMaven3.2.5的windows平台上遇到了同样的问题
原因是maven无法在settings.xml中检测配置
下面是我的解决方案
我希望如此…我最终使用了maven antrun插件,但在该阶段使用了集成测试。我使用的maven命令是mvn包集成测试。我还使用了trust=“true”属性,因为我无法摆脱jsch异常
com.jcraft.jsch.JSchException:UnknownHostKey:
。我在这里贴了一个问题
maven antrun插件
1.8
scp
集成测试
跑
com.jcraft
jsch
0.1.53
org.apache.ant
ant jsch
1.9.6
<phase>deploy</phase>
<phase>install</phase>
<configuration>
<url>scp://root@192.168.56.102</url>
</configuration>
<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>