mojohaus / flatten-maven-plugin

Flatten Maven Plugin
https://www.mojohaus.org/flatten-maven-plugin/
Apache License 2.0
201 stars 85 forks source link

resolveCiFriendliesOnly does not use custom repository maven option to resolve dependencymanagement. #101

Open aygalinc opened 5 years ago

aygalinc commented 5 years ago

Hi,

I have a project that use the flatten maven plugin with this configuration :

 <configuration>
          <updatePomFile>true</updatePomFile>
          <flattenMode>resolveCiFriendliesOnly</flattenMode>
        </configuration>

and replace central maven repository by a cutom configuration in order to use a private artifactory server :

 <!-- All build will use artifactory cache -->
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>libs-release</name>
      <url>http://galaxy-server1.private.com:80/artifactory/libs-release</url>
    </repository>
    <repository>
      <snapshots/>
      <id>snapshots</id>
      <name>libs-snapshot</name>
      <url>http://galaxy-server1.private.com:80/artifactory/libs-snapshot</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>libs-release</name>
      <url>http://galaxy-server1.private.com:80/artifactory/libs-release</url>
    </pluginRepository>
    <pluginRepository>
      <snapshots/>
      <id>snapshots</id>
      <name>libs-snapshot</name>
      <url>http://galaxy-server1.private.com:80/artifactory/libs-snapshot</url>
    </pluginRepository>
  </pluginRepositories>

This project has a dependency on some artifact published on an Artifactory server and based on a BOM :

  <dependencyManagement>
    <dependencies>
      <!-- Forum Stack dependencies -->
      <dependency>
        <groupId>com.se.gxl</groupId>
        <artifactId>gxl.forum.stack.depchain</artifactId>
        <version>${forum-head-version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

The BOM file published on the server is the following :

<parent>
    <groupId>com.se.gxl</groupId>
    <artifactId>gxl.forum.reactor</artifactId>
    <version>0.0.9-SNAPSHOT</version>
  </parent>
  <groupId>com.se.gxl</groupId>
  <artifactId>gxl.forum.stack.depchain</artifactId>
  <version>0.0.9-SNAPSHOT</version>
  <packaging>pom</packaging>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.se.gxl</groupId>
        <artifactId>gxl.forum.services</artifactId>
        <version>${project.version}</version>
      </dependency>
....

When I launch build with mvn clean install -X :

[DEBUG] [buildinfo] Resolved artifact: org.apache.maven.shared:maven-shared-utils:jar:3.0.0:build from: central (http://galaxy-server1.private.com:80/artifactory/libs-release, default, releases) Context is: plugin
[DEBUG] [buildinfo] Resolved artifact: commons-io:commons-io:jar:2.4:build from: central (http://galaxy-server1.private.com:80/artifactory/libs-release, default, releases) Context is: plugin
[DEBUG] [buildinfo] Resolved artifact: com.google.code.findbugs:jsr305:jar:2.0.1:build from: central (http://galaxy-server1.private.com:80/artifactory/libs-release, default, releases) Context is: plugin
[DEBUG] [buildinfo] Resolved artifact: commons-codec:commons-codec:jar:1.6:build from: central (http://galaxy-server1.private.com:80/artifactory/libs-release, default, releases) Context is: plugin
[DEBUG] [buildinfo] Resolved artifact: org.slf4j:slf4j-api:jar:1.7.5:build from: central (http://galaxy-server1.private.com:80/artifactory/libs-release, default, releases) Context is: plugin
[DEBUG] Created new class realm plugin>org.codehaus.mojo:flatten-maven-plugin:1.1.0
[DEBUG] Importing foreign packages into class realm plugin>org.codehaus.mojo:flatten-maven-plugin:1.1.0
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>org.codehaus.mojo:flatten-maven-plugin:1.1.0
[DEBUG]   Included: org.codehaus.mojo:flatten-maven-plugin:jar:1.1.0
[DEBUG]   Included: org.codehaus.plexus:plexus-interpolation:jar:1.21
[DEBUG]   Included: org.codehaus.plexus:plexus-component-annotations:jar:1.5.5
[DEBUG]   Included: org.eclipse.aether:aether-util:jar:1.0.0.v20140518
[DEBUG]   Included: javax.enterprise:cdi-api:jar:1.0
[DEBUG]   Included: org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.0.M1
[DEBUG]   Included: org.sonatype.sisu:sisu-guice:jar:no_aop:3.2.3
[DEBUG]   Included: aopalliance:aopalliance:jar:1.0
[DEBUG]   Included: com.google.guava:guava:jar:16.0.1
[DEBUG]   Included: org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3
[DEBUG]   Included: org.sonatype.plexus:plexus-cipher:jar:1.4
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:3.0.24
[DEBUG]   Included: org.apache.maven.shared:maven-artifact-transfer:jar:0.9.0
[DEBUG]   Included: org.apache.maven.shared:maven-common-artifact-filters:jar:3.0.0
[DEBUG]   Included: org.sonatype.sisu:sisu-inject-bean:jar:1.4.2
[DEBUG]   Included: org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7
[DEBUG]   Included: org.apache.maven.shared:maven-shared-utils:jar:3.0.0
[DEBUG]   Included: commons-io:commons-io:jar:2.4
[DEBUG]   Included: com.google.code.findbugs:jsr305:jar:2.0.1
[DEBUG]   Included: commons-codec:commons-codec:jar:1.6
[DEBUG] Configuring mojo org.codehaus.mojo:flatten-maven-plugin:1.1.0:flatten from plugin realm ClassRealm[plugin>org.codehaus.mojo:flatten-maven-plugin:1.1.0, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[DEBUG] Configuring mojo 'org.codehaus.mojo:flatten-maven-plugin:1.1.0:flatten' with basic configurator -->
[DEBUG]   (f) embedBuildProfileDependencies = false
[DEBUG]   (f) flattenMode = resolveCiFriendliesOnly
[DEBUG]   (f) flattenedPomFilename = .flattened-pom.xml
[DEBUG]   (f) localRepository =       id: local
      url: file:///home/caygalin/.m2/repository/
   layout: default
snapshots: [enabled => true, update => always]
 releases: [enabled => true, update => always]

[DEBUG]   (f) mojoExecution = org.codehaus.mojo:flatten-maven-plugin:1.1.0:flatten {execution: flatten}
[DEBUG]   (f) outputDirectory = /home/caygalin/Workspace/edge-applications/gx.iotb.samplerpublisher.application
[DEBUG]   (f) pomElements = org.codehaus.mojo.flatten.FlattenDescriptor@224c7de4
[DEBUG]   (f) project = MavenProject: com.se.iotbridge:samplerpublisher:0.0.2 @ /home/caygalin/Workspace/edge-applications/gx.iotb.samplerpublisher.application/pom.xml
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@5b498842
[DEBUG]   (f) updatePomFile = true
[DEBUG] -- end configuration --
[INFO] Generating flattened POM of project com.se.iotbridge:samplerpublisher:jar:0.0.2...
[DEBUG] Could not find metadata com.se.gxl:gxl.forum.reactor:0.0.9-SNAPSHOT/maven-metadata.xml in local (/home/caygalin/.m2/repository)
[DEBUG] Verifying availability of /home/caygalin/.m2/repository/com/se/gxl/gxl.forum.reactor/0.0.9-SNAPSHOT/gxl.forum.reactor-0.0.9-SNAPSHOT.pom from [central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] [buildinfo] Could not resolve artifact: com.se.gxl:gxl.forum.reactor:pom:0.0.9-SNAPSHOT:project
[WARNING] The POM for com.se.gxl:gxl.forum.reactor:pom:0.0.9-SNAPSHOT is missing, no dependency information available
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=26101, ConflictMarker.markTime=37891, ConflictMarker.nodeCount=2, ConflictIdSorter.graphTime=7623, ConflictIdSorter.topsortTime=30730, ConflictIdSorter.conflictIdCount=1, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=202392, ConflictResolver.conflictItemCount=1, DefaultDependencyCollector.collectTime=4775753, DefaultDependencyCollector.transformTime=344816}
[DEBUG] Verifying availability of /home/caygalin/.m2/repository/com/se/gxl/gxl.forum.reactor/0.0.9-SNAPSHOT/gxl.forum.reactor-0.0.9-SNAPSHOT.pom from [central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] [buildinfo] Could not resolve artifact: com.se.gxl:gxl.forum.reactor:pom:0.0.9-SNAPSHOT:project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.489 s
[INFO] Finished at: 2019-07-04T22:07:15+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.1.0:flatten (flatten) on project samplerpublisher: 1 problem was encountered while building the effective model for com.se.iotbridge:samplerpublisher:0.0.2
[ERROR] [FATAL] Non-resolvable parent POM for com.se.gxl:gxl.forum.stack.depchain:0.0.9-SNAPSHOT: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact com.se.gxl:gxl.forum.reactor:pom:0.0.9-SNAPSHOT @ com.se.gxl:gxl.forum.stack.depchain:0.0.9-SNAPSHOT

If i read the resolveCiFriendliesOnly doc, normaly only revision & changeList and sha1 are replaced, why the plug in try to download the parent remote dependency ? Also the download fails because the plug in not use the repository configuration of the POM file as we can see. It is an expected behavior ?

Regards,

aygalinc commented 5 years ago

I think it is related (even a duplicat of https://github.com/mojohaus/flatten-maven-plugin/issues/89 )