小编Mal*_*shi的帖子

如何多次执行maven插件

我正在使用 Properties Maven Plugin 来读取一些属性,在执行这个插件后我执行另一个插件,之后我想用不同的配置再次执行这个插件

<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>
Run Code Online (Sandbox Code Playgroud)

执行 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>
Run Code Online (Sandbox Code Playgroud)

和 Args2.properties :

prop2=${prop}/anotherValue
Run Code Online (Sandbox Code Playgroud)

我想在 Antrun 插件中给 prop 一个值后,稍后从文件 Args2 中读取 prop2

plugins pom.xml maven

0
推荐指数
1
解决办法
1896
查看次数

标签 统计

maven ×1

plugins ×1

pom.xml ×1