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


Java DependencyTreeBuilderException类代码示例

本文整理汇总了Java中org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException的典型用法代码示例。如果您正苦于以下问题:Java DependencyTreeBuilderException类的具体用法?Java DependencyTreeBuilderException怎么用?Java DependencyTreeBuilderException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DependencyTreeBuilderException类属于org.apache.maven.shared.dependency.tree包,在下文中一共展示了DependencyTreeBuilderException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDependencyTree

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
private static DependencyNode createDependencyTree(MavenProject project,
        DependencyTreeBuilder dependencyTreeBuilder, ArtifactRepository localRepository,
        ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource,
        ArtifactCollector artifactCollector,
        String scope) {
    ArtifactFilter artifactFilter = createResolvingArtifactFilter(scope);

    try {
        // TODO: note that filter does not get applied due to MNG-3236
        return dependencyTreeBuilder.buildDependencyTree(project,
                localRepository, artifactFactory,
                artifactMetadataSource, artifactFilter, artifactCollector);
    } catch (DependencyTreeBuilderException exception) {
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:DependencyTreeFactory.java

示例2: getDependencyArtifacts

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
protected Set<Artifact> getDependencyArtifacts( Set<?> classPathArtifacts, Artifact rootArtifact )
    throws DependencyTreeBuilderException
{
    Set<Artifact> result = null;

    buildDependencyTree();
    DependencyNode artifactNode = findArtifactNode( rootArtifact, rootNode );
    if ( artifactNode != null )
    {
        result = new HashSet<Artifact>();
        addDependencyArtifacts( result, classPathArtifacts, artifactNode );
    }
    else
    {
        result = Collections.emptySet();
    }

    return result;
}
 
开发者ID:play1-maven-plugin,项目名称:play1-maven-plugin,代码行数:20,代码来源:AbstractDependencyProcessingPlayMojo.java

示例3: constructRepository

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
private Repository constructRepository() throws IOException {
    Repository repo = new DirRepository(classesDirectory.toPath());
    
    if (!quiet) {
        getLog().info("HuntBugs: +dir " + classesDirectory);
    }

    // collecting project dependencies including pom and transitive dependencies
    ArtifactFilter artifactFilter = new ScopeArtifactFilter("compile");
    DependencyNode rootNode;
    try {
        rootNode = treeBuilder.buildDependencyTree(project, session.getLocalRepository(), artifactFilter);
    } catch (DependencyTreeBuilderException e) {
        throw new RuntimeException(e);
    }
    CollectingDependencyNodeVisitor visitor = new CollectingDependencyNodeVisitor();
    rootNode.accept(visitor);

    // converting dependencies to type loaders
    List<DependencyNode> nodes = visitor.getNodes();
    List<ITypeLoader> deps = new ArrayList<>();
    for (DependencyNode dependencyNode : nodes) {
        int state = dependencyNode.getState();

        // checking that transitive dependency is NOT excluded
        if (state == DependencyNode.INCLUDED) {
            Artifact artifact = dependencyNode.getArtifact();
            addDependency(artifact, deps);
        }
    }
    
    if (deps.isEmpty()) {
        return repo;
    }
    
    return new CompositeRepository(
        Arrays.asList(repo, new AuxRepository(new CompositeTypeLoader(deps.toArray(new ITypeLoader[0])))));
}
 
开发者ID:amaembo,项目名称:huntbugs,代码行数:39,代码来源:HuntBugsMojo.java

示例4: getDependenciesToCheck

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
private Set<Artifact> getDependenciesToCheck( MavenProject project, ArtifactRepository localRepository )
{
    Set<Artifact> dependencies = null;
    try
    {
        DependencyNode node = treeBuilder.buildDependencyTree( project, localRepository, null );
        
        if( isSearchTransitive() )
        {
            dependencies  = getAllDescendants( node );
        }
        else if ( node.getChildren() != null )
        {
            dependencies = new HashSet<Artifact>();
            for( DependencyNode depNode : node.getChildren() )
            {
                dependencies.add( depNode.getArtifact() );
            }
        }
    }
    catch ( DependencyTreeBuilderException e )
    {
        // otherwise we need to change the signature of this protected method
        throw new RuntimeException( e );
    }
    return dependencies;
}
 
开发者ID:mojohaus,项目名称:extra-enforcer-rules,代码行数:28,代码来源:AbstractResolveDependencies.java

示例5: getModuleDependencyArtifacts

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
protected Set<Artifact> getModuleDependencyArtifacts( Set<?> classPathArtifacts, Artifact moduleZipArtifact )
    throws DependencyTreeBuilderException
{
    Set<Artifact> result =
        getDependencyArtifactsExt( classPathArtifacts, moduleZipArtifact );
    return result;
}
 
开发者ID:play1-maven-plugin,项目名称:play1-maven-plugin,代码行数:8,代码来源:AbstractDependencyProcessingPlayMojo.java

示例6: getDependencyArtifactsExt

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
private Set<Artifact> getDependencyArtifactsExt( Set<?> classPathArtifacts, Artifact rootArtifact )
    throws DependencyTreeBuilderException
{
    Set<Artifact> result = null;

    buildDependencyTree();
    DependencyNode artifactNode = findArtifactNode( rootArtifact, rootNode );
    if ( artifactNode != null )
    {
        result = new HashSet<Artifact>();
        addDependencyArtifacts( result, classPathArtifacts, artifactNode );
        if ( result.isEmpty() )
        {
            Set<?> projectArtifacts = project.getArtifacts();
            for ( Iterator<?> iter = projectArtifacts.iterator(); iter.hasNext(); )
            {
                Artifact artifact = (Artifact) iter.next();
                if ( artifact != rootArtifact && artifact.getGroupId().equals( rootArtifact.getGroupId() )
                    && artifact.getArtifactId().equals( rootArtifact.getArtifactId() ) )
                {
                    Set<Artifact> tmp = getDependencyArtifacts( classPathArtifacts, artifact );
                    result.addAll( tmp );
                }
            }
        }
    }
    else
    {
        result = Collections.emptySet();
    }

    return result;
}
 
开发者ID:play1-maven-plugin,项目名称:play1-maven-plugin,代码行数:34,代码来源:AbstractDependencyProcessingPlayMojo.java

示例7: buildDependencyTree

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
private void buildDependencyTree()
    throws DependencyTreeBuilderException
{
    if ( rootNode == null )
    {
        rootNode =
            dependencyTreeBuilder.buildDependencyTree( project, localRepository, artifactFactory,
                                                       artifactMetadataSource, null, artifactCollector );
    }
}
 
开发者ID:play1-maven-plugin,项目名称:play1-maven-plugin,代码行数:11,代码来源:AbstractDependencyProcessingPlayMojo.java

示例8: createTree

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
private void createTree(MavenProject project, ArtifactFilter globalFilter, ArtifactFilter transitiveDependencyFilter, GraphBuilder<DependencyNode> graphBuilder) throws DependencyGraphException {
  org.apache.maven.shared.dependency.tree.DependencyNode root;
  try {
    root = this.dependencyTreeBuilder.buildDependencyTree(project, this.artifactRepository, globalFilter);
  } catch (DependencyTreeBuilderException e) {
    throw new DependencyGraphException(e);
  }

  // Due to MNG-3236, we need to filter the artifacts on our own.
  GraphBuildingVisitor visitor = new GraphBuildingVisitor(graphBuilder, globalFilter, transitiveDependencyFilter, this.targetFilter, this.includedResolutions);
  root.accept(visitor);
}
 
开发者ID:ferstl,项目名称:depgraph-maven-plugin,代码行数:13,代码来源:MavenGraphAdapter.java

示例9: dependencyTreeWithException

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
@Test
public void dependencyTreeWithException() throws Exception {
  DependencyTreeBuilderException cause = new DependencyTreeBuilderException("boom");
  when(this.dependencyTreeBuilder.buildDependencyTree(ArgumentMatchers.<MavenProject>any(), ArgumentMatchers.<ArtifactRepository>any(), ArgumentMatchers.<ArtifactFilter>any())).thenThrow(cause);

  this.expectedException.expect(DependencyGraphException.class);
  this.expectedException.expectCause(is(cause));

  this.treeAdapter.buildDependencyGraph(this.mavenProject, this.globalFilter, this.graphBuilder);
}
 
开发者ID:ferstl,项目名称:depgraph-maven-plugin,代码行数:11,代码来源:MavenGraphAdapterTest.java

示例10: getNonProvidedDependencies

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
List<String> getNonProvidedDependencies(String possibleArtifactIds) throws MojoExecutionException {
    try {
        DependencyNode root = depTreeBuilder.buildDependencyTree(project, localRepo, artifactFactory, artifactMetadataSource,
                PROVIDED_SCOPE_FILTER, artifactCollector);
        SubArtifactCollector sac = new SubArtifactCollector(possibleArtifactIds == null ? null : Arrays.asList(new IncludeAndExclude(
                possibleArtifactIds, null).getIncludeSplit()));
        root.accept(sac);
        return sac.getSubArtifactIds();
    } catch (DependencyTreeBuilderException e) {
        throw new MojoExecutionException("error building dependency tree", e);
    }
}
 
开发者ID:mimacom,项目名称:maven-liferay-plugin,代码行数:13,代码来源:CreatePortalMojo.java

示例11: checkDependencies

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
/**
 * @param mavenProject Base pom to check.
 * @param artifactRepository Repository to use when resolving artifacts.
 * @param dependencyTreeBuilder {@link DependencyTreeBuilder} instance to use
 *          to build a dependency tree.
 * @param scope Dependency scope to use. See {@link Artifact} SCOPE constants.
 * @param checkers A list of one or more {@link SciJavaDependencyChecker}s.
 *          Each will visit the constructed dependency tree.
 * @throws SciJavaDependencyException If one or more of the given checkers
 *           visitations ultimately returns {@code true}, indicating a failed
 *           state was discovered.n
 */
public static void checkDependencies(final MavenProject mavenProject,
	final ArtifactRepository artifactRepository,
	final DependencyTreeBuilder dependencyTreeBuilder, final String scope,
	final SciJavaDependencyChecker... checkers)
	throws SciJavaDependencyException
{
	final ArtifactFilter artifactFilter = createResolvingArtifactFilter(scope);
	try {
		// Build the dependency tree that will be visited by each checker.
		final DependencyNode root =
			dependencyTreeBuilder.buildDependencyTree(mavenProject,
				artifactRepository, artifactFilter);

		String failureMessage = "";

		// Iterate over each checker, visiting the dependency tree and aggregating
		// failure messages.
		for (final SciJavaDependencyChecker checker : checkers) {
			if (root.accept(checker)) {
				failureMessage += checker.makeExceptionMessage();
			}
		}

		// throw an exception if one or more checker failed.
		if (!failureMessage.isEmpty()) {
			throw new SciJavaDependencyException(failureMessage);
		}
	}
	catch (final DependencyTreeBuilderException e) {
		throw new SciJavaDependencyException(e.getMessage());
	}
}
 
开发者ID:scijava,项目名称:scijava-maven-plugin,代码行数:45,代码来源:DependencyUtils.java

示例12: processPackage

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
private void processPackage() throws MojoExecutionException {
    try {
        //Limit the transitivity of a dependency, and also to affect the classpath used for various build tasks.
        ArtifactFilter artifactFilter = createResolvingArtifactFilter();

        DependencyResolver dependencyResolver = new DefaultDependencyResolver();
        DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(project,
                localRepository, artifactFilter);

        DependencyResolutionResult drr = dependencyResolver.resolve(rootNode);

        Map<String, List<Artifact>> conflictDependencyArtifact = drr
                .getConflictDependencyArtifact();
        Map<String, Artifact> results = drr.getResolvedDependenciesByName();
        if (!conflictDependencyArtifact.isEmpty()) {
            Iterator<Entry<String, List<Artifact>>> iter = conflictDependencyArtifact
                    .entrySet().iterator();
            while (iter.hasNext()) {
                Entry<String, List<Artifact>> conflictEntries = iter.next();
                StringBuilder sb = new StringBuilder("Founded conflicting dependency component:");
                List<Artifact> conflictArtifacts = conflictEntries.getValue();
                sb.append(conflictEntries.getKey())
                        .append("\n Resolved version is "
                                + results.get(conflictEntries.getKey()))
                        .append("\n But found conflicting artifact ");
                for (Artifact at : conflictArtifacts) {
                    sb.append(String.format("%s:%s:%s,", at.getGroupId(), at.getArtifactId(),
                            at.getVersion()));
                }
                getLog().warn(sb.subSequence(0, sb.length() - 1));
            }
        }
    } catch (DependencyTreeBuilderException e) {
        throw new MojoExecutionException("Cannot build project dependency ", e);
    }
}
 
开发者ID:vongosling,项目名称:dependency-mediator,代码行数:37,代码来源:DependencyMediatorMojo.java

示例13: getFrameworkDependencyArtifacts

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
protected Set<Artifact> getFrameworkDependencyArtifacts( Set<?> classPathArtifacts, Artifact frameworkJarArtifact )
    throws DependencyTreeBuilderException
{
    Set<Artifact> result = getDependencyArtifactsExt( classPathArtifacts, frameworkJarArtifact );
    return result;
}
 
开发者ID:play1-maven-plugin,项目名称:play1-maven-plugin,代码行数:7,代码来源:AbstractDependencyProcessingPlayMojo.java

示例14: execute

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        // find the nar dependency
        Artifact narArtifact = null;
        for (final Artifact artifact : project.getDependencyArtifacts()) {
            if (NAR.equals(artifact.getType())) {
                // ensure the project doesn't have two nar dependencies
                if (narArtifact != null) {
                    throw new MojoExecutionException("Project can only have one NAR dependency.");
                }

                // record the nar dependency
                narArtifact = artifact;
            }
        }

        // ensure there is a nar dependency
        if (narArtifact == null) {
            throw new MojoExecutionException("Project does not have any NAR dependencies.");
        }

        // build the project for the nar artifact
        final ProjectBuildingRequest narRequest = new DefaultProjectBuildingRequest();
        narRequest.setRepositorySession(repoSession);
        narRequest.setSystemProperties(System.getProperties());
        final ProjectBuildingResult narResult = projectBuilder.build(narArtifact, narRequest);

        // get the artifact handler for excluding dependencies
        final ArtifactHandler narHandler = excludesDependencies(narArtifact);
        narArtifact.setArtifactHandler(narHandler);

        // nar artifacts by nature includes dependencies, however this prevents the
        // transitive dependencies from printing using tools like dependency:tree.
        // here we are overriding the artifact handler for all nars so the
        // dependencies can be listed. this is important because nar dependencies
        // will be used as the parent classloader for this nar and seeing what
        // dependencies are provided is critical.
        final Map<String, ArtifactHandler> narHandlerMap = new HashMap<>();
        narHandlerMap.put(NAR, narHandler);
        artifactHandlerManager.addHandlers(narHandlerMap);

        // get the dependency tree
        final DependencyNode root = dependencyTreeBuilder.buildDependencyTree(narResult.getProject(), localRepository, null);

        // write the appropriate output
        DependencyNodeVisitor visitor = null;
        if ("tree".equals(mode)) {
            visitor = new TreeWriter();
        } else if ("pom".equals(mode)) {
            visitor = new PomWriter();
        }

        // ensure the mode was specified correctly
        if (visitor == null) {
            throw new MojoExecutionException("The specified mode is invalid. Supported options are 'tree' and 'pom'.");
        }

        // visit and print the results
        root.accept(visitor);
        getLog().info("--- Provided NAR Dependencies ---\n\n" + visitor.toString());
    } catch (DependencyTreeBuilderException | ProjectBuildingException e) {
        throw new MojoExecutionException("Cannot build project dependency tree", e);
    }
}
 
开发者ID:apache,项目名称:nifi-maven,代码行数:66,代码来源:NarProvidedDependenciesMojo.java

示例15: DependencyGraphException

import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; //导入依赖的package包/类
public DependencyGraphException(DependencyTreeBuilderException cause) {
  super(cause);
}
 
开发者ID:ferstl,项目名称:depgraph-maven-plugin,代码行数:4,代码来源:DependencyGraphException.java


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