Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-5993

Confusing error message in case of missing/empty artifactId and version in pluginManagement

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.3.9
    • 3.5.0-alpha-1, 3.5.0
    • Dependencies
    • None

    Description

      Executing any goals/phases on this pom.xml leads to a weird error

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.example.group</groupId>
        <artifactId>testinvalidpom</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        
        <build>
          <pluginManagement>
              <plugins>
                  <plugin>
                      <groupId></groupId>
                  </plugin>
              </plugins>
          </pluginManagement>
        </build>
      </project>
      

      The error being emitted is

      [ERROR] Error resolving version for plugin ':null' from the repositories [local (<some path>), nexus (<some remote repo url>)]: Plugin not found in any plugin repository -> [Help 1]
      

      Even with debug you only see something like this

      [ERROR] Error resolving version for plugin ':null' from the repositories [...]: Plugin not found in any plugin repository -> [Help 1]
      org.apache.maven.plugin.version.PluginVersionResolutionException: Error resolving version for plugin ':null' from the repositories [local (/Users/konradwindszus/.m2/repository), nexus (https://repo.int.netcentric.biz/nexus/content/groups/public/)]: Plugin not found in any plugin repository
      	at org.apache.maven.plugin.version.internal.DefaultPluginVersionResolver.selectVersion(DefaultPluginVersionResolver.java:236)
      	at org.apache.maven.plugin.version.internal.DefaultPluginVersionResolver.resolveFromRepository(DefaultPluginVersionResolver.java:148)
      	at org.apache.maven.plugin.version.internal.DefaultPluginVersionResolver.resolve(DefaultPluginVersionResolver.java:96)
      	at org.apache.maven.lifecycle.internal.LifecyclePluginResolver.resolveMissingPluginVersions(LifecyclePluginResolver.java:89)
      	at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:116)
      	at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:135)
      	at org.apache.maven.lifecycle.internal.builder.BuilderCommon.resolveBuildPlan(BuilderCommon.java:97)
      	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:109)
      	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
      	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
      	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
      	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
      	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
      	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
      

      In this example the error is easy to spot, but for bigger pom.xmls with more complex hierarchies it is very hard.
      Some basic validation should take place that on the merged pom.xml all of groupId, artifactId and version is available and if that is not the case, the line number of the pom.xml together with the filename should be given out, where the according information is missing.

      A similar error is emitted in case the groupId element is missing as well or there is an empty artifactId.

      Attachments

        Issue Links

          Activity

            People

              khmarbaise Karl Heinz Marbaise
              kwin Konrad Windszus
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: