Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven 将变量从属性文件传递到pom.xml中的distributionManagement标记中_Maven_Pom.xml - Fatal编程技术网

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

Maven 将变量从属性文件传递到pom.xml中的distributionManagement标记中,maven,pom.xml,Maven,Pom.xml,所以我有点像: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-1</version> <executions>

所以我有点像:

<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>
我没有远程存储库,这就是为什么我使用
file://

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

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

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

Mark的答案可能是正确的,我正在做的就是在远程存储库的生产和测试实例之间切换。听起来您可以加载属性以便在以后的插件配置中使用,但像
这样的核心maven模型元素只有在POM的初始加载时才能解释属性


(移动注释以回答每个操作请求。)

如果使用
-Ddeploy.dir=
运行maven命令,它是否按预期工作?@user944849,它是这样工作的,但我想从pom.xmlRight执行此操作。我很确定在POM首次加载时插入了
,您对此进行了确认。Mark的答案可能是正确的,我正在做的就是在远程存储库的生产和测试实例之间切换。听起来您可以加载属性以便在以后的插件配置中使用,但像
这样的核心maven模型元素只有在POM的初始加载时才能解释属性。@user944849,这回答了我的问题,谢谢:)。你可以把答案和你的评论放在一起,我会把它标记为接受答案。
<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>
mvn -Prepo1 clean deploy