问题
I am using activation based on file exists in my pom.xml.
However, my profile is ALWAYS executed, no matter what.
Here is the profile description:
<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>
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?
Thanks Romain.
回答1:
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.
See the section How can a profile be triggered in this link.
来源:https://stackoverflow.com/questions/26126828/activation-in-my-maven-profile-is-ignored-profile-always-executed-using-file-e