use of org.eclipse.aether.artifact.DefaultArtifact in project bazel by bazelbuild.
the class ResultWriterTest method testArtifacts.
@Test
public void testArtifacts() throws Exception {
Set<Rule> rules = ImmutableSet.of(new Rule(new DefaultArtifact("x:y:1.2.3")));
String content = getWorkspaceFileContent(ImmutableList.<String>of(), rules);
assertThat(content).contains("maven_jar(\n" + " name = \"x_y\",\n" + " artifact = \"x:y:1.2.3\",\n" + ")");
}
use of org.eclipse.aether.artifact.DefaultArtifact in project buck by facebook.
the class ResolverIntegrationTest method shouldDetectNewestJar.
@Test
public void shouldDetectNewestJar() throws Exception {
Path groupDir = thirdParty.resolve("example");
Path existingNewerJar = groupDir.resolve("no-deps-1.1.jar");
Path existingNewestJar = groupDir.resolve("no-deps-1.2.jar");
Files.createDirectories(groupDir);
Path sourceJar = repo.resolve("com/example/no-deps/1.0/no-deps-1.0.jar");
Files.copy(sourceJar, existingNewerJar);
Files.copy(sourceJar, existingNewestJar);
Artifact artifact = new DefaultArtifact("com.example", "no-deps", "jar", "1.0");
Optional<Path> result = new Resolver(newConfig()).getNewerVersionFile(artifact, groupDir);
assertTrue(result.isPresent());
assertThat(result.get(), equalTo(existingNewestJar));
}
use of org.eclipse.aether.artifact.DefaultArtifact in project buck by facebook.
the class Publisher method publish.
public ImmutableSet<DeployResult> publish(SourcePathResolver pathResolver, ImmutableSet<MavenPublishable> publishables) throws DeploymentException {
ImmutableListMultimap<UnflavoredBuildTarget, UnflavoredBuildTarget> duplicateBuiltinBuileRules = checkForDuplicatePackagedDeps(publishables);
if (duplicateBuiltinBuileRules.size() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("Duplicate transitive dependencies for publishable libraries found! This means");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("that the following libraries would have multiple copies if these libraries were");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("used together. The can be resolved by adding a maven URL to each target listed");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("below:");
for (UnflavoredBuildTarget unflavoredBuildTarget : duplicateBuiltinBuileRules.keySet()) {
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append(unflavoredBuildTarget.getFullyQualifiedName());
sb.append(" (referenced by these build targets: ");
Joiner.on(", ").appendTo(sb, duplicateBuiltinBuileRules.get(unflavoredBuildTarget));
sb.append(")");
}
throw new DeploymentException(sb.toString());
}
ImmutableSet.Builder<DeployResult> deployResultBuilder = ImmutableSet.builder();
for (MavenPublishable publishable : publishables) {
DefaultArtifact coords = new DefaultArtifact(Preconditions.checkNotNull(publishable.getMavenCoords().get(), "No maven coordinates specified for published rule ", publishable));
Path relativePathToOutput = pathResolver.getRelativePath(Preconditions.checkNotNull(publishable.getSourcePathToOutput(), "No path to output present in ", publishable));
File mainItem = publishable.getProjectFilesystem().resolve(relativePathToOutput).toFile();
if (!coords.getClassifier().isEmpty()) {
deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem)));
}
try {
// If this is the "main" artifact (denoted by lack of classifier) generate and publish
// pom alongside
File pom = Pom.generatePomFile(pathResolver, publishable).toFile();
deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem, pom)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return deployResultBuilder.build();
}
use of org.eclipse.aether.artifact.DefaultArtifact in project buck by facebook.
the class Pom method applyBuildRule.
private void applyBuildRule() {
if (!HasMavenCoordinates.isMavenCoordsPresent(publishable)) {
throw new IllegalArgumentException("Cannot retrieve maven coordinates for target" + publishable.getBuildTarget().getFullyQualifiedName());
}
DefaultArtifact artifact = new DefaultArtifact(getMavenCoords(publishable).get());
Iterable<Artifact> deps = FluentIterable.from(publishable.getMavenDeps()).filter(HasMavenCoordinates::isMavenCoordsPresent).transform(input -> new DefaultArtifact(input.getMavenCoords().get()));
updateModel(artifact, deps);
}
use of org.eclipse.aether.artifact.DefaultArtifact in project camel by apache.
the class BOMResolver method retrieveUpstreamBOMVersions.
private void retrieveUpstreamBOMVersions() throws Exception {
RepositorySystem system = newRepositorySystem();
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepo = new LocalRepository(LOCAL_REPO);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
String camelVersion = DependencyResolver.resolveCamelParentProperty("${project.version}");
List<Artifact> neededArtifacts = new LinkedList<>();
neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel:pom:" + camelVersion).setFile(camelRoot("pom.xml")));
neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-parent:pom:" + camelVersion).setFile(camelRoot("parent/pom.xml")));
neededArtifacts.add(new DefaultArtifact("org.apache.camel:spring-boot:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/pom.xml")));
neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-spring-boot-dm:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/pom.xml")));
neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-spring-boot-dependencies:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml")));
Artifact camelSpringBootParent = new DefaultArtifact("org.apache.camel:camel-starter-parent:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/camel-starter-parent/pom.xml"));
neededArtifacts.add(camelSpringBootParent);
RemoteRepository localRepoDist = new RemoteRepository.Builder("org.apache.camel.itest.springboot", "default", new File(LOCAL_REPO).toURI().toString()).build();
for (Artifact artifact : neededArtifacts) {
DeployRequest deployRequest = new DeployRequest();
deployRequest.addArtifact(artifact);
deployRequest.setRepository(localRepoDist);
system.deploy(session, deployRequest);
}
RemoteRepository mavenCentral = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
ArtifactDescriptorRequest dReq = new ArtifactDescriptorRequest(camelSpringBootParent, Arrays.asList(localRepoDist, mavenCentral), null);
ArtifactDescriptorResult dRes = system.readArtifactDescriptor(session, dReq);
this.versions = new TreeMap<>();
for (Dependency dependency : dRes.getManagedDependencies()) {
Artifact a = dependency.getArtifact();
String key = a.getGroupId() + ":" + a.getArtifactId();
versions.put(key, dependency.getArtifact().getVersion());
}
}
Aggregations