[MNG-8504] Maven deploy with "release-profile" fails due to exception in plugin validation
- Dominant language
- Java
- Stars
- 5.3k
- Forks
- 3.1k
- Avg merge
- 20h 42m
- Merged PRs (30d)
- 297
Description
**[Dieter Deforce](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=JIRAUSER308275)** opened **[MNG-8504](https://issues.apache.org/jira/browse/MNG-8504?redirect=false)** and commented
Since Maven version 3.9.3 we are running into an exception when trying to release Maven projects with the built-in "release-profile". This bug is still present in 3.9.9. It only seems to happen when the plugin validation tries to report a warning related to the Maven deploy plugin. Instead of reporting the plugin warning it fails the build with the following stack trace:
```java
[ERROR] Illegal char <:> at index 3: jar:file:\C:\projects\tools\apache-maven-3.9.9\lib\maven-model-builder-3.9.9.jar!\org\apache\maven\model\pom-4.0.0.xml
java.nio.file.InvalidPathException: Illegal char <:> at index 3: jar:file:\C:\projects\tools\apache-maven-3.9.9\lib\maven-model-builder-3.9.9.jar!\org\apache\maven\model\pom-4.0.0.xml
at sun.nio.fs.WindowsPathParser.normalize (WindowsPathParser.java:182)
at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:153)
at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:77)
at sun.nio.fs.WindowsPath.parse (WindowsPath.java:92)
at sun.nio.fs.WindowsFileSystem.getPath (WindowsFileSystem.java:232)
at java.io.File.toPath (File.java:2387)
at org.apache.maven.plugin.internal.DefaultPluginValidationManager.pluginDeclaration (DefaultPluginValidationManager.java:322)
at org.apache.maven.plugin.internal.DefaultPluginValidationManager.reportPluginMojoValidationIssue (DefaultPluginValidationManager.java:203)
at org.apache.maven.plugin.internal.DeprecatedCoreExpressionValidator.lambda$doValidate$0 (DeprecatedCoreExpressionValidator.java:80)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept (ForEachOps.java:183)
at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:197)
at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:179)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential (ForEachOps.java:150)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential (ForEachOps.java:173)
at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach (ReferencePipeline.java:596)
at org.apache.maven.plugin.internal.DeprecatedCoreExpressionValidator.doValidate (DeprecatedCoreExpressionValidator.java:80)
at org.apache.maven.plugin.internal.AbstractMavenPluginParametersValidator.validate (AbstractMavenPluginParametersValidator.java:85)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo (DefaultMavenPluginManager.java:570)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:114)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
```
I found that the fix for issue MNG-7795 introduced this regression in the class DefaultPluginValidationManager. The reason the plugin validation logic throws this exception is because the built-in "release-profile" is defined in the super pom, which is not a file system resource, but a classpath resource defined in maven-model-builder-3.9.9.jar. When the DefaultPluginValidationManager detects a validation issue with a plugin then it tries to print the filesystem location of the pom.xml file containing the validation error. But the modified code in MNG-7795 tries to use the java.nio.file.Path API to print the path to the super pom file, which fails because the Path API doesn't support paths that point to resources inside of JAR files.
I have included a minimal sample project which reproduces the error when you execute the command
```java
mvn -X -Prelease-profile deploy
```
with Maven 3.9.3 or above. The build log of the build is attached as well.
---
**Affects:** 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.9.8, 3.9.9
**Attachments:**
- [build.log](https://issues.apache.org/jira/secure/attachment/13073859/build.log) (_127.36 kB_)
- [release-profile-validation-bug-project.zip](https://issues.apache.org/jira/secure/attachment/13073860/release-profile-validation-bug-project.zip) (_1.50 kB_)
Contributor guide
Research direction
Start with DefaultPluginValidationManager, especially the pluginDeclaration path described in the stack trace, and review the change associated with MNG-7795. Reproduce the failure with the attached sample project using mvn -X -Prelease-profile deploy on Windows. Done means plugin validation reports the warning without throwing InvalidPathException for the super POM resource inside the JAR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100