本文整理汇总了Java中org.eclipse.aether.util.artifact.JavaScopes类的典型用法代码示例。如果您正苦于以下问题:Java JavaScopes类的具体用法?Java JavaScopes怎么用?Java JavaScopes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaScopes类属于org.eclipse.aether.util.artifact包,在下文中一共展示了JavaScopes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveArtifacts
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
private Stream<? extends Artifact> resolveArtifacts(String coordinator) {
log.debug("resolving {}", coordinator);
try {
// build resolve filters
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(new DefaultArtifact(coordinator), JavaScopes.COMPILE));
DependencyRequest dependencyRequest = new DependencyRequest(
collectRequest,
DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME)
);
// resolve
final List<Artifact> artifacts = teslaAether.resolveArtifacts(dependencyRequest);
if (CollectionUtils.isEmpty(artifacts)) {
throw new DependencyResolveException(String.format("cannot resolve %s", coordinator));
}
return artifacts.stream();
} catch (DependencyResolutionException e) {
final String message = String.format("cannot resolve %s : %s", coordinator, e.getLocalizedMessage());
throw new DependencyResolveException(message, e);
}
}
示例2: fillfromExtraDependencies
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
protected void fillfromExtraDependencies(final Manifest manifest, final Map<String, File> files)
throws IOException, MojoExecutionException {
if (this.additionalDependencies != null) {
try {
final Collection<ArtifactRequest> requests = new ArrayList<>(this.additionalDependencies.length);
for (final Dependency dep : this.additionalDependencies) {
final DefaultArtifact art = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(),
dep.getClassifier(), dep.getType(), dep.getVersion());
final org.eclipse.aether.graph.Dependency adep = new org.eclipse.aether.graph.Dependency(art,
JavaScopes.RUNTIME);
requests.add(new ArtifactRequest(new DefaultDependencyNode(adep)));
}
final List<ArtifactResult> result = this.resolver.resolveArtifacts(this.repositorySession, requests);
for (final ArtifactResult ares : result) {
getLog().debug("Additional dependency: " + ares);
processArtifact(manifest, files, ares.getArtifact().getFile());
}
} catch (final ArtifactResolutionException e) {
throw new MojoExecutionException("Failed to resolve additional dependencies", e);
}
}
}
示例3: collectDependencyArtifacts
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
private List<Artifact> collectDependencyArtifacts(List<Dependency> dependencies)
throws RepositoryException {
CollectRequest collectRequest = new CollectRequest();
collectRequest.setDependencies(dependencies);
DependencyNode node = repositorySystem
.collectDependencies(repositorySystemSession, collectRequest)
.getRoot();
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setRoot(node);
// setFilter() allows null arguments.
dependencyRequest.setFilter(
AndDependencyFilter.newInstance(
new ScopeDependencyFilter(Arrays.asList(JavaScopes.COMPILE, JavaScopes.RUNTIME), null),
CloudKeeperBundleFilter.INSTANCE
)
);
repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
PreorderNodeListGenerator nodeListGenerator = new PreorderNodeListGenerator();
node.accept(nodeListGenerator);
return nodeListGenerator.getArtifacts(false);
}
示例4: AbstractProjectStub
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
AbstractProjectStub(String pomResourceName) throws IOException, XmlPullParserException {
super(new MavenXpp3Reader().read(ITCompileBundleMojo.class.getResourceAsStream(pomResourceName)));
Model model = getModel();
setGroupId(model.getGroupId());
setArtifactId(model.getArtifactId());
setVersion(model.getVersion());
setName(model.getName());
setUrl(model.getUrl());
setPackaging(model.getPackaging());
SimpleArtifactStub artifact = new SimpleArtifactStub(
model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging());
artifact.setArtifactHandler(new SimpleArtifactHandlerStub(model.getPackaging()));
setArtifact(artifact);
Build build = new Build();
build.setFinalName(model.getArtifactId() + '-' + model.getVersion());
setBuild(build);
for (Dependency dependency: model.getDependencies()) {
if (dependency.getScope() == null) {
dependency.setScope(JavaScopes.COMPILE);
}
}
}
示例5: addDependencyManagement
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
public void addDependencyManagement(DependencyManagement dependencyManagement) {
for (org.springframework.boot.cli.compiler.dependencies.Dependency dependency : dependencyManagement
.getDependencies()) {
List<Exclusion> aetherExclusions = new ArrayList<Exclusion>();
for (org.springframework.boot.cli.compiler.dependencies.Dependency.Exclusion exclusion : dependency
.getExclusions()) {
aetherExclusions.add(new Exclusion(exclusion.getGroupId(),
exclusion.getArtifactId(), "*", "*"));
}
Dependency aetherDependency = new Dependency(
new DefaultArtifact(dependency.getGroupId(),
dependency.getArtifactId(), "jar", dependency.getVersion()),
JavaScopes.COMPILE, false, aetherExclusions);
this.managedDependencies.add(0, aetherDependency);
this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency),
aetherDependency);
}
this.dependencyManagement = this.dependencyManagement == null
? dependencyManagement
: new CompositeDependencyManagement(dependencyManagement,
this.dependencyManagement);
this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(
this.dependencyManagement);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:DependencyResolutionContext.java
示例6: exportDependencies
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
protected void exportDependencies() throws MojoExecutionException{
getLog().debug("Exporting deps ");
addLanguageDeps();
for (Artifact pomDependency : project.getDependencyArtifacts()) {
getLog().debug("Exporting "+pomDependency);
// skip test deps unless we're dealing with tests
if(pomDependency.getScope().equals(JavaScopes.TEST)
&& !isTest()){
continue;
}
getLog().debug("Exporting type "+pomDependency.getType());
// skip non-jars
if(!pomDependency.getType().equals("jar") || pomDependency.getFile() == null)
continue;
addDep(pomDependency.getGroupId(), pomDependency.getArtifactId(), pomDependency.getClassifier(), pomDependency.getVersion());
}
}
示例7: resolveDependencies
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
private List<Artifact> resolveDependencies(final Artifact artifact) throws DependencyResolutionException {
List<Artifact> result = new ArrayList<Artifact>();
RepositorySystem system = newRepositorySystem();
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new org.eclipse.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
List<ArtifactResult> dependenciesTree = system.resolveDependencies(
session,
new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE))
).getArtifactResults();
for (final ArtifactResult res : dependenciesTree) {
result.add(res.getArtifact());
}
return result;
}
示例8: getDependencies
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
public List<Artifact> getDependencies(String groupId, String artifactId, String extension, String version) throws Exception {
Artifact artifact = new DefaultArtifact(groupId, artifactId, extension, version);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency( artifact, ""));
collectRequest.setRepositories(Collections.emptyList());
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE));
DependencyResult dependencyResult = system.resolveDependencies(session, dependencyRequest);
List<Artifact> dependencies = new ArrayList<>();
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
if (!artifactResult.isResolved()) {
throw new Exception("Could not resolve artifact " + artifactResult.getRequest().getArtifact());
}
dependencies.add(artifactResult.getArtifact());
}
return dependencies;
}
示例9: resolveArtifactsAndDependencies
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
public List<File> resolveArtifactsAndDependencies(List<Artifact> artifacts) throws ArtifactResolutionException, DependencyResolutionException {
List<Dependency> dependencies = new ArrayList<Dependency>();
for (Artifact artifact : artifacts) {
dependencies.add(new Dependency(artifact, JavaScopes.RUNTIME));
}
CollectRequest collectRequest = new CollectRequest((Dependency)null, dependencies, repositories);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter);
DependencyResult result = system.resolveDependencies(session, dependencyRequest);
List<File> files = new ArrayList<File>();
for (ArtifactResult artifactResult : result.getArtifactResults()) {
files.add(artifactResult.getArtifact().getFile());
}
return files;
}
示例10: getRunTimeTransitiveDeps
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
private ImmutableMap<String, Artifact> getRunTimeTransitiveDeps(Iterable<Dependency> mavenCoords)
throws RepositoryException {
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRequestContext(JavaScopes.RUNTIME);
collectRequest.setRepositories(repos);
for (Dependency dep : mavenCoords) {
collectRequest.addDependency(dep);
}
DependencyFilter filter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, filter);
DependencyResult dependencyResult = repoSys.resolveDependencies(session, dependencyRequest);
ImmutableSortedMap.Builder<String, Artifact> knownDeps = ImmutableSortedMap.naturalOrder();
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
Artifact node = artifactResult.getArtifact();
knownDeps.put(buildKey(node), node);
}
return knownDeps.build();
}
示例11: downloadDependencyTree
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
* Resolves and downloads an artifact with its dependencies.
*
* @param artifact
* artifact to resolve
* @param javadoc
* <code>true</code> if javadoc attachment should be retrieved too
* @param sources
* <code>true</code> if sources attachment should be retrieved too
* @throws DependencyCollectionException
* if the dependency graph could not be properly assembled
* @throws DependencyResolutionException
* if a dependency is not resolvable
*/
public void downloadDependencyTree(DefaultArtifact artifact, boolean javadoc, boolean sources)
throws DependencyCollectionException, DependencyResolutionException {
log.info("Resolving: {} with these dependencies ...", artifact.toString());
Dependency dependency = new Dependency(artifact, JavaScopes.COMPILE);
DependencyNode jarNode = repoSystemHelper.collectDependencies(dependency);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.TEST);
jarNode.accept(new TreeDependencyVisitor(new FilteringDependencyVisitor(new DependencyGraphPrinter(), classpathFilter)));
DependencyRequest dependencyRequest = new DependencyRequest(jarNode, classpathFilter);
DependencyResult dependencyResult = repoSystemHelper.resolveDependencies(dependencyRequest);
if (javadoc) {
downloadAttachments(dependencyResult, "javadoc");
}
if (sources) {
downloadAttachments(dependencyResult, "sources");
}
}
示例12: downloadAttachments
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
* Downloads additional artifacts like javadoc or sources.
*
* @param depResult
* a set of resolved dependencies
* @param attachment
* type of attachment. Either "javadoc" or "sources"
* @throws DependencyCollectionException
*/
private void downloadAttachments(DependencyResult depResult, final String attachment) throws DependencyCollectionException {
for (ArtifactResult artifactResult : depResult.getArtifactResults()) {
final Artifact artifact = artifactResult.getArtifact();
final String artifactId = artifact.getArtifactId();
final String groupId = artifact.getGroupId();
final String extension = artifact.getExtension();
final String version = artifact.getVersion();
log.info("Resolving {} for {}", attachment, artifact);
try {
DefaultArtifact extraArtifact = new DefaultArtifact(groupId, artifactId, attachment, extension, version);
Dependency attachedDependency = new Dependency(extraArtifact, JavaScopes.COMPILE);
DependencyNode attachmentNode = repoSystemHelper.collectDependencies(attachedDependency);
DependencyRequest javadocDependencyRequest = new DependencyRequest(attachmentNode, null);
repoSystemHelper.resolveDependencies(javadocDependencyRequest);
} catch (DependencyResolutionException de) {
log.warn("No {} found for {}", attachment, artifact);
}
}
}
示例13: newSession
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
* Set up repository session for maven.
*
* @param system
* the repository system
* @param localDownloadDir
* the directory where to put the downloaded artifacts
* @return the configured repository session
*/
private RepositorySystemSession newSession(RepositorySystem system, final String localDownloadDir) {
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepo = new LocalRepository(localDownloadDir);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
DependencySelector depFilter =
new AndDependencySelector(
new ScopeDependencySelector(JavaScopes.PROVIDED),
new OptionalDependencySelector(),
new ExclusionDependencySelector()
);
session.setDependencySelector(depFilter);
return session;
}
示例14: validateBomDependency
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
private void validateBomDependency(ValidatorContext ctx, Model bom, Dependency bomDependency, Dependency dependency) {
CollectRequest collectRequest = new CollectRequest(
bomDependency,
Collections.singletonList(dependency),
ctx.getRemoteRepositories());
DependencyRequest dependencyRequest = new DependencyRequest(
collectRequest,
DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE));
try {
repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
} catch (DependencyResolutionException e) {
ArtifactResolutionException are = findCause(e, ArtifactResolutionException.class);
if( are == null ) {
ctx.addError(this, bom.getPomFile(), e);
} else {
DependencyNode dependencyNode = e.getResult().getRoot();
Artifact validatedArtifact = new DefaultArtifact(bom.getGroupId(), bom.getArtifactId(), bom.getPackaging(), bom.getVersion());
for (Artifact missingArtifact : Utils.collectMissingArtifacts(are)) {
ctx.addError(this, bom.getPomFile(), new BomDependencyNotFoundException(e, missingArtifact, validatedArtifact, dependencyNode));
}
}
}
}
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:26,代码来源:BomDependencyNotFoundValidator.java
示例15: fetch
import org.eclipse.aether.util.artifact.JavaScopes; //导入依赖的package包/类
private Page<Artifact, Artifact> fetch(Artifact artifact)
throws SettingsBuildingException, DependencyResolutionException, DependencyCollectionException {
ScopeDependencySelector dependencySelector = new ScopeDependencySelector(
Collections.singleton(JavaScopes.COMPILE), Collections.emptySet());
Dependency task = new Dependency(new Maven());
Processor processor = new Processor(task, true, true, JavaScopes.COMPILE, dependencySelector, false);
return processor.process(artifact);
}