Maven Wagon 插件:wagon:upload 可以上传到多个位置吗?
我正在研究 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 或 Prod 运行部署部署到?
我考虑过(并编写了)一个脚本来多次运行 mvn wagon:upload -Penvironment#
- 每个服务器一次 - 但这对我来说似乎有缺陷。如果我编写一个脚本来处理这个过程,我也可以编写整个部署的脚本。然而,这削弱了 Wagon(和 Maven)的实用性……
有没有一种方法可以为一个目标运行多个
?例如,当我只运行 mvn deploy -Pqa
时,运行多个配置文件配置的 wagon:upload
任务?
I'm looking into the Maven Wagon Plugin to attempt uploading some artifacts to remote UNC Server shares (\\servername\share\directory\to\put\to
), and I have gotten it configured to work like so in the 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>
This works great for one server when I pass in -Dservername=x -Dsharename=y
, but how can I scale it out so I can run a deploy for QA or Prod where I have multiple servers to deploy to?
I've considered (and written) a script to run mvn wagon:upload -Penvironment#
multiple times--once for each server--but this seems flawed to me. If I'm shelling out to a script to handle this process, I could just as well script out the entire deploy, too. However, this takes away from the usefulness of Wagon (and Maven)...
Is there a way to run multiple <executions>
for one goal? For instance, running multiple profile configured wagon:upload
tasks when I just run mvn deploy -Pqa
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想使用多个配置文件,您只需使用:
mvn deploy -Denv=qa
并在此属性上触发一些配置文件,并在配置文件中定义服务器的配置。对于这种配置文件激活,请查看http://maven.apache.org /guides/introduction/introduction-to-profiles.html
并搜索
-Denvironment=test
这是一个示例 POM,它在一个构建中执行两次 maven-antrun-plugin:
If you want to use multiple profiles you could just use:
mvn deploy -Denv=qa
and trigger some profiles on this property and define the configuration for your severs in the profiles. For this kind of profile activation look athttp://maven.apache.org/guides/introduction/introduction-to-profiles.html
and search for
-Denvironment=test
Here's an example POM which does two executions of the maven-antrun-plugin in one build: