Package org.apache.maven.model

Examples of org.apache.maven.model.DependencyManagement


   @Override
   public List<Dependency> getManagedDependencies()
   {
      MavenFacet maven = getOrigin().getFacet(MavenFacet.class);
      Model pom = maven.getPOM();
      DependencyManagement depMan = pom.getDependencyManagement();

      List<Dependency> managedDependencies = null;
      if (depMan != null)
         managedDependencies = MavenDependencyAdapter.fromMavenList(depMan.getDependencies());
      else
         managedDependencies = new ArrayList<Dependency>();

      List<Dependency> result = new ArrayList<Dependency>();
      for (Dependency dependency : managedDependencies)
View Full Code Here


   @Override
   public Dependency getManagedDependency(final Dependency manDep)
   {
      MavenFacet maven = getOrigin().getFacet(MavenFacet.class);
      Model pom = maven.getPOM();
      DependencyManagement depMan = pom.getDependencyManagement();

      List<Dependency> managedDependencies = depMan != null ? MavenDependencyAdapter.fromMavenList(depMan
               .getDependencies()) : new ArrayList<Dependency>();

      for (Dependency managedDependency : managedDependencies)
      {
         if (Dependencies.areEquivalent(managedDependency, resolveProperties(manDep)))
View Full Code Here

                result.addMessage(
                    "For dependency " + d + ": only dependency with system scope can specify systemPath." );
            }
        }

        DependencyManagement mgmt = model.getDependencyManagement();
        if ( mgmt != null )
        {
            for ( Iterator it = mgmt.getDependencies().iterator(); it.hasNext(); )
            {
                Dependency d = (Dependency) it.next();

                validateSubElementStringNotEmpty( d, "dependencyManagement.dependencies.dependency.artifactId", result,
                                                  d.getArtifactId() );
View Full Code Here

    }

    private void mergeManagedDependencies(Model model, ArtifactRepository localRepository, List parentSearchRepositories)
        throws ProjectBuildingException
    {
        DependencyManagement modelDepMgmt = model.getDependencyManagement();

        if (modelDepMgmt != null)
        {
            Map depsMap = new TreeMap();
            Iterator iter = modelDepMgmt.getDependencies().iterator();
            boolean doInclude = false;
            while (iter.hasNext())
            {
                Dependency dep = (Dependency) iter.next();
                depsMap.put( dep.getManagementKey(), dep );
                if ( dep.getType().equals( "pom" ) && Artifact.SCOPE_IMPORT.equals( dep.getScope() ) )
                {
                    doInclude = true;
                }
            }
            Map newDeps = new TreeMap(depsMap);
            iter = modelDepMgmt.getDependencies().iterator();
            if (doInclude)
            {
                while (iter.hasNext())
                {
                    Dependency dep = (Dependency)iter.next();
                    if ( dep.getType().equals( "pom" )
                         && Artifact.SCOPE_IMPORT.equals( dep.getScope() ) )
                    {
                        Artifact artifact = artifactFactory.createProjectArtifact( dep.getGroupId(), dep.getArtifactId(),
                                                                                  dep.getVersion(), dep.getScope() );
                        MavenProject project = buildFromRepository(artifact, parentSearchRepositories, localRepository, false);

                        DependencyManagement depMgmt = project.getDependencyManagement();

                        if (depMgmt != null)
                        {
                            if ( getLogger().isDebugEnabled() )
                            {
                                getLogger().debug( "Importing managed dependencies for " + dep.toString() );
                            }

                            for ( Iterator it = depMgmt.getDependencies().iterator(); it.hasNext(); )
                            {
                                Dependency includedDep = (Dependency) it.next();
                                String key = includedDep.getManagementKey();
                                if (!newDeps.containsKey(key))
                                {
View Full Code Here

        exclusion.addExclusion( ex );
        List<Dependency> list = new ArrayList<Dependency>();
        list.add( exclusion );

        depMgt = new DependencyManagement();
        depMgt.setDependencies( list );


        project.setArtifacts( allArtifacts );
        project.setDependencyArtifacts( directArtifacts );
View Full Code Here

   @Override
   public void addDirectManagedDependency(final Dependency dep)
   {
      MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
      Model pom = maven.getModel();
      DependencyManagement depMan = pom.getDependencyManagement();
      depMan = depMan != null ? depMan : new DependencyManagement();

      List<Dependency> managedDependencies = MavenDependencyAdapter.fromMavenList(depMan.getDependencies());
      ListIterator<Dependency> managedDepsIterator = managedDependencies.listIterator();
      boolean found = false;
      while (managedDepsIterator.hasNext())
      {
         Dependency managedDependency = managedDepsIterator.next();
         if (Dependencies.areEquivalent(managedDependency, dep))
         {
            managedDepsIterator.set(dep);
            found = true;
         }
      }
      if (!found)
      {
         managedDependencies.add(dep);
      }
      depMan.setDependencies(MavenDependencyAdapter.toMavenList(managedDependencies));
      pom.setDependencyManagement(depMan);
      maven.setModel(pom);
   }
View Full Code Here

   public Dependency getEffectiveManagedDependency(final Dependency manDep)
   {
      MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
      try
      {
         DependencyManagement depMan = ((MavenFacetImpl) maven).getProjectBuildingResult().getProject()
                  .getDependencyManagement();
         List<Dependency> managedDependencies = (depMan != null ? MavenDependencyAdapter.fromMavenList(depMan
                  .getDependencies()) : new ArrayList<Dependency>());

         for (Dependency managedDependency : managedDependencies)
         {
            if (Dependencies.areEquivalent(managedDependency, resolveProperties(manDep)))
View Full Code Here

   @Override
   public boolean hasDirectManagedDependency(final Dependency managedDependency)
   {
      MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
      Model pom = maven.getModel();
      DependencyManagement depMan = pom.getDependencyManagement();

      List<Dependency> managedDependencies = depMan != null ? MavenDependencyAdapter.fromMavenList(depMan
               .getDependencies()) : new ArrayList<Dependency>();

      for (Dependency manDep : managedDependencies)
      {
         if (Dependencies.areEquivalent(resolveProperties(managedDependency), manDep))
View Full Code Here

   @Override
   public void removeManagedDependency(final Dependency manDep)
   {
      MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
      Model pom = maven.getModel();
      DependencyManagement depMan = pom.getDependencyManagement();
      depMan = depMan != null ? depMan : new DependencyManagement();

      List<Dependency> managedDependencies = MavenDependencyAdapter.fromMavenList(depMan.getDependencies());

      List<Dependency> toBeRemoved = new ArrayList<>();
      for (Dependency managedDependency : managedDependencies)
      {
         if (Dependencies.areEquivalent(managedDependency, manDep))
         {
            toBeRemoved.add(managedDependency);
         }
      }
      managedDependencies.removeAll(toBeRemoved);
      depMan.setDependencies(MavenDependencyAdapter.toMavenList(managedDependencies));
      pom.setDependencyManagement(depMan);
      maven.setModel(pom);
   }
View Full Code Here

   @Override
   public List<Dependency> getManagedDependencies()
   {
      MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
      Model pom = maven.getModel();
      DependencyManagement depMan = pom.getDependencyManagement();

      List<Dependency> managedDependencies = null;
      if (depMan != null)
         managedDependencies = MavenDependencyAdapter.fromMavenList(depMan.getDependencies());
      else
         managedDependencies = new ArrayList<>();

      List<Dependency> result = new ArrayList<>();
      for (Dependency dependency : managedDependencies)
View Full Code Here

TOP

Related Classes of org.apache.maven.model.DependencyManagement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.