Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,52 +1,83 @@
package com.devonfw.tools.ide.url.tool.mvn;

import com.devonfw.tools.ide.url.updater.MavenBasedUrlUpdater;
import java.util.Locale;

import com.devonfw.tools.ide.url.model.folder.UrlVersion;
import com.devonfw.tools.ide.url.updater.GithubUrlReleaseUpdater;
import com.devonfw.tools.ide.version.VersionIdentifier;

/**
* {@link MavenBasedUrlUpdater} for mvn (maven).
* {@link GithubUrlReleaseUpdater} for mvn (maven).
*/
public class MvnUrlUpdater extends MavenBasedUrlUpdater {
public class MvnUrlUpdater extends GithubUrlReleaseUpdater {

public static final VersionIdentifier MIN_VERSION = VersionIdentifier.of("3.0.4");
private static final VersionIdentifier MIN_VERSION = VersionIdentifier.of("3.0.4");
private static final VersionIdentifier MAVEN_4_IDENTIFIER = VersionIdentifier.of("4.0.0-alpha");

@Override
protected String getMavenGroupIdPath() {
public String getTool() {

return "org/apache/maven";
return "mvn";
}

@Override
protected String getMavenArtifcatId() {
public String getCpeVendor() {

return "maven-core";
return "apache";
}

@Override
public String getTool() {
public String getCpeProduct() {

return "mvn";
return "maven";
}

@Override
protected boolean isValidVersion(String version) {
protected String getGithubOrganization() {
return "apache";
}

VersionIdentifier artifactVersion = VersionIdentifier.of(version);
if (artifactVersion != null) {
return artifactVersion.isGreaterOrEqual(MIN_VERSION);
}
return true;
@Override
protected String getGithubRepository() {

return "maven";
}

@Override
public String getCpeVendor() {
protected String getDownloadBaseUrl() {

return "apache";
return "https://archive.apache.org";
}

@Override
public String getCpeProduct() {
public String mapVersion(String version) {

return "maven";
// Workaround to get Release Candidates.
// A better solution would be a flag or a map to signal which version are wanted.
String vLower = version.toLowerCase(Locale.ROOT);
if (vLower.startsWith("maven ")) {
version = version.substring(6);
vLower = vLower.substring(6);
}
if (vLower.contains("-rc")) {
return version;
} else {
return super.mapVersion(version);
}
}

@Override
protected void addVersion(UrlVersion urlVersion) {

VersionIdentifier versionIdentifier = urlVersion.getVersionIdentifier();
if (versionIdentifier.compareVersion(MIN_VERSION).isGreater()) {
String version = mapVersion(urlVersion.getName());

// This is just a workaround because apache archive sorts its versions into maven-x folders.
// A better solution would be to extract the major version of the VersionIdentifier
// and put that into the String Formatter but no such method exists yet.
String majorFolder = versionIdentifier.compareVersion(MAVEN_4_IDENTIFIER).isLess() ? "maven-3" : "maven-4";
doAddVersion(urlVersion, getDownloadBaseUrl() + "/dist/maven/" + majorFolder + "/${version}/binaries/apache-maven-${version}-bin.zip");
}
}
}
Loading