Maven Wagon 插件:wagon:upload 可以上传到多个位置吗?

2024-04-04

我正在调查Maven 旅行车插件 http://mojo.codehaus.org/wagon-maven-plugin/尝试将一些工件上传到远程 UNC Server 共享(\\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)的实用性......

有没有办法同时运行多个<executions>为了一个目标?例如,运行配置的多个配置文件wagon:upload我刚跑步时的任务mvn deploy -Pqa?


如果您想使用多个配置文件,您可以使用:mvn deploy -Denv=qa并触发此属性上的一些配置文件,并在配置文件中定义服务器的配置。对于这种类型的配置文件激活请查看

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

并搜索

-D环境=测试

下面是一个示例 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Maven Wagon 插件:wagon:upload 可以上传到多个位置吗? 的相关文章

随机推荐