use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project maven-plugins by apache.
the class AbstractJavadocMojo method populateCompileArtifactMap.
/**
* Method to put the artifacts in the hashmap.
*
* @param compileArtifactMap the hashmap that will contain the artifacts
* @param artifactList the list of artifacts that will be put in the map
* @throws MavenReportException if any
*/
private void populateCompileArtifactMap(Map<String, Artifact> compileArtifactMap, Collection<Artifact> artifactList) throws MavenReportException {
if (artifactList == null) {
return;
}
for (Artifact newArtifact : artifactList) {
File file = newArtifact.getFile();
if (file == null) {
throw new MavenReportException("Error in plugin descriptor - " + "dependency was not resolved for artifact: " + newArtifact.getGroupId() + ":" + newArtifact.getArtifactId() + ":" + newArtifact.getVersion());
}
if (compileArtifactMap.get(newArtifact.getDependencyConflictId()) != null) {
Artifact oldArtifact = compileArtifactMap.get(newArtifact.getDependencyConflictId());
ArtifactVersion oldVersion = new DefaultArtifactVersion(oldArtifact.getVersion());
ArtifactVersion newVersion = new DefaultArtifactVersion(newArtifact.getVersion());
if (newVersion.compareTo(oldVersion) > 0) {
compileArtifactMap.put(newArtifact.getDependencyConflictId(), newArtifact);
}
} else {
compileArtifactMap.put(newArtifact.getDependencyConflictId(), newArtifact);
}
}
}
use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project jangaroo-tools by CoreMedia.
the class ExmlToMxmlMojo method execute.
@Override
public void execute() throws MojoExecutionException {
boolean useNewPackagingType = extAsVersion != null && new DefaultArtifactVersion(extAsVersion).compareTo(EXT_AS_FIRST_SWC_ARTIFACT_VERSION) >= 0;
if (!renameOnly && (hasExmlConfiguration() || "jangaroo".equals(getProject().getPackaging()))) {
getLog().info("reading POM from " + getProject().getBasedir().getPath());
PomConverter pomConverter = new PomConverter(getProject().getBasedir());
getLog().info("removing exml-maven-plugin from POM");
pomConverter.removeExmlPlugin();
String newPackaging = useNewPackagingType ? "swc" : "jangaroo-pkg";
getLog().info("changing packaging from 'jangaroo' to '" + newPackaging + "'");
pomConverter.changePackaging(newPackaging);
if (useNewPackagingType) {
getLog().info("adding dependency type 'swc' to all compile dependencies");
pomConverter.addDependencyType(newPackaging);
}
getLog().info("updating POM at " + getProject().getBasedir().getPath());
pomConverter.writePom();
}
if (!isExmlProject()) {
getLog().info("not an EXML project, skipping MXML conversion");
return;
}
if (renameOnly) {
getLog().info("Renaming EXML files to MXML files");
try {
renameFiles(getSourceDirectory(), "exml", "mxml");
renameFiles(getTestSourceDirectory(), "exml", "mxml");
} catch (IOException e) {
throw new MojoExecutionException("error while renaming EXML files", e);
}
return;
}
if (alreadyRenamed) {
getLog().info("Renaming MXML files back to EXML files before running the conversion");
try {
renameFiles(getSourceDirectory(), "mxml", "exml");
renameFiles(getTestSourceDirectory(), "mxml", "exml");
} catch (IOException e) {
throw new MojoExecutionException("error while renaming files", e);
}
}
if (extAsVersion == null) {
throw new MojoExecutionException("exml-to-mxml needs an extAsVersion.");
}
Artifact extAsArtifact = resolveExtAsArtifact(extAsVersion, useNewPackagingType ? "swc" : "jar");
File extAsJar = extAsArtifact.getFile();
// Convert main EXML sources to MXML:
ExmlConfiguration config = createExmlConfiguration(getActionScriptClassPath(), Collections.singletonList(getSourceDirectory()), getGeneratedSourcesDirectory());
config.setExtAsJar(extAsJar);
new Exmlc(config).convertAllExmlToMxml();
// Also convert test EXML sources to MXML:
if (getTestSourceDirectory() != null && getTestSourceDirectory().exists()) {
ExmlConfiguration testConfig = createExmlConfiguration(getActionScriptTestClassPath(), Collections.singletonList(getTestSourceDirectory()), getGeneratedTestSourcesDirectory());
testConfig.setExtAsJar(extAsJar);
new Exmlc(testConfig).convertAllExmlToMxml();
}
}
use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project project-build-plugin by axonivy.
the class URLEngineDownloader method findEngineDownloadUrl.
public URL findEngineDownloadUrl(InputStream htmlStream) throws MojoExecutionException, MalformedURLException {
String engineFileNameRegex = "AxonIvyEngine[^.]+?\\.[^.]+?\\.+[^_]*?_" + osArchitecture + "\\.zip";
Pattern enginePattern = Pattern.compile("href=[\"|'][^\"']*?" + engineFileNameRegex + "[\"|']");
try (Scanner scanner = new Scanner(htmlStream)) {
String engineLink = null;
while (StringUtils.isBlank(engineLink)) {
String engineLinkMatch = scanner.findWithinHorizon(enginePattern, 0);
if (engineLinkMatch == null) {
throw new MojoExecutionException("Could not find a link to engine for version '" + ivyVersion + "' on site '" + engineListPageUrl + "'");
}
String versionString = StringUtils.substringBetween(engineLinkMatch, "AxonIvyEngine", "_" + osArchitecture);
ArtifactVersion version = new DefaultArtifactVersion(EngineVersionEvaluator.toReleaseVersion(versionString));
if (ivyVersionRange.containsVersion(version)) {
engineLink = StringUtils.replace(engineLinkMatch, "\"", "'");
engineLink = StringUtils.substringBetween(engineLink, "href='", "'");
}
}
return toAbsoluteLink(engineListPageUrl, engineLink);
}
}
use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project project-build-plugin by axonivy.
the class BaseEngineProjectMojoTest method getNextMajor.
private static String getNextMajor(String version) {
DefaultArtifactVersion parsed = new DefaultArtifactVersion(version);
int majorVersion = parsed.getMajorVersion();
String nextMajor = new StringBuilder().append(majorVersion + 1).append('.').append(parsed.getMinorVersion()).append('.').append(parsed.getIncrementalVersion()).toString();
return nextMajor;
}
use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project irontest by zheng-wang.
the class UpgradeCommand method run.
@Override
public void run() {
SystemDatabaseYml systemDBConfiguration;
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
try {
ConfigYml configYml = mapper.readValue(new File(ironTestHome, "config.yml"), ConfigYml.class);
systemDBConfiguration = configYml.getSystemDatabase();
} catch (IOException e) {
throw new RuntimeException("Failed to read config.yml under " + ironTestHome, e);
}
String fullyQualifiedSystemDBURL = getFullyQualifiedSystemDBURL(ironTestHome, systemDBConfiguration.getUrl());
DefaultArtifactVersion systemDBVersion = getSystemDBVersionStr(fullyQualifiedSystemDBURL, systemDBConfiguration.getUser(), systemDBConfiguration.getPassword());
DefaultArtifactVersion jarFileVersion = new DefaultArtifactVersion(Version.VERSION);
int comparison = systemDBVersion.compareTo(jarFileVersion);
if ("SNAPSHOT".equals(systemDBVersion.getQualifier())) {
System.out.println("System database version " + systemDBVersion + " is a SNAPSHOT version. Upgrade is not supported.");
} else if ("SNAPSHOT".equals(jarFileVersion.getQualifier())) {
System.out.println("Jar file version " + jarFileVersion + " is a SNAPSHOT version. Upgrade is not supported.");
} else if (comparison == 0) {
System.out.println("System database and the jar file are of the same version, so no need to upgrade.");
} else if (comparison > 0) {
// system database version is bigger than the jar file version
System.out.printf(Constants.PROMPT_TEXT_WHEN_SYSTEM_DB_VERSION_IS_BIGGER_THAN_JAR_VERSION, systemDBVersion, jarFileVersion);
} else {
// system database version is smaller than the jar file version
UpgradeActions upgradeActions = new UpgradeActions();
try {
upgradeActions.upgrade(systemDBVersion, jarFileVersion, ironTestHome, fullyQualifiedSystemDBURL, systemDBConfiguration.getUser(), systemDBConfiguration.getPassword());
} catch (Exception e) {
throw new RuntimeException("Failed to upgrade Iron Test under " + ironTestHome, e);
}
}
}
Aggregations