4 Replies Latest reply on Apr 30, 2013 5:16 PM by myannou

    how to obtain maven effective dependencies from an external pom ?

    myannou

      Hello,

       

      I am developping a plugin in which I would like to analyse all current maven depdencies and compare them to all dependency from an external pom.

      For this I need to obtain all effective dependencies of the external pom, but how could I do it in a Forge plugin ?

       

       

      What I did, I changed the current pom parent to, temporaly, replace the parent with the external pom then save it, so that I can use the dependencyFacet.getEffectiveDependencies() method :

       

       Model pom = mvn.getPOM();
        Model backupPom = pom.clone();
        update = changePomParent(out, currentParent, update, depParentOfficial, lastVersion, pom);
        if (update) {
        mvn.setPOM(pom);
        }
        DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class);
        officialDeps = dependencyFacet.getEffectiveDependencies();
        if (update) {
        mvn.setPOM(backupPom);
        }
      
      

       

      But, as you can guess, it is not really a good solution because:

      - I have to change the current pom

      - and it add the dependencies of the current pom

       

      Thanks for your help

      Yann