本文整理汇总了Java中org.apache.maven.shared.dependency.tree.DependencyTreeBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DependencyTreeBuilder类的具体用法?Java DependencyTreeBuilder怎么用?Java DependencyTreeBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DependencyTreeBuilder类属于org.apache.maven.shared.dependency.tree包,在下文中一共展示了DependencyTreeBuilder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDependencyTree
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; //导入依赖的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;
}
示例2: MavenEnvironment
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; //导入依赖的package包/类
public MavenEnvironment(MavenSession aMavenSession, BuildPluginManager aBuildPluginManager, Log aLog,
DependencyTreeBuilder aDependencyTreeBuilder, ArtifactRepository aLocalRepository,
SecDispatcher aSecurityDispatcher, MavenProjectBuilder aProjectBuilder,
LifecycleExecutor aLifecycleExecutor, ArtifactFactory aArtifactFactory,
ArtifactMetadataSource aArtifactMetadataSource, ArtifactCollector aArtifactCollector, RuntimeInformation aRuntimeInformation,
MojoExecution aExecution) {
mavenSession = aMavenSession;
buildPluginManager = aBuildPluginManager;
log = aLog;
dependencyTreeBuilder = aDependencyTreeBuilder;
localRepository = aLocalRepository;
securityDispatcher = aSecurityDispatcher;
projectBuilder = aProjectBuilder;
lifecycleExecutor = aLifecycleExecutor;
artifactFactory = aArtifactFactory;
artifactMetadataSource = aArtifactMetadataSource;
artifactCollector = aArtifactCollector;
runtimeInformation = aRuntimeInformation;
mojoExecution = aExecution;
}
示例3: before
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; //导入依赖的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));
}
示例4: initialize
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; //导入依赖的package包/类
public static void initialize(MavenSession aMavenSession, BuildPluginManager aBuildPluginManager, Log aLog,
DependencyTreeBuilder aDependencyTreeBuilder, ArtifactRepository aLocalRepository,
SecDispatcher aSecurityDispatcher, MavenProjectBuilder aProjectBuilder,
LifecycleExecutor aLifecycleExecutor, ArtifactFactory aArtifactFactory,
ArtifactMetadataSource aArtifactMetadataSource, ArtifactCollector aArtifactCollector, RuntimeInformation aRuntimeInformation, MojoExecution aExecution) {
ENVIRONMENT.set(new MavenEnvironment(aMavenSession, aBuildPluginManager, aLog,
aDependencyTreeBuilder, aLocalRepository,
aSecurityDispatcher, aProjectBuilder,
aLifecycleExecutor, aArtifactFactory,
aArtifactMetadataSource, aArtifactCollector, aRuntimeInformation, aExecution));
}
示例5: MavenGraphAdapter
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; //导入依赖的package包/类
public MavenGraphAdapter(DependencyTreeBuilder builder, ArtifactRepository artifactRepository, ArtifactFilter transitiveIncludeExcludeFilter, ArtifactFilter targetFilter, Set<NodeResolution> includedResolutions) {
this.dependencyTreeBuilder = builder;
this.artifactRepository = artifactRepository;
this.transitiveIncludeExcludeFilter = transitiveIncludeExcludeFilter;
this.targetFilter = targetFilter;
this.omitReachablePaths = false;
this.includedResolutions = includedResolutions;
this.dependencyGraphBuilder = null;
}
示例6: checkDependencies
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; //导入依赖的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());
}
}
示例7: getDependencyTreeBuilder
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; //导入依赖的package包/类
public DependencyTreeBuilder getDependencyTreeBuilder() {
return dependencyTreeBuilder;
}
示例8: testInitialize
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; //导入依赖的package包/类
@Test
public void testInitialize() {
assertNull(MavenEnvironment.get());
MavenSession aMavenSession = mock(MavenSession.class);
BuildPluginManager aBuildPluginManager = mock(BuildPluginManager.class);
Log aLog = mock(Log.class);
DependencyTreeBuilder aDependencyTreeBuilder = mock(DependencyTreeBuilder.class);
ArtifactRepository aLocalRepository = mock(ArtifactRepository.class);
SecDispatcher aSecurityDispatcher = mock(SecDispatcher.class);
MavenProjectBuilder aProjectBuilder = mock(MavenProjectBuilder.class);
LifecycleExecutor aLifecycleExecutor = mock(LifecycleExecutor.class);
ArtifactFactory aArtifactFactory = mock(ArtifactFactory.class);
ArtifactMetadataSource aArtifactMetadataSource = mock(ArtifactMetadataSource.class);
ArtifactCollector aArtifactCollector = mock(ArtifactCollector.class);
RuntimeInformation aRuntimeInformation = mock(RuntimeInformation.class);
MojoExecution theExecution = mock(MojoExecution.class);
MavenEnvironment.initialize(aMavenSession, aBuildPluginManager, aLog,
aDependencyTreeBuilder, aLocalRepository,
aSecurityDispatcher, aProjectBuilder,
aLifecycleExecutor, aArtifactFactory,
aArtifactMetadataSource, aArtifactCollector, aRuntimeInformation, theExecution);
MavenEnvironment theMavenEnvironment = MavenEnvironment.get();
assertNotNull(theMavenEnvironment);
assertSame(aMavenSession, theMavenEnvironment.getMavenSession());
assertSame(aBuildPluginManager, theMavenEnvironment.getBuildPluginManager());
assertSame(aLog, theMavenEnvironment.getLog());
assertSame(aDependencyTreeBuilder, theMavenEnvironment.getDependencyTreeBuilder());
assertSame(aLocalRepository, theMavenEnvironment.getLocalRepository());
assertSame(aSecurityDispatcher, theMavenEnvironment.getSecurityDispatcher());
assertSame(aProjectBuilder, theMavenEnvironment.getProjectBuilder());
assertSame(aLifecycleExecutor, theMavenEnvironment.getLifecycleExecutor());
assertSame(aArtifactFactory, theMavenEnvironment.getArtifactFactory());
assertSame(aArtifactMetadataSource, theMavenEnvironment.getArtifactMetadataSource());
assertSame(aArtifactCollector, theMavenEnvironment.getArtifactCollector());
assertSame(aRuntimeInformation, theMavenEnvironment.getRuntimeInformation());
MavenEnvironment.cleanUp();;
assertNull(MavenEnvironment.get());
}
示例9: resolveExecutionClasspath
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; //导入依赖的package包/类
/**
* Resolves the processing unit's dependencies classpath.
*
* @param project the processing unit project
* @param includeScopes the scopes of the dependencies to include
* @param includeProjects whether to include project's output directories
* @param reactorProjects the reactor projects
* @param dependencyTreeBuilder the dependency tree builder
* @param metadataSource the metadata source
* @param artifactCollector the artifact collector
* @param artifactResolver the artifact resolver
* @param artifactFactory the artifact factory
* @param localRepository the local repository
* @param remoteRepositories the remote repositories
* @return a list containing all dependency URLs.
* @throws Exception
*/
static List resolveExecutionClasspath(MavenProject project, String[] includeScopes,
boolean includeProjects, List reactorProjects, DependencyTreeBuilder dependencyTreeBuilder,
ArtifactMetadataSource metadataSource, ArtifactCollector artifactCollector,
ArtifactResolver artifactResolver, ArtifactFactory artifactFactory,
ArtifactRepository localRepository, List remoteRepositories) throws Exception {
Set scopes = new HashSet(includeScopes.length);
Collections.addAll(scopes, includeScopes);
// resolve all dependency of the specifies scope
// scope 'test' is the widest scope available.
ArtifactFilter artifactFilter = new ScopeArtifactFilter("test");
DependencyNode root = dependencyTreeBuilder.buildDependencyTree(project, localRepository, artifactFactory,
metadataSource, artifactFilter,artifactCollector);
// resolve all dependency files. if the dependency is a referenced project and not
// a file in the repository add its output directory to the classpath.
Iterator i = root.preorderIterator();
Set artifacts = new HashSet();
while (i.hasNext()) {
DependencyNode node = (DependencyNode)i.next();
// the dependency may not be included due to duplication
// dependency cycles and version conflict.
// don't include those in the classpath.
if (node.getState() != DependencyNode.INCLUDED) {
PluginLog.getLog().debug("Not including dependency: " + node);
continue;
}
Artifact artifact = node.getArtifact();
if (artifact.getFile() == null) {
try {
// if file is not found an exception is thrown
artifactResolver.resolve(artifact, remoteRepositories, localRepository);
}
catch (Exception e) {
if (includeProjects) {
// try to see if the dependency is a referenced project
Iterator projectsIterator = reactorProjects.iterator();
while (projectsIterator.hasNext()) {
MavenProject proj = (MavenProject)projectsIterator.next();
if (proj.getArtifactId().equals(artifact.getArtifactId())) {
artifact.setFile(new File(proj.getBuild().getOutputDirectory()));
break;
}
}
}
}
}
if (!scopes.contains(artifact.getScope())) {
if (artifact.getScope() != null) {
continue;
}
// if it's not the same project don't add
if (!includeProjects || !project.getArtifactId().equals(artifact.getArtifactId())) {
continue;
}
}
artifacts.add(artifact);
}
return getArtifactURLs(artifacts);
}