use of org.jboss.modules.maven.ArtifactCoordinates in project wildfly-swarm by wildfly-swarm.
the class GradleResolverTest method testToGradleArtifactPath.
@Test
public void testToGradleArtifactPath() {
// GIVEN
String group = "org.jboss.ws.cxf";
String artifact = "jbossws-cxf-resources";
String version = "5.1.5.Final";
ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version);
// WHEN
GradleResolver resolver = new GradleResolver(null);
String artifactPath = resolver.toGradleArtifactPath(artifactCoordinates);
// THEN
assertEquals("org/jboss/ws/cxf/jbossws-cxf-resources/5.1.5.Final/jbossws-cxf-resources-5.1.5.Final", artifactPath);
}
use of org.jboss.modules.maven.ArtifactCoordinates in project wildfly-swarm by wildfly-swarm.
the class GradleResolverTest method testResolveArtifact.
@Test
public void testResolveArtifact() throws IOException {
// GIVEN
File dirFile = TempFileManager.INSTANCE.newTempDirectory("gradle", null);
Path gradleCachePath = dirFile.toPath();
String group = "org.wildfly.swarm";
String packaging = "jar";
String artifact = "test";
String version = "1.0";
String classifier = "sources";
ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version, classifier);
Path artifactDir = Files.createDirectories(gradleCachePath.resolve(group).resolve(artifact).resolve(version).resolve("hash"));
File artifactFile = Files.createFile(artifactDir.resolve(artifact + "-" + version + "-" + classifier + "." + packaging)).toFile();
// WHEN
GradleResolver resolver = new GradleResolver(gradleCachePath.toString());
File resolvedArtifactFile = resolver.resolveArtifact(artifactCoordinates, packaging);
// THEN
assertEquals(artifactFile, resolvedArtifactFile);
}
use of org.jboss.modules.maven.ArtifactCoordinates in project wildfly-swarm by wildfly-swarm.
the class MavenDependencyResolution method resolve.
@Override
public Set<String> resolve(List<String> exclusions) throws IOException {
final Set<String> archivePaths = new HashSet<>();
ApplicationEnvironment env = ApplicationEnvironment.get();
env.getDependencies().forEach(dep -> {
String[] parts = dep.split(":");
ArtifactCoordinates coords = null;
if (parts.length == 4) {
coords = new ArtifactCoordinates(parts[0], parts[1], parts[3]);
} else if (parts.length == 5) {
coords = new ArtifactCoordinates(parts[0], parts[1], parts[3], parts[4]);
}
try {
final File artifact = MavenResolvers.get().resolveJarArtifact(coords);
if (artifact == null) {
LOGGER.error("Unable to resolve artifact: " + coords);
} else {
archivePaths.add(artifact.getAbsolutePath());
}
} catch (IOException e) {
LOGGER.error("Error resolving artifact " + coords, e);
}
});
return archivePaths;
}
Aggregations