当前位置: 首页>>代码示例>>Java>>正文


Java DependencyNode.getArtifact方法代码示例

本文整理汇总了Java中org.apache.maven.shared.dependency.graph.DependencyNode.getArtifact方法的典型用法代码示例。如果您正苦于以下问题:Java DependencyNode.getArtifact方法的具体用法?Java DependencyNode.getArtifact怎么用?Java DependencyNode.getArtifact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.shared.dependency.graph.DependencyNode的用法示例。


在下文中一共展示了DependencyNode.getArtifact方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addPackageDependencies

import org.apache.maven.shared.dependency.graph.DependencyNode; //导入方法依赖的package包/类
/**
 * Find all of the dependencies for a specified artifact
 */
private List<PackageDescriptor> addPackageDependencies(PackageDescriptor parent, String groupId, String artifactId, String version,
                                                       DependencyNode parentDep) {
    List<PackageDescriptor> packageDependency = new LinkedList<PackageDescriptor>();
    List<DependencyNode> children = parentDep.getChildren();
    if (children != null) {
        for (DependencyNode node : children) {
            DependencyNodeVisitor nlg = new CollectingDependencyNodeVisitor();
            node.accept(nlg);
            List<DependencyNode> deps = ((CollectingDependencyNodeVisitor) nlg).getNodes();
            for (DependencyNode dep : deps) {
                Artifact artifact = dep.getArtifact();
                PackageDescriptor pkgDep = new PackageDescriptor("maven", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
                // Only include each package once. They might be transitive dependencies from multiple places.
                if (!parents.containsKey(pkgDep)) {
                    pkgDep = request.add("maven", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
                    parents.put(pkgDep, parent);
                    packageDependency.add(pkgDep);
                }
            }
        }
    }
    return packageDependency;
}
 
开发者ID:OSSIndex,项目名称:ossindex-maven-plugin,代码行数:27,代码来源:DependencyAuditor.java

示例2: traverseDependencyNodes

import org.apache.maven.shared.dependency.graph.DependencyNode; //导入方法依赖的package包/类
private void traverseDependencyNodes(DependencyNode node, Set<Artifact> transitiveDependencies)
  throws EnforcerRuleException {
  final List<DependencyNode> children = node.getChildren();
  if ((children == null) || children.isEmpty()) {
    return;
  }
  for (DependencyNode child : children) {
    final Artifact artifact = child.getArtifact();
    enforceArtifactResolution(artifact);
    if (logger.isDebugEnabled()) {
      logger.debug("Add dependency '" + artifact.getId() + "'");
    }
    transitiveDependencies.add(artifact);
    traverseDependencyNodes(child, transitiveDependencies);
  }
}
 
开发者ID:ImmobilienScout24,项目名称:illegal-transitive-dependency-check,代码行数:17,代码来源:IllegalTransitiveDependencyCheck.java

示例3: dependencies

import org.apache.maven.shared.dependency.graph.DependencyNode; //导入方法依赖的package包/类
/**
 * Retrieve dependencies for from given node and scope.
 * @param node Node to traverse.
 * @param scps Scopes to use.
 * @return Collection of dependency files.
 */
private Collection<String> dependencies(final DependencyNode node,
    final Collection<String> scps) {
    final Artifact artifact = node.getArtifact();
    final Collection<String> files = new LinkedList<String>();
    if (artifact.getScope() == null
        || scps.contains(artifact.getScope())) {
        if (artifact.getScope() == null) {
            files.add(artifact.getFile().toString());
        } else {
            files.add(
                this.session.getLocalRepository().find(artifact).getFile()
                    .toString()
            );
        }
        for (final DependencyNode child : node.getChildren()) {
            if (child.getArtifact().compareTo(node.getArtifact()) != 0) {
                files.addAll(this.dependencies(child, scps));
            }
        }
    }
    return files;
}
 
开发者ID:jcabi,项目名称:jcabi-maven-plugin,代码行数:29,代码来源:AjcMojo.java

示例4: dependencies

import org.apache.maven.shared.dependency.graph.DependencyNode; //导入方法依赖的package包/类
/**
 * Retrieve dependencies for from given node and scope.
 * @param node Node to traverse.
 * @param scps Scopes to use.
 * @return Collection of dependency files.
 */
private Collection<File> dependencies(final DependencyNode node,
    final Collection<String> scps) {
    final Artifact artifact = node.getArtifact();
    final Collection<File> files = new LinkedList<File>();
    if ((artifact.getScope() == null)
        || scps.contains(artifact.getScope())) {
        if (artifact.getScope() == null) {
            files.add(artifact.getFile());
        } else {
            files.add(
                this.session.getLocalRepository().find(artifact).getFile()
            );
        }
        for (final DependencyNode child : node.getChildren()) {
            if (child.getArtifact().compareTo(node.getArtifact()) != 0) {
                files.addAll(this.dependencies(child, scps));
            }
        }
    }
    return files;
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:28,代码来源:MavenClasspath.java

示例5: checkDepNode

import org.apache.maven.shared.dependency.graph.DependencyNode; //导入方法依赖的package包/类
private Set<Artifact> checkDepNode(final DependencyNode rootNode,
		final List<ArtifactRepository> repositories, final int level,
		DefaultHttpClient client, MatrixPrinter printer)
		throws MojoFailureException {
	if (!(level < depth))
		return Collections.emptySet();

	HashSet<Artifact> missingArts = new HashSet<Artifact>();
	for (DependencyNode dep : rootNode.getChildren()) {
		Artifact artifact = dep.getArtifact();

		if (!checkSnapshots && artifact.isSnapshot()) {
			printer.printResult(artifact, level, Collections.nCopies(repositories.size(), Result.IGNORED));
		} else {
			final LinkedList<Result> results = new LinkedList<RepositoryCheckerMojo.Result>();
			for (ArtifactRepository repo : repositories) {
				Result result = lookupArtifact(artifact, repo, client);
				results.add(result);
			}

			if (!results.contains(Result.FOUND)) {
				missingArts.add(artifact);
				if (breakOnMissing) {
					throw new MojoFailureException(
							String.format(
									"did not find artifact %s in any of the available repositories",
									artifact.getId()));
				}
			}

			printer.printResult(artifact, level, results);
			missingArts.addAll(checkDepNode(dep, repositories, level + 1, client, printer));
		}
	}
	
	return missingArts;
}
 
开发者ID:apache,项目名称:marmotta,代码行数:38,代码来源:RepositoryCheckerMojo.java

示例6: visit

import org.apache.maven.shared.dependency.graph.DependencyNode; //导入方法依赖的package包/类
@Override
public boolean visit(DependencyNode dependencyNode) {
    Artifact artifact = dependencyNode.getArtifact();
    if (artifact == null) {
        return false;
    }
    if (artifact.getScope() == null) {
        // no scope means the current artifact (root).
        // we have to return true to traverse the dependencies.
        return true;
    }

    if (SCOPE_COMPILE.equals(artifact.getScope())) {
        mojo.getLog().debug("Adding " + artifact.toString() + " to the transitive list");
        artifacts.add(artifact);
    }

    if (SCOPE_PROVIDED.equals(artifact.getScope())) {
        mojo.getLog().debug("Adding " + artifact.toString() + " to the transitive list");
        artifacts.add(artifact);
        return false;
    }

    // The scope of the artifact we retrieved in context-aware. For instance,
    // if we have a dependency in the test scope, all its dependencies will be considered as test dependencies.
    // So we can visit the children, as the pruning is made in the if statement above. (this is related to
    // #263).
    return true;
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:30,代码来源:DependencyCopy.java

示例7: visit

import org.apache.maven.shared.dependency.graph.DependencyNode; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public boolean visit( DependencyNode node )
{
    if ( throwable != null )
    {
        return false;
    }
    if ( root == node )
    {
        return true;
    }
    try
    {
        Artifact artifact = node.getArtifact();
        if ( !artifacts.containsKey( artifact.getDependencyConflictId() ) )
        {
            //ignore non-runtime stuff..
            return false;
        }
        // somehow the transitive artifacts in the  tree are not always resolved?
        artifact = artifacts.get( artifact.getDependencyConflictId() );

        ExamineManifest depExaminator = examinerCache.get( artifact );
        if ( depExaminator == null )
        {
            depExaminator = new ExamineManifest( log );
            depExaminator.setArtifactFile( artifact.getFile() );
            depExaminator.checkFile();
            examinerCache.put( artifact, depExaminator );
        }
        if ( AbstractNbmMojo.matchesLibrary( artifact, explicitLibs, depExaminator, log, useOsgiDependencies ) )
        {
            if ( depExaminator.isNetBeansModule() )
            {
                log.warn(
                    "You are using a NetBeans Module as a Library (classpath extension): " + artifact.getId() );
            }

            nodes.add( artifact );
            includes.add( artifact.getDependencyConflictId() );
            // if a library, iterate to it's child nodes.
            return true;
        }
    }
    catch ( MojoExecutionException mojoExecutionException )
    {
        throwable = mojoExecutionException;
    }
    //don't bother iterating to childs if the current node is not a library.
    return false;
}
 
开发者ID:bitstrings,项目名称:nbm-maven,代码行数:54,代码来源:CollectLibrariesNodeVisitor.java

示例8: visit

import org.apache.maven.shared.dependency.graph.DependencyNode; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public boolean visit( DependencyNode node )
{
    if ( throwable != null )
    {
        return false;
    }
    if ( root == node )
    {
        return true;
    }
    try
    {
        Artifact artifact = node.getArtifact();
        if ( !artifacts.containsKey( artifact.getDependencyConflictId() ) )
        {
            //ignore non-runtime stuff..
            return false;
        }
        // somehow the transitive artifacts in the  tree are not always resolved?
        artifact = artifacts.get( artifact.getDependencyConflictId() );

        ExamineManifest depExaminator = examinerCache.get( artifact );
        if ( depExaminator == null )
        {
            depExaminator = new ExamineManifest( log );
            depExaminator.setArtifactFile( artifact.getFile() );
            depExaminator.checkFile();
            examinerCache.put( artifact, depExaminator );
        }
        if ( depExaminator.isNetBeansModule() || ( useOSGiDependencies && depExaminator.isOsgiBundle() ) )
        {
            currentModule.push( artifact.getDependencyConflictId() );
            ArrayList<Artifact> arts = new ArrayList<Artifact>();
            arts.add( artifact );
            if ( currentModule.size() == 1 )
            {
                directNodes.put( currentModule.peek(), arts );
            }
            else
            {
                transitiveNodes.put( currentModule.peek(), arts );
            }
            return true;
        }
        if ( currentModule.size() > 0 )
        {
            ////MNBMODULE-95 we are only interested in the module owned libraries
            if ( !currentModule.peek().startsWith( LIB_ID ) &&
                    AbstractNbmMojo.matchesLibrary( artifact, Collections.<String>emptyList(), depExaminator, log, useOSGiDependencies ) )
            {
                if ( currentModule.size() == 1 )
                {
                    directNodes.get( currentModule.peek() ).add( artifact );
                }
                else
                {
                    transitiveNodes.get( currentModule.peek() ).add( artifact );
                }
                // if a library, iterate to it's child nodes.
                return true;
            }
        }
        else
        {
            //MNBMODULE-95 we check the non-module dependencies to see if they
            // depend on modules/bundles. these bundles are transitive, so
            // we add the root module as the first currentModule to keep
            //any bundle/module underneath it as transitive
            currentModule.push( LIB_ID + artifact.getDependencyConflictId() );
        }
    }
    catch ( MojoExecutionException mojoExecutionException )
    {
        throwable = mojoExecutionException;
    }
    return true;
}
 
开发者ID:bitstrings,项目名称:nbm-maven,代码行数:81,代码来源:CollectModuleLibrariesNodeVisitor.java


注:本文中的org.apache.maven.shared.dependency.graph.DependencyNode.getArtifact方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。