mojohaus / flatten-maven-plugin

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

Does not work with https://github.com/jcgay/maven-distinct-local-repository #232

Closed dimovelev closed 1 year ago

dimovelev commented 3 years ago

It seems that the artifact lookup is not compatible with the extension above. when the flatten plugin is disabled and the extension is enabled, the build succeeds and the snapshots and releases local repositories are split as expected. When the plugin is also enabled, the build fails in the plugin because it refers to a file in the local repository which does not include the releases/snapshots split. Exception looks like that:

[INFO] --- flatten-maven-plugin:1.2.5:flatten (flatten) @ xxx ---
[DEBUG] Configuring mojo org.codehaus.mojo:flatten-maven-plugin:1.2.5:flatten from plugin realm ClassRealm[plugin>org.codehaus.mojo:flatten-maven-plugin:1.2.5, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@659e0bfd]
[DEBUG] Configuring mojo 'org.codehaus.mojo:flatten-maven-plugin:1.2.5: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:///C:/Users/dimo/.m2/repository/
   layout: default
snapshots: [enabled => true, update => always]
 releases: [enabled => true, update => always]

[DEBUG]   (f) mojoExecution = org.codehaus.mojo:flatten-maven-plugin:1.2.5:flatten {execution: flatten}
[DEBUG]   (f) outputDirectory = d:\src\xxx
[DEBUG]   (f) project = MavenProject: xxx:xxx:1.0-SNAPSHOT @ d:\src\xxx\pom.xml
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@fe7b6b0
[DEBUG]   (f) updatePomFile = true
[DEBUG] -- end configuration --
[INFO] Generating flattened POM of project xxx:xxx:pom:1.0-SNAPSHOT...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for xxx 1.0-SNAPSHOT:
[INFO]
[INFO] xxx ....................................... FAILURE [  1.823 s]
[INFO] xxx-config ................................ SKIPPED
[INFO] xxx-application ........................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.215 s
[INFO] Finished at: 2021-09-24T14:05:38+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.2.5:flatten (flatten) on project xxx: 1 problem was encountered while building the effective model for xxx:xxx:1.0-SNAPSHOT
[ERROR] [FATAL] Non-readable POM C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom: C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom (The system cannot find the path specified) @ C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom
[ERROR]
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.2.5:flatten (flatten) on project xxx: 1 problem was encountered while building the effective model for xxx:xxx:1.0-SNAPSHOT
[FATAL] Non-readable POM C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom: C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom (The system cannot find the path specified) @ C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: 1 problem was encountered while building the effective model for xxx:xxx:1.0-SNAPSHOT
[FATAL] Non-readable POM C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom: C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom (The system cannot find the path specified) @ C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom

    at org.codehaus.mojo.flatten.FlattenMojo.createEffectivePom (FlattenMojo.java:906)
    at org.codehaus.mojo.flatten.FlattenMojo.createFlattenedPom (FlattenMojo.java:545)
    at org.codehaus.mojo.flatten.FlattenMojo.execute (FlattenMojo.java:387)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.model.building.ModelBuildingException: 1 problem was encountered while building the effective model for xxx:xxx:1.0-SNAPSHOT
[FATAL] Non-readable POM C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom: C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom (The system cannot find the path specified) @ C:\Users\dimo\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.5.5\spring-boot-dependencies-2.5.5.pom

    at org.apache.maven.model.building.DefaultModelProblemCollector.newModelBuildingException (DefaultModelProblemCollector.java:197)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:498)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:440)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:430)
    at org.codehaus.mojo.flatten.ModelBuilderThreadSafetyWorkaround.build (ModelBuilderThreadSafetyWorkaround.java:130)
    at org.codehaus.mojo.flatten.FlattenMojo.createEffectivePom (FlattenMojo.java:902)
    at org.codehaus.mojo.flatten.FlattenMojo.createFlattenedPom (FlattenMojo.java:545)
    at org.codehaus.mojo.flatten.FlattenMojo.execute (FlattenMojo.java:387)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
GethDeeo commented 1 year ago

Now that Maven 3.9.0 came out with split repository feature built in, I'm experiencing a very similar bug with latest flatten-maven-plugin. Since I rely heavily on the plugin, right now this issue blocks using the split repo feature :(

slawekjaranowski commented 1 year ago

This PR should fix it: #336