将变量从属性文件传递到pom.xml中的distributionManagement标记中 [英] Pass variables from properties file into distributionManagement tag in pom.xml

查看:383
本文介绍了将变量从属性文件传递到pom.xml中的distributionManagement标记中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有类似的东西:

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

我有distributionManagement

<distributionManagement>
    <repository>
        <id>local-repo</id>
        <url>file:///${deploy.dir}/${project.artifactId}</url>
    </repository>
</distributionManagement>

我没有远程存储库,这就是为什么我使用file:///

进行存储的原因

${deploy.dir}build.properties文件中的一个属性,它将不使用该属性的值. 为什么?

解决方案

Mark的答案可能是正确的方法,也是我在远程存储库的生产实例和测试实例之间进行切换时要做的事情. 根据我发现的讨论,听起来好像您可以加载用于以后的插件配置的属性,但是像<distributionManagement>这样的核心Maven模型元素仅在POM的初始加载时解释了属性.

(移动评论以回答每个OP请求.)

So I have something like:

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

and I have distributionManagement like:

<distributionManagement>
    <repository>
        <id>local-repo</id>
        <url>file:///${deploy.dir}/${project.artifactId}</url>
    </repository>
</distributionManagement>

I don't have a remote repository, that is why I am doing it using file:///

${deploy.dir} is a property from the build.properties file and it will not take the value for that property. Why?

解决方案

Mark's answer is probably the way to go, and is what I'm doing to switch between our production and test instances of our remote repository. Per a discussion I found it sounds like you can load properties for use in later plugin configurations, but core maven model elements like <distributionManagement> only have properties interpreted on initial load of the POM.

(Moving comment to answer per OP request.)

这篇关于将变量从属性文件传递到pom.xml中的distributionManagement标记中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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