mojohaus / flatten-maven-plugin

Flatten Maven Plugin

Home Page:https://www.mojohaus.org/flatten-maven-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to flatten pom if a dependency has the version defined via dependencyManagement in a parent.pom profile

RPCMoritz opened this issue · comments

For a multi-scala-version project, I want to maintain different versions of dependencies in a dependencyManagement section of a profile.
For normal builds this is fine, but mvn flatten:flatten does not appear to pick up the declared dependencies, despite me passing the profile explicitly, and it being present in the flattened parent.pom.

[ERROR] 'dependencies.dependency.version' for org.scala-lang:scala-library:jar is missing. @

Parent pom has this profile:

<profile>
    <id>scala-212</id>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
        <scala.main.version>2.12</scala.main.version>
        <scala.version>${scala.main.version}.10</scala.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-library</artifactId>
                <version>${scala.version}</version>
            </dependency>
    </dependencyManagement>
</profile>                    

and this plugin conf:

<build>
  <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>flatten-maven-plugin</artifactId>
            <version>1.2.7</version>
            <configuration>
                <updatePomFile>true</updatePomFile>
                <flattenMode>resolveCiFriendliesOnly</flattenMode>
            </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>

In the module I then have

<parent>
    <artifactId>parent</artifactId>
    <groupId>com.example</groupId>
    <version>0.0.${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>

<artifactId>module_${scala.main.version}</artifactId>
<dependencies>
      <dependency>
          <groupId>org.scala-lang</groupId>
          <artifactId>scala-library</artifactId>
      </dependency>
</dependencies>

This feels like the same error as #117 , but with a much simpler setup.