I have a Maven project which uses profiles to inject application properties at build time. The properties that get injected are stored in the Maven settings file which i use when asking Maven to build the project.
My build command can take two flavors;
OPTION1: mvn -s ${MAVEN_PROPERTIES_FILE_NON_PROD} -e deploy -f ${PARENT-POM}/pom.xml
OPTION2: mvn -s ${MAVEN_PROPERTIES_FILE_PROD} -e deploy -f ${PARENT-POM}/pom.xml
The problem happens when i build OPTION1 and then try build OPTION2. Sometimes Maven will continue to use the properties from the unwanted profile. Whats even more strange is that not all of the child projects will have this problem.
Can anyone suggest why Maven might be continuing to use the old profile even when i have explicitly defined the file in my build command?
Thanks
Use the
clean
target before the deploy. If you don't clean, maven will use the cached or already created artifacts.