Maven Wagon插件:可以货车:上传上传到多个位置吗?
-
08-10-2019 - |
题
我正在调查 Maven Wagon插件 尝试将一些文物上传到远程UNC服务器共享(\\servername\share\directory\to\put\to
),我已经将其配置为在POM中像这样工作的工作:
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>upload-jar-to-folder</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
</execution>
</executions>
<configuration>
<fromDir>${project.build.directory}</fromDir>
<includes>*</includes>
<url>file://localhost///${servername}/${sharename}</url>
<toDir>directory/to/put/artifact</toDir>
</configuration>
</plugin>
...
</build>
这很棒 对于一台服务器 当我经过 -Dservername=x -Dsharename=y
, ,但是如何将其缩放到以便我可以部署多个服务器可以部署到的QA或产品的部署?
我已经考虑(写)一个脚本要运行 mvn wagon:upload -Penvironment#
多次 - 对于每个服务器,但这似乎对我来说是有缺陷的。如果我要弹出脚本来处理此过程,那么我也可以将整个部署脚本拼写出来。但是,这从货车(和Maven)的实用性中消失了...
有没有办法运行多个 <executions>
一个进球?例如,运行多个配置文件配置 wagon:upload
我刚运行时的任务 mvn deploy -Pqa
?
解决方案
如果要使用多个配置文件,则可以使用: mvn deploy -Denv=qa
并在此属性上触发一些配置文件,并在配置文件中为您的devers定义配置。对于这种概况激活
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
并搜索
-denvironment =测试
这是一个示例POM,在一个构建中对Maven-Antrun-Plugin进行了两次执行:
<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>org.stackoverflow</groupId>
<artifactId>q5328617</artifactId>
<version>0.0.1-SNAPSHOT</version>
<profiles>
<profile>
<activation>
<property>
<name>env</name>
<value>qa</value>
</property>
</activation>
<id>qa1</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>qa1</id>
<phase>test</phase>
<configuration>
<tasks>
<echo level="info">Executing qa1</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<activation>
<property>
<name>env</name>
<value>qa</value>
</property>
</activation>
<id>qa2</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>qa2</id>
<phase>test</phase>
<configuration>
<tasks>
<echo level="info">Executing qa2</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
不隶属于 StackOverflow