使用文件存在时,忽略我的maven配置文件中的激活(配置文件始终执行)

时间:2014-09-30 17:39:42

标签: java maven maven-plugin activation

我正在使用基于我的pom.xml中存在的文件的激活。

然而,无论如何,我的个人资料总是被执行。

以下是个人资料说明:

<profile>
    <id>copy</id>
    <activation>
        <file>
            <exists>file.xml</exists>
        </file>
    </activation>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <configuration>
                            <target name="copy and rename file">
                                <copy           file="${basedir}/src/main/resources/application.${env}.properties"  tofile="${basedir}/src/main/fabric8/io.fabric8.system.properties" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

我这样称呼我的个人资料: mvn包-Pcopy

但无论文件是否存在,都会调用配置文件。 我做错了什么?

由于 罗曼。

1 个答案:

答案 0 :(得分:3)

如果项目中存在该文件,则在运行mvn命令时,您不需要传递配置文件名称。明确地将-Pcopy传递给命令将覆盖POM中的activation,并始终激活此配置文件。

请参阅此link如何触发配置文件部分。