Github user JaroslavTulach commented on a diff in the pull request: https://github.com/apache/incubator-netbeans/pull/97#discussion_r143400960 --- Diff: nbbuild/antsrc/org/netbeans/nbbuild/extlibs/DownloadBinaries.java --- @@ -415,16 +406,113 @@ private String hash(InputStream is) throws IOException { return String.format("%040X", new BigInteger(1, digest.digest())); } - static boolean isMavenFile(String... hashAndId) { - return hashAndId[1].split(":").length > 2; - } - static String mavenFileName(String... hashAndId) { - assert isMavenFile(hashAndId); - String[] artifactGroupVersion = hashAndId[1].split(":"); - return artifactGroupVersion[1] + "-" + artifactGroupVersion[2] + ".jar"; - } + static class MavenCoordinate { + private final String groupId; + private final String artifactId; + private final String version; + private final String extension; + private final String classifier; + private MavenCoordinate(String groupId, String artifactId, String version, String extension, String classifier) { + this.groupId = groupId; + this.artifactId = artifactId; + this.version = version; + this.extension = extension; + this.classifier = classifier; + } + + public boolean hasClassifier() { + return (! classifier.isEmpty()); + } + + public String getGroupId() { + return groupId; + } + + public String getArtifactId() { + return artifactId; + } + + public String getVersion() { + return version; + } + public String getExtension() { + return extension; + } + + public String getClassifier() { + return classifier; + } + + /** + * @return filename of the artifact by maven convention: + * {@code artifact-version[-classifier].extension} + */ + public String toArtifactFilename() { + return String.format("%s-%s%s.%s", + getArtifactId(), + getVersion(), + hasClassifier() ? ("-" + getClassifier()) : "", + getExtension() + ); + } + + /** + * @return The repository path for an artifact by maven convention: + * {@code group/artifact/version/artifact-version[-classifier].extension}. + * In the group part all dots are replaced by a slash. + */ + public String toMavenPath() { + return String.format("%s/%s/%s/%s", + getGroupId().replace(".", "/"), + getArtifactId(), + getVersion(), + toArtifactFilename() + ); + } + + public static boolean isMavenFile(String gradleFormat) { + return gradleFormat.split(":").length > 2; + } + + /** + * The maven coordinate is supplied in the form: + * + * <p>{@code group:name:version:classifier@extension}</p> + * + * <p>For the DownloadBinaries task the parts group, name and version + * are requiered. classifier and extension are optional. The extension + * has a default value of "jar". --- End diff -- Nice.
---