【发布时间】:2017-04-13 11:45:35
【问题描述】:
我正在使用Properties Maven Plugin 来读取一些Properties,在执行这个插件后我执行另一个插件,之后我想用不同的配置再次执行这个插件
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>src/Args.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
执行 maven-antrun-plugin,然后用配置“src/Args2.properties”调用这个插件,因为在最后一个插件中我声明了一个新属性,它在文件“Args2.properties”中使用
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath"/>
<if>
<equals arg1="${serviceType}" arg2="none"/>
<then>
<property name="prop" value="x"/>
</then>
<else>
<property name="prop"value="y"/>
</else>
</if>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
和 Args2.properties :
prop2=${prop}/anotherValue
我想在 Antrun 插件中为 prop 赋值后,稍后从文件 Args2 中读取 prop2
【问题讨论】:
-
您的全球通缉用例是什么?通过在构建中完全不同的时间读取 2 个属性并在其间运行 AntRun 插件,您想解决什么问题?
-
在 AntRun 插件中给 prop 赋值后,我想稍后从 Args2 中读取 prop2,将它包含在 prop 的新值中
-
是的,但我是XY Problem,你为什么一开始就有这个设置?
-
prop 的值与 serviceType 的值有关...例如 if serviceType= value1 then prop 有 x else prop 有值 y
-
@MalazAlbawarshi 你还是没能解释为什么你想要这个。