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


Java DependencyGraphBuilderException类代码示例

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


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

示例1: resolveTransitiveDependencies

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Set<Artifact> resolveTransitiveDependencies(Artifact artifact) throws EnforcerRuleException {
  final DependencyNode root;
  try {
    root = dependencyGraphBuilder.buildDependencyGraph(project, null);
  } catch (DependencyGraphBuilderException e) {
    throw new EnforcerRuleException("Unable to build the dependency graph!", e);
  }
  if (logger.isDebugEnabled()) {
    logger.debug("Root node is '" + root + "'.");
  }

  final Set<Artifact> transitiveDependencies = new HashSet<Artifact>();
  traverseDependencyNodes(root, transitiveDependencies);

  final Set<Artifact> directDependencies = resolveDirectDependencies(artifact);
  transitiveDependencies.removeAll(directDependencies);
  if (logger.isDebugEnabled()) {
    logger.debug("Transitive dependencies are '" + transitiveDependencies + "'.");
  }
  return transitiveDependencies;
}
 
开发者ID:ImmobilienScout24,项目名称:illegal-transitive-dependency-check,代码行数:23,代码来源:IllegalTransitiveDependencyCheck.java

示例2: root

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
/**
 * Convert dependency to root artifact.
 * @param dep Dependency
 * @return Root artifact
 */
private MavenRootArtifact root(final Dependency dep) {
    final DefaultArtifact artifact = new DefaultArtifact(
        dep.getGroupId(),
        dep.getArtifactId(),
        dep.getVersion(),
        dep.getScope(),
        dep.getType(),
        dep.getClassifier(),
        new DefaultArtifactHandler()
    );
    try {
        final Collection<Artifact> children = new LinkedList<Artifact>();
        for (final DependencyNode child : this.graph().getChildren()) {
            children.add(child.getArtifact());
        }
        return new MavenRootArtifact(
            artifact,
            dep.getExclusions(),
            children
        );
    } catch (final DependencyGraphBuilderException ex) {
        throw new IllegalStateException(ex);
    }
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:30,代码来源:MavenClasspath.java

示例3: getRootDependencyNode

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
public DependencyNode getRootDependencyNode(final DependencyGraphBuilder dependencyGraphBuilder, final MavenSession session, final MavenProject project,
        final String projectName,
        final String versionName) throws MojoExecutionException {
    org.apache.maven.shared.dependency.graph.DependencyNode rootNode = null;
    final ProjectBuildingRequest buildRequest = new DefaultProjectBuildingRequest(
            session.getProjectBuildingRequest());
    buildRequest.setProject(project);
    buildRequest.setResolveDependencies(true);

    try {
        rootNode = dependencyGraphBuilder.buildDependencyGraph(buildRequest, null);
    } catch (final DependencyGraphBuilderException ex) {
        throw new MojoExecutionException(EXCEPTION_MSG_NO_DEPENDENCY_GRAPH, ex);
    }

    final String groupId = project.getGroupId();
    final String artifactId = project.getArtifactId();
    final String version = versionName;
    final MavenExternalId projectGav = new MavenExternalId(groupId, artifactId, version);

    final Set<DependencyNode> children = new LinkedHashSet<>();
    final DependencyNode root = new DependencyNode(projectName, versionName, projectGav, children);
    for (final org.apache.maven.shared.dependency.graph.DependencyNode child : rootNode.getChildren()) {
        if (includedScopes.contains(child.getArtifact().getScope())) {
            children.add(createCommonDependencyNode(child));
        }
    }

    for (final MavenProject moduleProject : project.getCollectedProjects()) {
        if (!excludedModules.contains(moduleProject.getArtifactId())) {
            final DependencyNode moduleRootNode = getRootDependencyNode(dependencyGraphBuilder, session, moduleProject, moduleProject.getArtifactId(),
                    moduleProject.getVersion());
            children.addAll(moduleRootNode.children);
        }
    }

    return root;
}
 
开发者ID:blackducksoftware,项目名称:hub-maven-plugin,代码行数:39,代码来源:MavenDependencyExtractor.java

示例4: getDependenciesToCheck

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
protected Set<Artifact> getDependenciesToCheck( MavenProject project )
{
    Set<Artifact> dependencies = null;
    try
    {
        DependencyNode node = graphBuilder.buildDependencyGraph( project, null );
        dependencies  = getAllDescendants( node );
    }
    catch ( DependencyGraphBuilderException e )
    {
        // otherwise we need to change the signature of this protected method
        throw new RuntimeException( e );
    }
    return dependencies;
}
 
开发者ID:mojohaus,项目名称:extra-enforcer-rules,代码行数:16,代码来源:BanCircularDependencies.java

示例5: createGraph

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

  GraphBuildingVisitor visitor = new GraphBuildingVisitor(graphBuilder, transitiveDependencyFilter, this.targetFilter, this.omitReachablePaths);
  root.accept(visitor);
}
 
开发者ID:ferstl,项目名称:depgraph-maven-plugin,代码行数:12,代码来源:MavenGraphAdapter.java

示例6: dependencyGraphWithException

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
@Test
public void dependencyGraphWithException() throws Exception {
  DependencyGraphBuilderException cause = new DependencyGraphBuilderException("boom");
  when(this.dependencyGraphBuilder.buildDependencyGraph(ArgumentMatchers.<MavenProject>any(), ArgumentMatchers.<ArtifactFilter>any())).thenThrow(cause);

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

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

示例7: createDependencyTree

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
protected DependencyNode createDependencyTree( MavenProject project, DependencyGraphBuilder dependencyGraphBuilder,
                                               String scope )
    throws MojoExecutionException
{
    ArtifactFilter artifactFilter = createResolvingArtifactFilter( scope );
    try
    {
        return dependencyGraphBuilder.buildDependencyGraph( project, artifactFilter );
    }
    catch ( DependencyGraphBuilderException exception )
    {
        throw new MojoExecutionException( "Cannot build project dependency tree", exception );
    }

}
 
开发者ID:bitstrings,项目名称:nbm-maven,代码行数:16,代码来源:AbstractNbmMojo.java

示例8: getTransitiveDependencies

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
/**
 * Collects the transitive dependencies of the current projects.
 *
 * @param mojo  the mojo
 * @param graph the dependency graph builder
 * @return the set of resolved transitive dependencies.
 */
private static Set<Artifact> getTransitiveDependencies(AbstractWisdomMojo mojo, DependencyGraphBuilder graph,
                                                       ArtifactFilter filter) {
    Set<Artifact> artifacts;
    artifacts = new LinkedHashSet<>();
    try {
        Set<Artifact> transitives = new LinkedHashSet<>();
        DependencyNode node = graph.buildDependencyGraph(mojo.project, filter);
        node.accept(new ArtifactVisitor(mojo, transitives));
        mojo.getLog().debug(transitives.size() + " transitive dependencies have been collected : " +
                transitives);

        // Unfortunately, the retrieved artifacts are not resolved, we need to find their 'surrogates' in the
        // resolved list.
        Set<Artifact> resolved = mojo.project.getArtifacts();
        for (Artifact a : transitives) {
            Artifact r = getArtifact(a, resolved);
            if (r == null) {
                mojo.getLog().warn("Cannot find resolved artifact for " + a);
            } else {
                artifacts.add(r);
            }
        }
    } catch (DependencyGraphBuilderException e) {
        mojo.getLog().error("Cannot traverse the project's dependencies to collect transitive dependencies, " +
                "ignoring transitive");
        mojo.getLog().debug("Here is the thrown exception having disabled the transitive dependency collection", e);
        artifacts = mojo.project.getDependencyArtifacts();
    }
    return artifacts;
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:38,代码来源:DependencyCopy.java

示例9: fetch

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
/**
 * Fetch all files found (JAR, ZIP, directories, etc).
 * @return Set of files
 */
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private Set<File> fetch() {
    final Set<File> files = new LinkedHashSet<File>(0);
    for (final String path : this.elements()) {
        files.add(new File(path));
    }
    try {
        files.addAll(this.dependencies(this.graph(), this.scopes));
    } catch (final DependencyGraphBuilderException ex) {
        throw new IllegalStateException(ex);
    }
    return files;
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:18,代码来源:MavenClasspath.java

示例10: graph

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
/**
 * Build dependency graph.
 * @return Root of dependency graph.
 * @throws DependencyGraphBuilderException In case of error.
 */
private DependencyNode graph() throws DependencyGraphBuilderException {
    return this.builder.buildDependencyGraph(
        this.session.getCurrentProject(),
        new ArtifactFilter() {
            @Override
            public boolean include(
                final Artifact artifact) {
                return MavenClasspath.this.scopes
                    .contains(artifact.getScope());
            }
        }
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:19,代码来源:MavenClasspath.java

示例11: hasToStringWithBrokenDependency

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
/**
 * Classpath can return a string when a dependency is broken.
 * @throws Exception If there is some problem inside
 */
@Test
public void hasToStringWithBrokenDependency() throws Exception {
    final DependencyGraphBuilder builder =
        Mockito.mock(DependencyGraphBuilder.class);
    Mockito.doThrow(
        new DependencyGraphBuilderException("DependencyResolutionException")
    )
        .when(builder)
        .buildDependencyGraph(
            Mockito.any(MavenProject.class),
            Mockito.any(ArtifactFilter.class)
        );
    final MavenSession session = Mockito.mock(MavenSession.class);
    final MavenProject project = this.project(
        this.dependency(
            "junit-broken", "junit-absent", "1.0"
        )
    );
    Mockito.when(session.getCurrentProject()).thenReturn(project);
    final MavenClasspath classpath = new MavenClasspath(
        builder, session, MavenClasspath.TEST_SCOPE
    );
    MatcherAssert.assertThat(
        classpath.toString(),
        Matchers.containsString(
            "failed to load 'junit-broken:junit-absent:jar:1.0 (test)'"
        )
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:34,代码来源:MavenClasspathTest.java

示例12: createDependencyReducedPom

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
private void createDependencyReducedPom( Set<String> artifactsToRemove )
    throws IOException, DependencyGraphBuilderException, ProjectBuildingException
{
    List<Dependency> dependencies = new ArrayList<Dependency>();

    boolean modified = false;

    List<Dependency> transitiveDeps = new ArrayList<Dependency>();

    // NOTE: By using the getArtifacts() we get the completely evaluated artifacts
    // including the system scoped artifacts with expanded values of properties used.
    for ( Artifact artifact : project.getArtifacts() )
    {
        if ( "pom".equals( artifact.getType() ) )
        {
            // don't include pom type dependencies in dependency reduced pom
            continue;
        }

        // promote
        Dependency dep = createDependency( artifact );

        // we'll figure out the exclusions in a bit.
        transitiveDeps.add( dep );
    }
    List<Dependency> origDeps = project.getDependencies();

    if ( promoteTransitiveDependencies )
    {
        origDeps = transitiveDeps;
    }

    Model model = project.getOriginalModel();
    // MSHADE-185: We will remove all system scoped dependencies which usually
    // have some kind of property usage. At this time the properties within
    // such things are already evaluated.
    List<Dependency> originalDependencies = model.getDependencies();
    removeSystemScopedDependencies( artifactsToRemove, originalDependencies );

    for ( Dependency d : origDeps )
    {
        dependencies.add( d );

        String id = getId( d );

        if ( artifactsToRemove.contains( id ) )
        {
            modified = true;

            if ( keepDependenciesWithProvidedScope )
            {
                d.setScope( "provided" );
            }
            else
            {
                dependencies.remove( d );
            }
        }
    }

    // MSHADE-155
    model.setArtifactId( shadedArtifactId );

    // MSHADE-185: We will add those system scoped dependencies
    // from the non interpolated original pom file. So we keep
    // things like this: <systemPath>${tools.jar}</systemPath> intact.
    addSystemScopedDependencyFromNonInterpolatedPom( dependencies, originalDependencies );

    // Check to see if we have a reduction and if so rewrite the POM.
    rewriteDependencyReducedPomIfWeHaveReduction( dependencies, modified, transitiveDeps, model );
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:72,代码来源:ShadeMojo.java

示例13: DependencyGraphException

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

示例14: getChangeLogResources

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
/**
 * Examines the {@linkplain #getProject() current
 * <code>MavenProject</code>}'s dependencies, {@linkplain
 * #getArtifactResolver() resolving} them if necessary, and
 * assembles and returns a {@link Collection} whose elements are
 * {@link URL}s representing reachable changelog fragments that are
 * classpath resources.
 *
 * <p>This method may return {@code null}.</p>
 *
 * <p>This method calls the {@link #getChangeLogResources(Iterable)}
 * method.</p>
 *
 * <p>This method invokes the {@link
 * Artifacts#getArtifactsInTopologicalOrder(MavenProject,
 * DependencyGraphBuilder, ArtifactFilter, ArtifactResolver,
 * ArtifactRepository)} method.</p>
 *
 * @return a {@link Collection} of {@link URL}s to classpath
 * resources that are changelog fragments, or {@code null}
 *
 * @exception IllegalStateException if the return value of {@link
 * #getProject()}, {@link #getDependencyGraphBuilder()} or {@link
 * #getArtifactResolver()} is {@code null}
 * 
 * @exception ArtifactResolutionException if there was a problem
 * {@linkplain ArtifactResolver#resolve(ArtifactResolutionRequest)
 * resolving} a given {@link Artifact} representing a dependency
 *
 * @exception DependencyGraphBuilderException if there was a problem
 * with dependency resolution
 *
 * @exception IOException if there was a problem with input or
 * output
 *
 * @see #getChangeLogResources(Iterable)
 *
 * @see Artifacts#getArtifactsInTopologicalOrder(MavenProject,
 * DependencyGraphBuilder, ArtifactFilter, ArtifactResolver,
 * ArtifactRepository)
 */
public final Collection<? extends URL> getChangeLogResources() throws ArtifactResolutionException, DependencyGraphBuilderException, IOException {
  final MavenProject project = this.getProject();
  if (project == null) {
    throw new IllegalStateException("this.getProject()", new NullPointerException("this.getProject()"));
  }
  final DependencyGraphBuilder dependencyGraphBuilder = this.getDependencyGraphBuilder();
  if (dependencyGraphBuilder == null) {
    throw new IllegalStateException("this.getDependencyGraphBuilder()", new NullPointerException("this.getDependencyGraphBuilder()"));
  }
  final ArtifactResolver resolver = this.getArtifactResolver();
  if (resolver == null) {
    throw new IllegalStateException("this.getArtifactResolver()", new NullPointerException("this.getArtifactResolver()"));
  }
  final Collection<? extends Artifact> artifacts = new Artifacts().getArtifactsInTopologicalOrder(project,
                                                                                                  dependencyGraphBuilder,
                                                                                                  this.getArtifactFilter(),
                                                                                                  resolver,
                                                                                                  this.getLocalRepository());
  Collection<? extends URL> urls = null;
  if (artifacts != null && !artifacts.isEmpty()) {
    urls = getChangeLogResources(artifacts);
  }
  if (urls == null) {
    urls = Collections.emptySet();
  }
  return urls;
}
 
开发者ID:ljnelson,项目名称:liquibase-maven-plugin,代码行数:69,代码来源:AssembleChangeLogMojo.java

示例15: resolveDependencies

import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; //导入依赖的package包/类
/**
 * Resolve dependencies of a project matching the given filter.
 * 
 * @param mavenProject
 *            The {@link MavenProject} whose dependency tree is to be read.
 * @param artifactFilter
 *            An {@link ArtifactFilter} that will determine what artifacts are to qualify.
 * @return A {@link List} of {@link DependencyNode} objects representing the matching dependencies.
 * @throws MojoExecutionException
 *             If any errors occur while trying to resolve the dependencies.
 */
protected List<DependencyNode> resolveDependencies(MavenProject mavenProject, ArtifactFilter artifactFilter) throws MojoExecutionException {
    try {
        return dependencyGraphBuilder.buildDependencyGraph(project, artifactFilter).getChildren();
    } catch (DependencyGraphBuilderException e) {
        throw new MojoExecutionException(String.format("Failed to build dependency graph for project %s", formatIdentifier(project)), e);
    }
}
 
开发者ID:jrh3k5,项目名称:flume-plugin-maven-plugin,代码行数:19,代码来源:AbstractFlumePluginMojo.java


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