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

embedBuildProfileDependencies takes dependencies of other (not selected) profiles #73

Open
karonpante opened this issue Aug 7, 2018 · 1 comment

Comments

@karonpante
Copy link

We have a project in which different profiles define another version of a certain dependency.
So the GroupID and ArtifactID of these dependencies are the same.

When we build this project with a certain profile using the flatten plugin with the 'embedBuildProfileDependencies' option enabled we don't get the expected result. Next to the selected profile dependencies also the dependencies of other profiles which have the same GroupID and ArtifactID (but another version) are added to the flattened pom file.

Following pom file was used to test this:

<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>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0-SNAPSHOT</version>
 
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <version>1.0.1</version>
        <configuration>
          <updatePomFile>true</updatePomFile>
          <embedBuildProfileDependencies>true</embedBuildProfileDependencies>
        </configuration>
        <executions>
          <execution>
            <id>flatten</id>
            <phase>process-resources</phase>
            <goals>
              <goal>flatten</goal>
            </goals>
          </execution>
          <execution>
            <id>flatten.clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
 
  <profiles>
    <profile>
      <id>profile1</id>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.12</version>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <id>profile2</id>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.10</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>

When building this with the following command:

mvn clean install -Pprofile1

This gives the following flattened pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
    </dependency>
  </dependencies>
</project>
@hohwille hohwille added the bug label Jan 14, 2019
@hohwille
Copy link
Member

OMG. You are right. I have testet it - even with 1.1.0 the bug is reproducable just as you described.
Seems that the profile activation is somehow buggy.
Shall be fixed for next release. Help is more than welcome.

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

No branches or pull requests

2 participants