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

Failure with Maven CI friendly versioning; unresolved placeholder in download URL #3022

Closed
famod opened this issue Mar 23, 2023 · 13 comments
Closed
Labels
bug Something isn't working question Further information is requested

Comments

@famod
Copy link

famod commented Mar 23, 2023

When running curl -Ls https://sh.jbang.dev | bash -s - --fresh upgrade-to-quarkus3@quarkusio, I'm getting the following error in one of my modules (and only in that one!):

[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.41.0:run (default-cli) on project register-archive-server: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.41.0:run failed: Illegal character in path at index 81: file:///home/famod/.m2/repository/somecompany/someproject/register-archive-parent/${revision}.${changelist}-dev3/register-archive-parent-${revision}.${changelist}-dev3.pom -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.41.0:run (default-cli) on project register-archive-server: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.41.0:run failed: Illegal character in path at index 81: file:///home/famod/.m2/repository/somecompany/someproject/register-archive-parent/${revision}.${changelist}-dev3/register-archive-parent-${revision}.${changelist}-dev3.pom
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.41.0:run failed: Illegal character in path at index 81: file:///home/famod/.m2/repository/somecompany/someproject/register-archive-parent/${revision}.${changelist}-dev3/register-archive-parent-${revision}.${changelist}-dev3.pom
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 81: file:///home/famod/.m2/repository/somecompany/someproject/register-archive-parent/${revision}.${changelist}-dev3/register-archive-parent-${revision}.${changelist}-dev3.pom
    at java.net.URI.create (URI.java:906)
    at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:487)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:353)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively (ResolvedPom.java:310)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolve (ResolvedPom.java:299)
    at org.openrewrite.maven.tree.ResolvedPom.resolve (ResolvedPom.java:144)
    at org.openrewrite.maven.tree.Pom.resolve (Pom.java:104)
    at org.openrewrite.maven.MavenParser.parseInputs (MavenParser.java:105)
    at org.openrewrite.Parser.parse (Parser.java:41)
    at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:311)
    at org.openrewrite.maven.MavenMojoProjectParser.listSourceFiles (MavenMojoProjectParser.java:120)
    at org.openrewrite.maven.AbstractRewriteMojo.listResults (AbstractRewriteMojo.java:272)
    at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:53)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
Caused by: java.net.URISyntaxException: Illegal character in path at index 81: file:///home/famod/.m2/repository/somecompany/someproject/register-archive-parent/${revision}.${changelist}-dev3/register-archive-parent-${revision}.${changelist}-dev3.pom
    at java.net.URI$Parser.fail (URI.java:2974)
    at java.net.URI$Parser.checkChars (URI.java:3145)
    at java.net.URI$Parser.parseHierarchical (URI.java:3227)
    at java.net.URI$Parser.parse (URI.java:3175)
    at java.net.URI.<init> (URI.java:623)
    at java.net.URI.create (URI.java:904)
    at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:487)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:353)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively (ResolvedPom.java:310)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolve (ResolvedPom.java:299)
    at org.openrewrite.maven.tree.ResolvedPom.resolve (ResolvedPom.java:144)
    at org.openrewrite.maven.tree.Pom.resolve (Pom.java:104)
    at org.openrewrite.maven.MavenParser.parseInputs (MavenParser.java:105)
    at org.openrewrite.Parser.parse (Parser.java:41)
    at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:311)
    at org.openrewrite.maven.MavenMojoProjectParser.listSourceFiles (MavenMojoProjectParser.java:120)
    at org.openrewrite.maven.AbstractRewriteMojo.listResults (AbstractRewriteMojo.java:272)
    at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:53)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)

This archive-server module is located in archive/server. The other two modules where a Quarkus app is built (not sure this matters) are located in server and testdata-server and those two are not failing! So the nesting depth might be relevant?
Then again there are two other simple lib-like modules under archive/ that don't fail. There are even more modules next to server and testdata-server that don't fail either.

pom-xml setup is as follows:
archive/server/pom.xml:

    <parent>
        <groupId>somecompany.someproject</groupId>
        <artifactId>register-archive-parent</artifactId>
        <version>${revision}.${changelist}${sha1}</version>
    </parent>
    <artifactId>register-archive-server</artifactId>

archive:

    <parent>
        <groupId>somecompany.someproject</groupId>
        <artifactId>register-parent</artifactId>
        <version>${revision}.${changelist}${sha1}</version>
    </parent>
    <artifactId>register-archive-parent</artifactId>

root parent (has no parent):

    <groupId>somecompany.someproject</groupId>
    <artifactId>register-parent</artifactId>
    <version>${revision}.${changelist}${sha1}</version>
    <packaging>pom</packaging>
<!-- ... -->
    <properties>
        <revision>4.2.0</revision>
        <changelist>local</changelist>
        <sha1></sha1>   <!-- can be used locally as a discriminator to keep multiple clones separated -->
<!-- ... -->

sha1 is set via export MAVEN_OPTS="${MAVEN_OPTS} -Dsha1=-dev3" (in .envrc for direnv, but that shouldn't matter`).

I cannot share the project (closed source) and so far I haven't been able to create a reproducer.

Any thoughts? @nmck257 maybe?

/cc @gsmet

@famod
Copy link
Author

famod commented Mar 23, 2023

Btw, I can see flatten-maven-plugin:1.3.0:flatten being executed in the lifecycle forked by openrewrite.
Using Maven 3.8.8.

@timtebeek timtebeek added bug Something isn't working question Further information is requested labels Mar 23, 2023
@knutwannheden
Copy link
Contributor

@famod Thanks for the report! It looks like OpenRewrite is having issues with the Maven CI friendly version properties in the parent <version> element. We will investigate this and keep you posted.

@nmck257
Copy link
Collaborator

nmck257 commented Mar 23, 2023

yeah, this has been my bane for many months (#2049), and new occurrences of the issue keep waiting until just after I've forgotten everything about it.

@famod can you also share the parent elements for some of the other (working) modules, for comparison?

@famod
Copy link
Author

famod commented Mar 23, 2023

@nmck257

@famod can you also share the parent elements for some of the other (working) modules, for comparison?

Sure, but that's the thing: there is no difference!

archive/shared/pom.xml

    <parent>
        <groupId>somecompany.someproject</groupId>
        <artifactId>register-archive-parent</artifactId>
        <version>${revision}.${changelist}${sha1}</version>
    </parent>
    <artifactId>register-archive-shared</artifactId>

server/pom.xml

    <parent>
        <groupId>somecompany.someproject</groupId>
        <artifactId>register-parent</artifactId>
        <version>${revision}.${changelist}${sha1}</version>
    </parent>
    <artifactId>register-server</artifactId>

Maybe related, maybe not: the failing archive/server module depends on archive/shared (and other modules outside of archive, e.g. common).
We also have a couple of inter-module test-jar dependencies, but that shouldn't be relevant either.

@nmck257
Copy link
Collaborator

nmck257 commented Mar 23, 2023

  • are you running the recipe from the root of the project, or the root of the archive/server module?
  • is archive/server the only thing with a dependency on archive/shared? the issue could be occurring when the pom-resolution "stack" is ProjectPomA -> ProjectPomB (who's parent is another project pom referenced via CI-friendly versions) -> ProjectPomB's Parent

@famod
Copy link
Author

famod commented Mar 23, 2023

  • are you running the recipe from the root of the project, or the root of the archive/server module?

From the root.

* is `archive/server` the only thing with a dependency on `archive/shared`? the issue could be occurring when the pom-resolution "stack" is ProjectPomA -> ProjectPomB (who's parent is another project pom referenced via CI-friendly versions) -> ProjectPomB's Parent

No, there is also this chain:
common1 <- common2 <- archive/shared <- archive/job <- server (not archive/server!)

The other chain is:
common1 <- common2 <- archive/shared <- archive/server

To give more context:
Our main backend "service" is server. A special interface has to be exposed to external partners for archiving data, for which we have archive/server.
At the same time only the main server shall run scheduled jobs and there is one for archiving (in archive/job). And then there is common code for both servers, in archive/shared and those common modules.

What might be relevant is that we list most modules in dependencyManagement of the root parent (so that we can omit the version), e.g.:

            <dependency>
                <groupId>somecompany.someproject</groupId>
                <artifactId>register-archive-shared</artifactId>
                <version>${project.version}</version>
            </dependency>

@nmck257
Copy link
Collaborator

nmck257 commented Mar 24, 2023

hmm -- yeah, if you're able to isolate this into a test project / RewriteTest case which reproduces the issue, then that should do the most to help get to a fix

@pjotteri
Copy link

pjotteri commented Apr 1, 2023

A version range in parent also fails in similar way.

    <parent>
        <groupId>anothercompany</groupId>
        <artifactId>our-parent</artifactId>
	<version>[3.0.0,3.0.5)</version>
    </parent>

causes :

Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.42.0:run failed

...

Caused by: java.net.URISyntaxException: Illegal character in path at index 58: file:///Users/me/.m2/repository/anothercompany/our-parent/[3.0.0,3.0.5)/our-parent-[3.0.0,3.0.5).pom
    at java.net.URI$Parser.fail (URI.java:2873)
    at java.net.URI$Parser.checkChars (URI.java:3046)
    at java.net.URI$Parser.parseHierarchical (URI.java:3130)
    at java.net.URI$Parser.parse (URI.java:3078)
    at java.net.URI.<init> (URI.java:588)
    at java.net.URI.create (URI.java:850)
    at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:487)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:353)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:364)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively (ResolvedPom.java:310)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolve (ResolvedPom.java:299)
    at org.openrewrite.maven.tree.ResolvedPom.resolve (ResolvedPom.java:144)
    at org.openrewrite.maven.tree.Pom.resolve (Pom.java:104)
    at org.openrewrite.maven.MavenParser.parseInputs (MavenParser.java:105)
    at org.openrewrite.Parser.parse (Parser.java:41)
    at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:350)

Parent version is not resolved before it is used?

@knutwannheden
Copy link
Contributor

@pjotteri In the upcoming release this case should be fixed: #3023

@pjotteri
Copy link

pjotteri commented Apr 1, 2023

Nice, Thanks.

@sambsnyd
Copy link
Member

sambsnyd commented Apr 8, 2023

Closing this as a release with @knutwannheden 's fix is now available. Let us know if it is still a problem

@famod
Copy link
Author

famod commented Apr 12, 2023

@sambsnyd @knutwannheden I'm afraid to report that 4.43.0 of the maven-plugin does not fix this issue. 😕

@famod
Copy link
Author

famod commented Apr 12, 2023

Trace looks a bit different now:

[...]
Caused by: java.net.URISyntaxException: Illegal character in path at index 73: [...]
    at java.net.URI$Parser.fail (URI.java:2974)
    at java.net.URI$Parser.checkChars (URI.java:3145)
    at java.net.URI$Parser.parseHierarchical (URI.java:3227)
    at java.net.URI$Parser.parse (URI.java:3175)
    at java.net.URI.<init> (URI.java:623)
    at java.net.URI.create (URI.java:904)
    at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:487)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPom (ResolvedPom.java:413)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:353)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively (ResolvedPom.java:310)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolve (ResolvedPom.java:299)
    at org.openrewrite.maven.tree.ResolvedPom.resolve (ResolvedPom.java:144)
    at org.openrewrite.maven.tree.Pom.resolve (Pom.java:104)
    at org.openrewrite.maven.MavenParser.parseInputs (MavenParser.java:105)
    at org.openrewrite.Parser.parse (Parser.java:41)
    at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:363)
    at org.openrewrite.maven.AbstractRewriteMojo.listResults (AbstractRewriteMojo.java:276)
    at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:54)
    [...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
Archived in project
Development

No branches or pull requests

6 participants