use of org.eclipse.aether.artifact.DefaultArtifact in project byte-buddy by raphw.
the class ClassLoaderResolverTest method setUp.
@Before
public void setUp() throws Exception {
classLoaderResolver = new ClassLoaderResolver(log, repositorySystem, repositorySystemSession, Collections.<RemoteRepository>emptyList());
when(repositorySystem.collectDependencies(eq(repositorySystemSession), any(CollectRequest.class))).thenReturn(new CollectResult(new CollectRequest()).setRoot(root));
when(child.getDependency()).thenReturn(new Dependency(new DefaultArtifact(FOO, BAR, QUX, BAZ, FOO + BAR, Collections.<String, String>emptyMap(), new File(FOO + "/" + BAR)), QUX + BAZ));
when(root.accept(any(DependencyVisitor.class))).then(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
DependencyVisitor dependencyVisitor = invocationOnMock.getArgumentAt(0, DependencyVisitor.class);
dependencyVisitor.visitEnter(child);
dependencyVisitor.visitLeave(child);
return null;
}
});
}
use of org.eclipse.aether.artifact.DefaultArtifact in project spring-boot by spring-projects.
the class DependencyResolutionContext method addDependencyManagement.
public void addDependencyManagement(DependencyManagement dependencyManagement) {
for (org.springframework.boot.cli.compiler.dependencies.Dependency dependency : dependencyManagement.getDependencies()) {
List<Exclusion> aetherExclusions = new ArrayList<>();
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);
}
use of org.eclipse.aether.artifact.DefaultArtifact in project bazel by bazelbuild.
the class ResultWriterTest method testBuildFile.
@Test
public void testBuildFile() throws Exception {
Rule rule = new Rule(new DefaultArtifact("x:y:1.2.3"));
Rule dep1 = new Rule(new DefaultArtifact("dep:dep1:4.5.6"));
rule.addDependency(dep1);
Rule dep2 = new Rule(new DefaultArtifact("dep:dep2:7.8.9"));
rule.addDependency(dep2);
Set<Rule> rules = ImmutableSet.of(rule, dep1, dep2);
String content = getBuildFileContent(ImmutableList.<String>of(), rules);
assertThat(content).contains("java_library(\n" + " name = \"x_y\",\n" + " visibility = [\"//visibility:public\"],\n" + " exports = [\n" + " \"@x_y//jar\",\n" + " \"@dep_dep1//jar\",\n" + " \"@dep_dep2//jar\",\n" + " ],\n" + ")");
}
use of org.eclipse.aether.artifact.DefaultArtifact in project bazel by bazelbuild.
the class ResultWriterTest method testParents.
@Test
public void testParents() throws Exception {
Rule rule = new Rule(new DefaultArtifact("x:y:1.2.3"));
rule.addParent("some parent");
Set<Rule> rules = ImmutableSet.of(rule);
String content = getWorkspaceFileContent(ImmutableList.<String>of(), rules);
assertThat(content).contains("# some parent\n" + "maven_jar(\n" + " name = \"x_y\",\n" + " artifact = \"x:y:1.2.3\",\n" + ")");
}
use of org.eclipse.aether.artifact.DefaultArtifact in project bazel by bazelbuild.
the class MavenDownloader method download.
/**
* Download the Maven artifact to the output directory. Returns the path to the jar.
*/
public Path download(String name, WorkspaceAttributeMapper mapper, Path outputDirectory, MavenServerValue serverValue) throws IOException, EvalException {
this.name = name;
this.outputDirectory = outputDirectory;
String url = serverValue.getUrl();
Server server = serverValue.getServer();
Artifact artifact;
String artifactId = mapper.get("artifact", Type.STRING);
String sha1 = mapper.isAttributeValueExplicitlySpecified("sha1") ? mapper.get("sha1", Type.STRING) : null;
if (sha1 != null && !KeyType.SHA1.isValid(sha1)) {
throw new IOException("Invalid SHA-1 for maven_jar " + name + ": '" + sha1 + "'");
}
try {
artifact = new DefaultArtifact(artifactId);
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage());
}
boolean isCaching = repositoryCache.isEnabled() && KeyType.SHA1.isValid(sha1);
if (isCaching) {
Path downloadPath = getDownloadDestination(artifact);
Path cachedDestination = repositoryCache.get(sha1, downloadPath, KeyType.SHA1);
if (cachedDestination != null) {
return cachedDestination;
}
}
MavenConnector connector = new MavenConnector(outputDirectory.getPathString());
RepositorySystem system = connector.newRepositorySystem();
RepositorySystemSession session = connector.newRepositorySystemSession(system);
RemoteRepository repository = new RemoteRepository.Builder(name, MavenServerValue.DEFAULT_ID, url).setAuthentication(new MavenAuthentication(server)).build();
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.setRepositories(ImmutableList.of(repository));
try {
ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
artifact = artifactResult.getArtifact();
} catch (ArtifactResolutionException e) {
throw new IOException("Failed to fetch Maven dependency: " + e.getMessage());
}
Path downloadPath = outputDirectory.getRelative(artifact.getFile().getAbsolutePath());
// Verify checksum.
if (!Strings.isNullOrEmpty(sha1)) {
RepositoryCache.assertFileChecksum(sha1, downloadPath, KeyType.SHA1);
}
if (isCaching) {
repositoryCache.put(sha1, downloadPath, KeyType.SHA1);
}
return downloadPath;
}
Aggregations