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

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

Open
RPCMoritz opened this issue Feb 21, 2022 · 0 comments

Comments

@RPCMoritz
Copy link

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.

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

1 participant