Merge branch 'develop' into stable

This commit is contained in:
2022-04-04 17:52:32 -04:00

View File

@@ -63,6 +63,9 @@ public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback
@Requirement
private ArtifactResolver artifactResolver;
@Parameter( property = "classifier", required = false )
protected String classifier;
@Parameter( property = "outputFile", required = true, defaultValue = "${project.build.directory}/${project.artifactId}-${project.version}.amp" )
protected String outputAmpFile;
@@ -103,6 +106,13 @@ public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback
}
this.getLog().debug("Executing AMP packaging");
this.classifier = StringUtils.trimToNull(this.classifier);
if (this.classifier != null) {
this.getLog().info("A classifier was specified; injecting classifier into module and output artifact names");
this.outputAmpFile = this.injectClassifier(this.outputAmpFile);
this.moduleJarFile = this.injectClassifier(this.moduleJarFile);
}
this.normalize();
File ampFile = this.getOutputFile();
@@ -134,6 +144,22 @@ public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback
}
}
private String injectClassifier(String filename) {
int lastDot = filename.lastIndexOf('.');
if (lastDot < 0)
throw new IllegalArgumentException();
int lastDash = filename.lastIndexOf('-', lastDot-1);
if (lastDash > 0) {
// see if the classifier was already specified
String possibleClassifier = filename.substring(lastDash+1, lastDot);
if (this.classifier.equals(possibleClassifier))
return filename;
}
return filename.substring(0, lastDot) + '-' + this.classifier + filename.substring(lastDot);
}
private void normalize() {
this.outputAmpFile = StringUtils.trimToNull(this.outputAmpFile);
this.moduleJarFile = StringUtils.trimToNull(this.moduleJarFile);