本文整理汇总了Java中org.apache.maven.shared.dependency.graph.DependencyGraphBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DependencyGraphBuilder类的具体用法?Java DependencyGraphBuilder怎么用?Java DependencyGraphBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DependencyGraphBuilder类属于org.apache.maven.shared.dependency.graph包,在下文中一共展示了DependencyGraphBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: before
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
@Before
public void before() throws Exception {
this.globalFilter = mock(ArtifactFilter.class);
this.transitiveIncludeExcludeFilter = mock(ArtifactFilter.class);
this.targetFilter = mock(ArtifactFilter.class);
when(this.globalFilter.include(ArgumentMatchers.<Artifact>any())).thenReturn(true);
when(this.transitiveIncludeExcludeFilter.include(ArgumentMatchers.<Artifact>any())).thenReturn(true);
when(this.targetFilter.include(ArgumentMatchers.<Artifact>any())).thenReturn(true);
org.apache.maven.shared.dependency.graph.DependencyNode dependencyNode = mock(org.apache.maven.shared.dependency.graph.DependencyNode.class);
this.dependencyGraphBuilder = mock(DependencyGraphBuilder.class);
when(this.dependencyGraphBuilder.buildDependencyGraph(ArgumentMatchers.<MavenProject>any(), ArgumentMatchers.<ArtifactFilter>any())).thenReturn(dependencyNode);
this.adapter = new MavenGraphAdapter(this.dependencyGraphBuilder, this.transitiveIncludeExcludeFilter, this.targetFilter, false);
this.graphBuilder = GraphBuilder.create(ToStringNodeIdRenderer.INSTANCE);
this.collectedProjectSupplier = new SubProjectSupplier() {
@Override
public Collection<MavenProject> getSubProjects(MavenProject parent) {
return parent.getCollectedProjects();
}
};
}
示例2: before
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
@Before
public void before() throws Exception {
this.mavenProject = new MavenProject();
Artifact projectArtifact = mock(Artifact.class);
this.mavenProject.setArtifact(projectArtifact);
this.globalFilter = mock(ArtifactFilter.class);
this.transitiveIncludeExcludeFilter = mock(ArtifactFilter.class);
this.targetFilter = mock(ArtifactFilter.class);
this.graphBuilder = GraphBuilder.create(ToStringNodeIdRenderer.INSTANCE);
this.dependencyGraphBuilder = mock(DependencyGraphBuilder.class);
when(this.dependencyGraphBuilder.buildDependencyGraph(ArgumentMatchers.<MavenProject>any(), ArgumentMatchers.<ArtifactFilter>any())).thenReturn(mock(org.apache.maven.shared.dependency.graph.DependencyNode.class));
this.dependencyTreeBuilder = mock(DependencyTreeBuilder.class);
when(this.dependencyTreeBuilder.buildDependencyTree(ArgumentMatchers.<MavenProject>any(), ArgumentMatchers.<ArtifactRepository>any(), ArgumentMatchers.<ArtifactFilter>any())).thenReturn(mock(org.apache.maven.shared.dependency.tree.DependencyNode.class));
this.artifactRepository = mock(ArtifactRepository.class);
this.graphAdapter = new MavenGraphAdapter(this.dependencyGraphBuilder, this.transitiveIncludeExcludeFilter, this.targetFilter, false);
this.treeAdapter = new MavenGraphAdapter(this.dependencyTreeBuilder, this.artifactRepository, this.transitiveIncludeExcludeFilter, this.targetFilter, allOf(NodeResolution.class));
}
示例3: setupNativeHelper
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
@Before
public void setupNativeHelper() {
MavenProject project = new MavenProject();
project.setDependencyArtifacts(Collections.<Artifact>emptySet());
ArtifactStub apklib = new ArtifactStub() {
@Override
public String getId() {
return getArtifactId();
}
};
apklib.setArtifactId("some-apklib");
apklib.setGroupId("group");
apklib.setType(AndroidExtension.APKLIB);
project.addAttachedArtifact(apklib);
final DependencyGraphBuilder dependencyGraphBuilder = new DefaultDependencyGraphBuilder();
nativeHelper = new NativeHelper(project, dependencyGraphBuilder, new SilentLog());
}
示例4: getArtifactsToConsider
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
/**
* Gets the list of artifact to consider during the analysis.
*
* @param mojo the mojo
* @param graph the dependency graph builder
* @param transitive do we have to include transitive dependencies
* @return the set of artifacts
*/
public static Set<Artifact> getArtifactsToConsider(AbstractWisdomMojo mojo, DependencyGraphBuilder graph,
boolean transitive, ArtifactFilter filter) {
// No transitive.
Set<Artifact> artifacts;
if (!transitive) {
// Direct dependencies that the current project has (no transitives)
artifacts = mojo.project.getDependencyArtifacts();
} else {
// All dependencies that the current project has, including transitive ones. Contents are lazily
// populated, so depending on what phases have run dependencies in some scopes won't be
// included.
artifacts = getTransitiveDependencies(mojo, graph, filter);
}
return artifacts;
}
示例5: comparesToAnotherClasspath
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
/**
* Classpath can be compared to another classpath.
* @throws Exception If there is some problem inside
*/
@Test
public void comparesToAnotherClasspath() throws Exception {
final DependencyGraphBuilder builder =
Mockito.mock(DependencyGraphBuilder.class);
final MavenSession session = Mockito.mock(MavenSession.class);
final MavenProject project = this.project(
this.dependency(
"org.apache.commons", "commons-lang3-absent", "3.0"
)
);
Mockito.when(session.getCurrentProject()).thenReturn(project);
final MavenClasspath classpath = new MavenClasspath(
builder, session, MavenClasspath.TEST_SCOPE
);
MatcherAssert.assertThat(classpath, Matchers.equalTo(classpath));
MatcherAssert.assertThat(
classpath.canEqual(classpath),
Matchers.is(true)
);
}
示例6: getRootDependencyNode
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的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;
}
示例7: MavenGraphAdapter
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
public MavenGraphAdapter(DependencyGraphBuilder builder, ArtifactFilter transitiveIncludeExcludeFilter, ArtifactFilter targetFilter, boolean omitReachablePaths) {
this.dependencyGraphBuilder = builder;
this.transitiveIncludeExcludeFilter = transitiveIncludeExcludeFilter;
this.targetFilter = targetFilter;
this.omitReachablePaths = omitReachablePaths;
this.includedResolutions = allOf(NodeResolution.class);
this.dependencyTreeBuilder = null;
this.artifactRepository = null;
}
示例8: initializeDependencyGraphBuilder
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
private void initializeDependencyGraphBuilder(EnforcerRuleHelper helper) throws EnforcerRuleException {
try {
dependencyGraphBuilder = helper.getContainer().lookup(DependencyGraphBuilder.class, "default");
} catch (ComponentLookupException e) {
throw new EnforcerRuleException("Unable to lookup dependency graph builder!", e);
}
}
开发者ID:ImmobilienScout24,项目名称:illegal-transitive-dependency-check,代码行数:8,代码来源:IllegalTransitiveDependencyCheck.java
示例9: createDependencyTree
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的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 );
}
}
示例10: getTransitiveDependencies
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的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;
}
示例11: MavenClasspath
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
/**
* Public ctor.
* @param bldr Dependency graph builder.
* @param sess Maven session.
* @param scps All scopes to include
*/
public MavenClasspath(final DependencyGraphBuilder bldr,
final MavenSession sess, final Collection<String> scps) {
super();
this.builder = bldr;
this.session = sess;
this.scopes = new HashSet<String>(scps);
}
示例12: buildsClasspath
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
/**
* MavenClasspath can build a classpath.
* @throws Exception If there is some problem inside
*/
@Test
public void buildsClasspath() throws Exception {
final String group = "junit";
final String jar = "junit-4.10.jar";
final DependencyGraphBuilder builder = this.builder(jar);
final MavenSession session = Mockito.mock(MavenSession.class);
final MavenProject project = this.project(
this.dependency(
group, group, "4.10"
)
);
Mockito.when(session.getCurrentProject()).thenReturn(project);
MatcherAssert.assertThat(
new MavenClasspath(builder, session, JavaScopes.TEST),
Matchers.<File>hasItems(
Matchers.hasToString(
Matchers.endsWith(
String.format(
MavenClasspathTest.SDIR,
System.getProperty(MavenClasspathTest.FILE_SEP)
)
)
),
Matchers.hasToString(Matchers.endsWith(jar))
)
);
}
示例13: buildsClasspathWithMoreScopes
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
/**
* MavenClasspath can build a classpath when there are more scopes.
* @throws Exception If there is some problem inside
*/
@Test
public void buildsClasspathWithMoreScopes() throws Exception {
final String artf = "jcabi-xml";
final String vrs = "0.17.2";
final String jar = "%s-%s.jar";
final DependencyGraphBuilder builder = this.builder(
String.format(jar, artf, vrs)
);
final MavenSession session = Mockito.mock(MavenSession.class);
final MavenProject project = this.project(
this.dependency("com.jcabi", artf, vrs)
);
Mockito.when(session.getCurrentProject()).thenReturn(project);
MatcherAssert.assertThat(
new MavenClasspath(
builder, session, JavaScopes.TEST, JavaScopes.COMPILE
),
Matchers.<File>hasItems(
Matchers.hasToString(
Matchers.endsWith(
String.format(
MavenClasspathTest.SDIR,
System.getProperty(MavenClasspathTest.FILE_SEP)
)
)
),
Matchers.hasToString(
Matchers.endsWith(
String.format(jar, artf, vrs)
)
)
)
);
}
示例14: hasToStringWithBrokenDependency
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的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)'"
)
);
}
示例15: injectDependencies
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; //导入依赖的package包/类
private void injectDependencies(EnforcerRuleHelper enforcerRuleHelper) throws ComponentLookupException {
this.log = enforcerRuleHelper.getLog();
this.dependencyGraphBuilder =
(DependencyGraphBuilder) enforcerRuleHelper.getComponent(DependencyGraphBuilder.class);
}