org.jboss.modules.maven.ArtifactCoordinates Java Examples

The following examples show how to use org.jboss.modules.maven.ArtifactCoordinates. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GradleResolver.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Override
public File resolveArtifact(ArtifactCoordinates artifactCoordinates, String packaging) throws IOException {
    //Search the matching artifact in a gradle cache.
    String filter = toGradleArtifactFileName(artifactCoordinates, packaging);
    Path artifactDirectory = Paths.get(gradleCachePath, artifactCoordinates.getGroupId(), artifactCoordinates.getArtifactId(), artifactCoordinates.getVersion());
    if (Files.exists(artifactDirectory)) {
        File latestArtifactFile = null;
        for (Path hashDir : Files.list(artifactDirectory).collect(Collectors.toList())) {
            for (Path artifact : Files.list(hashDir).collect(Collectors.toList())) {
                if (artifact.endsWith(filter)) {
                    File artifactFile = artifact.toFile();
                    if (latestArtifactFile == null || latestArtifactFile.lastModified() < artifactFile.lastModified()) {
                        //take always the latest version of the artifact
                        latestArtifactFile = artifactFile;
                    }
                }
            }
        }
        if (latestArtifactFile != null) {
            return latestArtifactFile;
        }
    }

    //Artifact not found in the locale gradle cache. Try to resolve it from the remote respository
    return downloadFromRemoteRepository(artifactCoordinates, packaging, artifactDirectory);
}
 
Example #2
Source File: UberJarMavenResolver.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@Override
public File resolveArtifact(ArtifactCoordinates coordinates, String packaging) throws IOException {

    String artifactRelativePath = "m2repo/" + relativeArtifactPath('/', coordinates.getGroupId(), coordinates.getArtifactId(), coordinates.getVersion());
    String classifier = "";
    if (coordinates.getClassifier() != null && !coordinates.getClassifier().trim().isEmpty()) {
        classifier = "-" + coordinates.getClassifier();
    }

    String jarPath = artifactRelativePath + classifier + "." + packaging;

    InputStream stream = UberJarMavenResolver.class.getClassLoader().getResourceAsStream(jarPath);

    if (stream != null) {
        return copyTempJar(coordinates.getArtifactId() + "-" + coordinates.getVersion(), stream, packaging);
    }

    return null;
}
 
Example #3
Source File: DependencyTreeTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testTransitiveDepsOrder() {
    ArtifactCoordinates parent = ArtifactCoordinates.fromString("g:a:v");
    tree.add(parent, ArtifactCoordinates.fromString("g:a:2.0"));
    tree.add(parent, ArtifactCoordinates.fromString("g:a:1.0"));
    tree.add(parent, ArtifactCoordinates.fromString("g:a:3.0"));
    tree.add(parent, ArtifactCoordinates.fromString("g:a:4.0"));
    tree.add(parent, ArtifactCoordinates.fromString("g:a:5.0"));
    tree.add(parent, ArtifactCoordinates.fromString("g:a:6.0"));
    tree.add(parent, ArtifactCoordinates.fromString("g:a:7.0"));
    tree.add(parent, ArtifactCoordinates.fromString("g:a:1.5"));

    Collection<ArtifactCoordinates> transientDeps = tree.getTransientDeps(parent);
    Iterator<ArtifactCoordinates> iterator = transientDeps.iterator();

    Assert.assertEquals("2.0", iterator.next().getVersion());
    Assert.assertEquals("1.0", iterator.next().getVersion());
    Assert.assertEquals("3.0", iterator.next().getVersion());
    Assert.assertEquals("4.0", iterator.next().getVersion());
    Assert.assertEquals("5.0", iterator.next().getVersion());
    Assert.assertEquals("6.0", iterator.next().getVersion());
    Assert.assertEquals("7.0", iterator.next().getVersion());
    Assert.assertEquals("1.5", iterator.next().getVersion());
}
 
Example #4
Source File: DependencyTreeTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testDirectDepsOrder() {
    tree.add(ArtifactCoordinates.fromString("g:a:2.0"));
    tree.add(ArtifactCoordinates.fromString("g:a:1.0"));
    tree.add(ArtifactCoordinates.fromString("g:a:3.0"));
    tree.add(ArtifactCoordinates.fromString("g:a:4.0"));
    tree.add(ArtifactCoordinates.fromString("g:a:5.0"));
    tree.add(ArtifactCoordinates.fromString("g:a:6.0"));
    tree.add(ArtifactCoordinates.fromString("g:a:7.0"));
    tree.add(ArtifactCoordinates.fromString("g:a:1.5"));

    Collection<ArtifactCoordinates> directDeps = tree.getDirectDeps();
    Iterator<ArtifactCoordinates> iterator = directDeps.iterator();

    Assert.assertEquals("2.0", iterator.next().getVersion());
    Assert.assertEquals("1.0", iterator.next().getVersion());
    Assert.assertEquals("3.0", iterator.next().getVersion());
    Assert.assertEquals("4.0", iterator.next().getVersion());
    Assert.assertEquals("5.0", iterator.next().getVersion());
    Assert.assertEquals("6.0", iterator.next().getVersion());
    Assert.assertEquals("7.0", iterator.next().getVersion());
    Assert.assertEquals("1.5", iterator.next().getVersion());
}
 
Example #5
Source File: GradleResolverTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testResolveArtifact_notExists() 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 + ".pom")).toFile(); // Other packaging type

    //WHEN
    GradleResolver resolver = new GradleResolver(gradleCachePath.toString());
    File resolvedArtifactFile = resolver.resolveArtifact(artifactCoordinates, packaging);

    //THEN
    assertNull(resolvedArtifactFile);
}
 
Example #6
Source File: GradleResolverTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testResolveArtifact_latest() throws IOException, InterruptedException {
    //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("hash1"));
    File artifactFile = Files.createFile(artifactDir.resolve(artifact + "-" + version + "-" + classifier + "." + packaging)).toFile();
    Thread.sleep(2000); //Timestemp resolution of some filesystems are 2 seconds
    Path artifactDirLatest = Files.createDirectories(gradleCachePath.resolve(group).resolve(artifact).resolve(version).resolve("hash2"));
    File artifactFileLatest = Files.createFile(artifactDirLatest.resolve(artifact + "-" + version + "-" + classifier + "." + packaging)).toFile();

    //WHEN
    GradleResolver resolver = new GradleResolver(gradleCachePath.toString());
    File resolvedArtifactFile = resolver.resolveArtifact(artifactCoordinates, packaging);

    //THEN
    assertEquals(artifactFileLatest, resolvedArtifactFile);
}
 
Example #7
Source File: GradleResolverTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #8
Source File: GradleResolverTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testToGradleArtifactPath_withClassifier(){
    //GIVEN
    String group = "org.jboss.ws.cxf";
    String artifact = "jbossws-cxf-resources";
    String version = "5.1.5.Final";
    String classifier = "wildfly1000";
    ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version, classifier);

    //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-wildfly1000",
            artifactPath);
}
 
Example #9
Source File: GradleResolverTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #10
Source File: GradleResolverTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testToGradleArtifactFileName_withClassifier(){
    //GIVEN
    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);

    //WHEN
    GradleResolver resolver = new GradleResolver(null);
    String artifactFileName = resolver.toGradleArtifactFileName(artifactCoordinates, packaging);

    //THEN
    assertEquals(artifact + "-" + version + "-"+ classifier + "." + packaging, artifactFileName);
}
 
Example #11
Source File: GradleResolverTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void testToGradleArtifactFileName(){
    //GIVEN
    String group = "org.wildfly.swarm";
    String packaging = "jar";
    String artifact = "test";
    String version = "1.0";
    ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version);

    //WHEN
    GradleResolver resolver = new GradleResolver(null);
    String artifactFileName = resolver.toGradleArtifactFileName(artifactCoordinates, packaging);

    //THEN
    assertEquals(artifact + "-" + version + "." + packaging, artifactFileName);
}
 
Example #12
Source File: GradleResolverTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void downloadFromRemoteRepository_unknown() 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 = "2017.1.1";
    ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version);

    Path artifactDirectory = gradleCachePath.resolve(group);
    GradleResolver resolver = spy(new GradleResolver(gradleCachePath.toString()));
    doReturn(null).when(resolver).doDownload(anyString(), anyString(), anyString(), eq(artifactCoordinates), eq(packaging), any(File.class), any(File.class));

    //WHEN
    File result = resolver.downloadFromRemoteRepository(artifactCoordinates, packaging, artifactDirectory);

    //THEN
    assertNull(result);
}
 
Example #13
Source File: GradleResolverTest.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Test
public void downloadFromRemoteRepository() throws IOException {
    //GIVEN
    File dirFile = TempFileManager.INSTANCE.newTempDirectory(".gradle", null);
    Path gradleCachePath = dirFile.toPath();
    String group = "org.wildfly.swarm";
    String packaging = "jar";
    String artifact = "bootstrap";
    String version = "2017.1.1";
    ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version);

    Path artifactDirectory = gradleCachePath.resolve(group);
    GradleResolver resolver = spy(new GradleResolver(gradleCachePath.toString()));
    File targetFile = mock(File.class);
    doReturn(targetFile).when(resolver).doDownload(anyString(), anyString(), anyString(), eq(artifactCoordinates), eq(packaging), any(File.class), any(File.class));

    //WHEN
    File result = resolver.downloadFromRemoteRepository(artifactCoordinates, packaging, artifactDirectory);

    //THEN
    assertEquals(targetFile, result);
}
 
Example #14
Source File: MultiMavenResolver.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Override
public File resolveArtifact(ArtifactCoordinates coordinates, String packaging) throws IOException {

    try (AutoCloseable handle = Performance.accumulate("artifact-resolver")) {
        for (MavenResolver resolver : this.resolvers) {
            File result = resolver.resolveArtifact(coordinates, packaging);
            if (result != null) {
                return result;
            }
        }

        return null;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #15
Source File: GradleResolver.java    From thorntail with Apache License 2.0 6 votes vote down vote up
/**
 * Build file name for artifact.
 *
 * @param artifactCoordinates
 * @param packaging
 * @return
 */
String toGradleArtifactFileName(ArtifactCoordinates artifactCoordinates, String packaging) {
    StringBuilder sbFileFilter = new StringBuilder();
    sbFileFilter
            .append(artifactCoordinates.getArtifactId())
            .append("-")
            .append(artifactCoordinates.getVersion());
    if (artifactCoordinates.getClassifier() != null && artifactCoordinates.getClassifier().length() > 0) {
        sbFileFilter
                .append("-")
                .append(artifactCoordinates.getClassifier());
    }
    sbFileFilter
            .append(".")
            .append(packaging);
    return sbFileFilter.toString();
}
 
Example #16
Source File: MavenArtifactDescriptor.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public ArtifactCoordinates mscCoordinates() {
    return new ArtifactCoordinates(this.groupId,
                                   this.artifactId,
                                   this.version,
                                   this.classifier == null ? "" : this.classifier);

}
 
Example #17
Source File: UberJarMavenResolver.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public File resolveArtifact(ArtifactCoordinates coordinates, String packaging) throws IOException {

    File resolved = this.resolutionCache.get(coordinates);
    if (resolved == null) {

        String artifactRelativePath = "m2repo/" + relativeArtifactPath('/', coordinates.getGroupId(), coordinates.getArtifactId(), coordinates.getVersion());
        String classifier = "";
        if (coordinates.getClassifier() != null && !coordinates.getClassifier().trim().isEmpty()) {
            classifier = HYPHEN + coordinates.getClassifier();
        }

        String jarPath = artifactRelativePath + classifier + DOT + packaging;

        InputStream stream = UberJarMavenResolver.class.getClassLoader().getResourceAsStream(jarPath);

        if (stream != null) {
            try {
                resolved = copyTempJar(coordinates.getArtifactId() + HYPHEN + coordinates.getVersion(), stream, packaging);
                this.resolutionCache.put(coordinates, resolved);
            } finally {
                stream.close();
            }
        }
    }

    return resolved;
}
 
Example #18
Source File: GradleResolver.java    From thorntail with Apache License 2.0 5 votes vote down vote up
/**
 * Build the artifact path including the classifier.
 *
 * @param artifactCoordinates
 * @return
 */
String toGradleArtifactPath(ArtifactCoordinates artifactCoordinates) {
    // e.g.: org/jboss/ws/cxf/jbossws-cxf-resources/5.1.5.Final/jbossws-cxf-resources-5.1.5.Final
    String pathWithMissingClassifier = artifactCoordinates.relativeArtifactPath('/');
    StringBuilder sb = new StringBuilder(pathWithMissingClassifier);

    if (artifactCoordinates.getClassifier() != null && artifactCoordinates.getClassifier().length() > 0) {
        // org/jboss/ws/cxf/jbossws-cxf-resources/5.1.5.Final/jbossws-cxf-resources-5.1.5.Final-wildfly1000
        sb
                .append("-")
                .append(artifactCoordinates.getClassifier());
    }

    return sb.toString();
}
 
Example #19
Source File: GradleResolver.java    From thorntail with Apache License 2.0 5 votes vote down vote up
/**
 * Download artifact from remote repository.
 *
 * @param artifactCoordinates
 * @param packaging
 * @param artifactDirectory
 * @return
 */
File downloadFromRemoteRepository(ArtifactCoordinates artifactCoordinates, String packaging, Path artifactDirectory) {
    String artifactRelativeHttpPath = toGradleArtifactPath(artifactCoordinates);
    String artifactRelativeMetadataHttpPath = artifactCoordinates.relativeMetadataPath('/');
    for (String remoteRepos : remoteRepositories) {
        String artifactAbsoluteHttpPath = remoteRepos + artifactRelativeHttpPath + ".";
        File targetArtifactPomDirectory = artifactDirectory.resolve(computeGradleUUID(artifactCoordinates + ":pom")).toFile();
        File targetArtifactDirectory = artifactDirectory.resolve(computeGradleUUID(artifactCoordinates + ":" + packaging)).toFile();

        File artifactFile = doDownload(remoteRepos, artifactAbsoluteHttpPath, artifactRelativeHttpPath, artifactCoordinates, packaging, targetArtifactPomDirectory, targetArtifactDirectory);
        if (artifactFile != null) {
            return artifactFile; // Success
        }

        //Try to doDownload the snapshot version
        if (artifactCoordinates.isSnapshot()) {
            String remoteMetadataPath = remoteRepos + artifactRelativeMetadataHttpPath;
            try {
                String timestamp = MavenArtifactUtil.downloadTimestampVersion(artifactCoordinates + ":" + packaging, remoteMetadataPath);

                String timestampedArtifactRelativePath = artifactCoordinates.relativeArtifactPath('/', timestamp);
                String artifactTimestampedAbsoluteHttpPath = remoteRepos + timestampedArtifactRelativePath + ".";
                File targetTimestampedArtifactPomDirectory = artifactDirectory.resolve(computeGradleUUID(artifactCoordinates + ":" + timestamp + ":pom")).toFile();
                File targetTimestampedArtifactDirectory = artifactDirectory.resolve(computeGradleUUID(artifactCoordinates + ":" + packaging)).toFile();

                File snapshotArtifactFile = doDownload(remoteRepos, artifactTimestampedAbsoluteHttpPath, timestampedArtifactRelativePath, artifactCoordinates, packaging, targetTimestampedArtifactPomDirectory, targetTimestampedArtifactDirectory);
                if (snapshotArtifactFile != null) {
                    return snapshotArtifactFile; //Success
                }
            } catch (XPathExpressionException | IOException ex) {
                Module.getModuleLogger().trace(ex, "Could not doDownload '%s' from '%s' repository", artifactRelativeHttpPath, remoteRepos);
                // try next one
            }
        }
    }
    return null;
}
 
Example #20
Source File: MultiMavenResolver.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public File resolveArtifact(ArtifactCoordinates coordinates, String packaging) throws IOException {

    for (MavenResolver resolver : this.resolvers) {
        File result = resolver.resolveArtifact(coordinates, packaging);
        if (result != null) {
            return result;
        }
    }

    return null;
}
 
Example #21
Source File: MavenArtifactDescriptor.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
public ArtifactCoordinates mscCoordinates() {
    return new ArtifactCoordinates(this.groupId,
            this.artifactId,
            this.version,
            this.classifier == null ? "" : this.classifier);

}
 
Example #22
Source File: MavenSettingsTest.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * testing is snapshot resolving works properly, as in case of snapshot version, we need to use different path than exact version.
 * @throws Exception
 */
@Test
public void testSnapshotResolving()throws Exception{
    ArtifactCoordinates coordinates = ArtifactCoordinates.fromString("org.wildfly.core:wildfly-version:2.0.5.Final-20151222.144931-1");
    String path = coordinates.relativeArtifactPath('/');
    Assert.assertEquals("org/wildfly/core/wildfly-version/2.0.5.Final-SNAPSHOT/wildfly-version-2.0.5.Final-20151222.144931-1", path);
}
 
Example #23
Source File: ArtifactManager.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
private File findFile(String gav) throws IOException, ModuleLoadException {

        // groupId:artifactId
        // groupId:artifactId:version
        // groupId:artifactId:packaging:version
        // groupId:artifactId:packaging:version:classifier

        String[] parts = gav.split(":");

        if (parts.length < 2) {
            throw new RuntimeException("GAV must includes at least 2 segments");
        }

        String groupId = parts[0];
        String artifactId = parts[1];
        String packaging = "jar";
        String version = null;
        String classifier = "";

        if (parts.length == 3) {
            version = parts[2];
        }

        if (parts.length == 4) {
            packaging = parts[2];
            version = parts[3];
        }

        if (parts.length == 5) {
            packaging = parts[2];
            version = parts[3];
            classifier = parts[4];
        }

        if (version != null && (version.isEmpty() || version.equals("*"))) {
            version = null;
        }

        if (version == null) {
            version = determineVersionViaDependenciesConf(groupId, artifactId, packaging, classifier);
        }

        if (version == null) {
            version = determineVersionViaClasspath(groupId, artifactId, packaging, classifier);
        }

        if (version == null) {
            throw new RuntimeException("Unable to determine version number from GAV: " + gav);
        }

        return MavenResolvers.get().resolveArtifact(
                new ArtifactCoordinates(
                        groupId,
                        artifactId,
                        version,
                        classifier == null ? "" : classifier), packaging);
    }
 
Example #24
Source File: ArtifactManager.java    From thorntail with Apache License 2.0 4 votes vote down vote up
private File findFile(String gav) throws IOException, ModuleLoadException {

        // groupId:artifactId
        // groupId:artifactId:version
        // groupId:artifactId:packaging:version
        // groupId:artifactId:packaging:classifier:version

        String[] parts = gav.split(COLON);

        if (parts.length < 2) {
            throw SwarmMessages.MESSAGES.gavMinimumSegments();
        }

        String groupId = parts[0];
        String artifactId = parts[1];
        String packaging = JAR;
        String version = null;
        String classifier = "";

        if (parts.length == 3) {
            version = parts[2];
        }

        if (parts.length == 4) {
            // the type "test-jar" is packaged as a .jar file more info: https://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html
            packaging = TEST_JAR.equals(parts[2]) ? JAR : parts[2];
            version = parts[3];
        }

        if (parts.length == 5) {
            packaging = TEST_JAR.equals(parts[2]) ? JAR : parts[2];
            classifier = parts[3];
            version = parts[4];
        }

        if (version != null && (version.isEmpty() || version.equals("*"))) {
            version = null;
        }

        if (version == null) {
            version = determineVersionViaApplicationEnvironment(groupId, artifactId, packaging, classifier);
        }

        if (version == null) {
            version = determineVersionViaClasspath(groupId, artifactId, packaging, classifier);
        }

        if (version == null) {
            throw SwarmMessages.MESSAGES.unableToDetermineVersion(gav);
        }
        ArtifactCoordinates coords = new ArtifactCoordinates(
                groupId,
                artifactId,
                version,
                classifier == null ? "" : classifier);

        return MavenResolvers.get().resolveArtifact(coords, packaging);
    }