NPanday
  1. NPanday
  2. NPANDAY-411

Transitive dependency resolution requires explicit version in a dependent child pom

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4-incubating
    • Fix Version/s: 1.5.0-incubating
    • Component/s: Maven Plugins
    • Labels:
      None
    • Environment:

      Description

      In the past, NPanday required the version of a dependency in pom.xml to be explicit, whereas now that has been fixed so that a parent pom.xml can specify the version in the dependencyManagement section instead.

      Suppose we have 3 projects called Parent, Library and Executable. The Parent pom refers to both Library and Executable projects as modules, and also acts as the super pom for both Library and Executable projects. The Executable project depends on the Library project. The Parent project defaults the version of another dotnet-library (let's say ThirdParty) used by the Library project in the Parent's dependencyManagement section.

      The Library project builds successfully. However, when attempting to build the Executable project, it complains during dependency resolution that the version is missing from ThirdParty and the build fails. Now, while the version is physically missing from the Library pom.xml file, it is not missing from the effective pom for the Library and should therefore not give any error, just as no error is given when the Library project builds.

      WARNING: NPANDAY-180-003: Project Version is missing: Group Id = NUnit, Artifact Id = NUnit.Framework
      [INFO] ------------------------------------------------------------------------
      [ERROR] FATAL ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] null
      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      java.lang.NullPointerException
      	at npanday.dao.Project.hashCode(Project.java:329)
      	at java.util.HashMap.put(HashMap.java:372)
      	at java.util.HashSet.add(HashSet.java:200)
      	at npanday.dao.Project.addProjectDependency(Project.java:204)
      	at npanday.dao.ProjectFactory.createProjectFrom(ProjectFactory.java:147)
      	at npanday.dao.impl.ProjectDaoImpl.storeProjectAndResolveDependencies(ProjectDaoImpl.java:866)
      	at npanday.dao.impl.ProjectDaoImpl.storeProjectAndResolveDependencies(ProjectDaoImpl.java:414)
      	at npanday.artifact.impl.AssemblyResolverImpl.resolveTransitivelyFor(AssemblyResolverImpl.java:131)
      	at npanday.plugin.compile.ComponentInitializerMojo.execute(ComponentInitializerMojo.java:86)
      	at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
      	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
      	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
      	at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      

        Activity

        Hide
        Lars Corneliussen added a comment -

        Fixed by NPANDAY-231

        Show
        Lars Corneliussen added a comment - Fixed by NPANDAY-231
        Hide
        Brennan Gaunce added a comment -

        In addition, it appears that properties cannot be used as versions, which increases the need for specifying the version in the parent pom for a large multi-module project.

        Show
        Brennan Gaunce added a comment - In addition, it appears that properties cannot be used as versions, which increases the need for specifying the version in the parent pom for a large multi-module project.
        Hide
        Brett Porter added a comment -

        scheduling to go along with RDF removal

        Show
        Brett Porter added a comment - scheduling to go along with RDF removal
        Hide
        Brett Porter added a comment -

        The original issue was worked around, but the root issue is that NPanday doesn't use Maven's POM construction and resolution, but reproduces much of it it imperfectly. We're in a long process of removing that.

        Show
        Brett Porter added a comment - The original issue was worked around, but the root issue is that NPanday doesn't use Maven's POM construction and resolution, but reproduces much of it it imperfectly. We're in a long process of removing that.
        Hide
        John R. Fallows added a comment -

        This issue reproduces both when the ThirdParty dependency is "test" scope and when scope is omitted (default="compile" scope).

        Show
        John R. Fallows added a comment - This issue reproduces both when the ThirdParty dependency is "test" scope and when scope is omitted (default="compile" scope).
        Hide
        John R. Fallows added a comment -

        Note that using an expression to describe the version, such as nunit.version fails as follows:

        NPANDAY-1005-0001: Error copying dependency NUnit:NUnit.Framework:dotnet-library:${nunit.version}:test File /home/jfallows/.m2/repository/NUnit/NUnit.Framework/${nunit.version}/NUnit.Framework-${nunit.version}.dll does not exist
        

        It seems as though the expression is not evaluated prior to constructing the artifact name.

        Show
        John R. Fallows added a comment - Note that using an expression to describe the version, such as nunit.version fails as follows: NPANDAY-1005-0001: Error copying dependency NUnit:NUnit.Framework:dotnet-library:${nunit.version}:test File /home/jfallows/.m2/repository/NUnit/NUnit.Framework/${nunit.version}/NUnit.Framework-${nunit.version}.dll does not exist It seems as though the expression is not evaluated prior to constructing the artifact name.

          People

          • Assignee:
            Lars Corneliussen
            Reporter:
            John R. Fallows
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development