Search in sources :

Example 11 with ArtifactCoordinates

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);
}
Also used : ArtifactCoordinates(org.jboss.modules.maven.ArtifactCoordinates) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 12 with ArtifactCoordinates

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);
}
Also used : Path(java.nio.file.Path) ArtifactCoordinates(org.jboss.modules.maven.ArtifactCoordinates) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) Test(org.junit.Test)

Example 13 with ArtifactCoordinates

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;
}
Also used : ArtifactCoordinates(org.jboss.modules.maven.ArtifactCoordinates) IOException(java.io.IOException) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

ArtifactCoordinates (org.jboss.modules.maven.ArtifactCoordinates)13 Test (org.junit.Test)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 File (java.io.File)7 Path (java.nio.file.Path)5 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 JarFile (java.util.jar.JarFile)1 NativeLibraryResourceLoader (org.jboss.modules.NativeLibraryResourceLoader)1 ResourceLoader (org.jboss.modules.ResourceLoader)1 MultiplePathFilterBuilder (org.jboss.modules.filter.MultiplePathFilterBuilder)1