Maven Wagon插件:wagon:upload可以上传到多个位置吗? [英] Maven Wagon plugin: Can wagon:upload upload to multiple locations?

查看:143
本文介绍了Maven Wagon插件:wagon:upload可以上传到多个位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究 Maven Wagon插件,尝试将一些工件上传到远程UNC服务器共享(\\servername\share\directory\to\put\to),我已经将其配置为在POM中像这样工作:

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>

当我传入-Dservername=x -Dsharename=y时,这对于一台服务器 来说效果很好,但是如何扩展它,以便可以在其中运行QA或Prod的部署有多个服务器要部署到?

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?

我已经考虑(并编写)一个脚本来多次运行mvn wagon:upload -Penvironment#(每个服务器一次),但这在我看来是有缺陷的.如果我要编写脚本来处理此过程,那么也可以将整个部署脚本化.但是,这脱离了Wagon(和Maven)的用途...

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)...

是否可以针对一个目标运行多个<executions>?例如,当我刚运行mvn deploy -Pqa时,运行多个配置文件配置的wagon:upload任务?

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?

推荐答案

如果要使用多个配置文件,则可以使用:mvn deploy -Denv=qa并触发该属性上的一些配置文件,并为配置文件中的服务器定义配置.对于这种个人资料激活,请查看

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 at

http://maven.apache.org/guides/introduction/Introduction-to-profiles.html

并搜索

-Denvironment = test

-Denvironment=test

下面是一个示例POM,它在一个版本中执行两次maven-antrun-plugin:

Here's an example POM which does two executions of the maven-antrun-plugin in one build:

 <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>

这篇关于Maven Wagon插件:wagon:upload可以上传到多个位置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆