目的:实现本地代码,或者程序包,或者单个配置文件,或者多个上传部署到服务器对应的目录中去。
问题1:用maven什么插件可以实现?
wagon-maven-plugin
该插件的maven依赖为:
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0</version>
</dependency>
插件的文档地址为:
http://www.mojohaus.org/wagon-maven-plugin/
主要提供如下几个goal
wagon:upload-single uploads the specified file to a remote location.
wagon:upload uploads the specified set of files to a remote location.
wagon:download-single downloads the specified file from a remote location.
wagon:download downloads the specified set of files from a remote location.
wagon:list lists the content of a specified location in a remote repository.
wagon:copy copies a set of files under a Wagon repository to another.
wagon:merge-maven-repos merges , including metadata, a Maven repository to another.
wagon:sshexec Executes a set of commands at remote SSH host.
下面给出我的POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hdkg</groupId>
<artifactId>upload</artifactId>
<version>0.0.1</version>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<finalName>upload</finalName>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.10</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<serverId>hdkg</serverId>
<!-- 本地目录,从哪上传,这里指定不是目录,是单个文件 -->
<!-- <fromFile>target/dis/atc.jar</fromFile>-->
<!-- <fromFile>target/dis/resources/logback-spring.xml</fromFile>-->
<fromFile>target/upload.jar</fromFile>
<!-- 本地目录,从哪上传,这里指定的是目录,不是单个文件 -->
<!-- <fromDir>target/dis</fromDir>-->
<!-- 过滤你不想要的文件 -->
<!-- <excludes>logback-spring.xml</excludes>-->
<!--远程目录,上传到哪去-->
<toDir>/home/hdkg/ATC/temp</toDir>
<!-- 服务器地址IP,如果没有toDir,写完整路径 -->
<!-- <url>scp://hdkg@100.100.100.154/home/hdkg/ATC/temp</url>-->
<url>scp://hdkg@100.100.100.154</url>
<!-- <commands>-->
<!-- <!– 关闭tomcat –>-->
<!-- <command>/home/hadoop/apache-tomcat-8.0.5/bin/shutdown.sh</command>-->
<!-- <!– 删除之前解压后的目录 –>-->
<!-- <command>rm -rf /home/hadoop/apache-tomcat-8.0.5/webapps/osc-shop-->
<!-- </command>-->
<!-- <!– 启动tomcat –>-->
<!-- <command>/home/hadoop/apache-tomcat-8.0.5/bin/startup.sh</command>-->
<!-- </commands>-->
<!--是否显示Shell命令-->
<displayCommandOutputs>true</displayCommandOutputs>
</configuration>
</plugin>
</plugins>
</build>
</project>
我的pom文件名字是 upload.xml ,没有用pom.xml ,是因为有pom.xml了,这个upload.xml是单独为了上传文件用的
问题2:那么怎么单独执行这个upload.xml呢?
mvn wagon:upload-single -f upload.xml 这个是上传单独文件。例如jar包这样一类的
mvn wagon:upload -f upload.xml 这个是上传多文件,可以整个目录
官方示例:
http://www.mojohaus.org/wagon-maven-plugin/usage.html
问题3 :那么如果我想一次执行多个pom.xml文件该怎么办?

本文介绍了wagon-maven-plugin插件,其可将本地代码、程序包或配置文件上传部署到服务器对应目录。给出了该插件的maven依赖、文档地址及主要功能goal,还说明了单独执行upload.xml文件的方法,最后提出一次执行多个pom.xml文件的问题。
1822

被折叠的 条评论
为什么被折叠?



