Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flatten error when profiles are activated by property #91

Open
farfouille64 opened this issue Mar 22, 2019 · 5 comments
Open

flatten error when profiles are activated by property #91

farfouille64 opened this issue Mar 22, 2019 · 5 comments

Comments

@farfouille64
Copy link

farfouille64 commented Mar 22, 2019

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}'.

@hunalme
Copy link

hunalme commented Dec 24, 2019

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>

lafoletc added a commit to lafoletc/flatten-maven-plugin that referenced this issue Apr 8, 2020
Projet properties should be a merge of all active profiles : activated
explicitly with -P, with property activation or by default
lafoletc added a commit to lafoletc/flatten-maven-plugin that referenced this issue Nov 14, 2020
Projet properties should be a merge of all active profiles : activated
explicitly with -P, with property activation or by default
@ashulin
Copy link

ashulin commented Sep 29, 2021

I have the same problem.

@menneske2
Copy link

boy oh boy i sure do love debugging

@dymont
Copy link

dymont commented Jan 26, 2022

Nothing new since pratically 3 years?

@jcunliffe1
Copy link

jcunliffe1 commented Feb 10, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants