将变量从属性文件传递到 pom.xml 中的 distributionManagement 标记

And*_*fat 3 pom.xml maven

所以我有类似的东西:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0-alpha-1</version>
            <executions>
                <execution>
                    <phase>initialize</phase>
                    <goals>
                        <goal>read-properties</goal>
                    </goals>
                    <configuration>
                        <files>
                            <file>${user.home}/build.properties</file>
                        </files>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

distributionManagement喜欢:

<distributionManagement>
    <repository>
        <id>local-repo</id>
        <url>file:///${deploy.dir}/${project.artifactId}</url>
    </repository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)

我没有远程存储库,这就是我使用它的原因 file:///

${deploy.dir}build.properties文件中的一个属性,它不会获取该属性的值。为什么?

Mar*_*nor 5

我建议使用构建配置文件来管理多个分发目标。例如:

<profiles>
   <profile>
      <id>repo1</id>
      <distributionManagement>
         <repository>
            <id>repo1-release</id>
            <url>http://.......</url>
         </repository>
      </distributionManagement>
   </profile>

   <profile>
      <id>repo2</id>
      <distributionManagement>
         <repository>
            <id>repo2-release</id>
            <url>http://.......</url>
         </repository>
      </distributionManagement>
   </profile>
   ..
</profiles>
Run Code Online (Sandbox Code Playgroud)

调用部署目标时,您可以通过激活配置文件来选择目标:

mvn -Prepo1 clean deploy
Run Code Online (Sandbox Code Playgroud)