flatten-maven-plugin
flatten-maven-plugin copied to clipboard
flatten error when profiles are activated by property
Given the following pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.test</groupId>
<artifactId>A</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.${revision}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
<configuration>
<embedBuildProfileDependencies>true</embedBuildProfileDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ProfDef</id>
<activation>
<property>
<name>!prof</name>
</property>
</activation>
<properties>
<revision>10</revision>
</properties>
</profile>
<profile>
<id>ProfA</id>
<activation>
<property>
<name>prof</name>
</property>
</activation>
<properties>
<revision>12</revision>
</properties>
</profile>
</profiles>
</project>
flatten succeeds if profiles are activated explicitly (-P option) but fails when they are activated by properties :
mvn process-resources => failure
mvn -Dprof process-resources => failure
mvn -PProfA process-resources => success
mvn -PProfDef process-resources => success
failure message :
[ERROR] 'dependencies.dependency.version' for junit:junit:jar must be a valid version but is '4.${revision}'.
activeByDefault=true property in profile configuration doesn't work either.
<profiles>
<profile>
<id>TEST</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<revision>1.0.1-SNAPSHOT</revision>
</properties>
</profile>
<profile>
<id>PRE</id>
<properties>
<revision>1.0.1-PRE-SNAPSHOT</revision>
</properties>
</profile>
</profiles>
I have the same problem.
boy oh boy i sure do love debugging
Nothing new since pratically 3 years?
maybe this is intentional?
from docu:
| profiles | resolved specially | only the Activation and the Dependency dependencies of a Profile are copied to the flattened POM. If you set the parameter embedBuildProfileDependencies to true then only profiles Activation activated by JDK or OS will be added to the flattened POM while the other profiles are triggered by the current build setup and if activated their impact on dependencies is embedded into the resulting flattened POM. |
|---|
enabledByDefault is not part of that activation list: JDK/OS