使用文件存在时,忽略我的maven配置文件中的激活(配置文件始终执行) [英] Activation in my maven profile is ignored (profile always executed) using file exist
问题描述
我正在使用基于我的pom.xml中存在的文件的激活。
I am using activation based on file exists in my pom.xml.
然而,无论如何,我的个人资料总是被执行。
However, my profile is ALWAYS executed, no matter what.
以下是资料说明:
<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 package -Pcopy
I call my profile like this: mvn package -Pcopy
但无论文件是否存在,都会调用配置文件。
我做错了什么?
But the profile is always called, no matter if the file is present or not. What am I doing wrong?
谢谢
罗曼。
推荐答案
如果项目中存在该文件,则在运行 mvn
命令时,无需传递配置文件名称。明确地将 -Pcopy
传递给该命令将覆盖POM中的激活
,并将始终激活此配置文件。
You don't need to pass the profile name when running the mvn
command if the file exists in the project. Passing -Pcopy
explicitly to the command will override the activation
in the POM, and will always activate this profile.
请参阅如何触发配置文件部分introduction-to-profiles.htmlrel =nofollow>链接。
See the section How can a profile be triggered in this link.
这篇关于使用文件存在时,忽略我的maven配置文件中的激活(配置文件始终执行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!