trivial: skip execution of validate-files mojo earlier
diff --git a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/AbstractValidateMojo.java b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/AbstractValidateMojo.java
index 05d1b20..fa09f12 100644
--- a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/AbstractValidateMojo.java
+++ b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/AbstractValidateMojo.java
@@ -187,8 +187,20 @@
// cannot use null values due to https://bugs.openjdk.java.net/browse/JDK-8148463 therefore rely on artificial IGNORE_ARTIFACT
.collect(Collectors.toMap(a -> Dependency.fromString(a[0]), a -> { if (a[1].equalsIgnoreCase(IGNORE_GAV)) { return IGNORE_ARTIFACT; } String[] mavenGA = a[1].split(":", 2); if(mavenGA.length != 2) { throw new IllegalArgumentException("Could not parse Maven group Id and artifact Id (must be separated by ':')"); } return new DefaultArtifact(mavenGA[0], mavenGA[1], "", "", "", "", null);} ));
}
+
+ /**
+ *
+ * @return {@code true} to skip execution of the mojo. Default is {@code false}.
+ */
+ protected boolean shouldSkip() {
+ return false;
+ }
+
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
+ if (shouldSkip()) {
+ return;
+ }
if (skipValidation) {
getLog().info("Skipping validation");
return;
diff --git a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidateFilesMojo.java b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidateFilesMojo.java
index 875d144..1cc429d 100644
--- a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidateFilesMojo.java
+++ b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/ValidateFilesMojo.java
@@ -143,9 +143,8 @@
public ValidateFilesMojo() {
}
-
@Override
- public void doExecute() throws MojoExecutionException, MojoFailureException {
+ protected boolean shouldSkip() {
final List<String> allGoals;
if (session != null) {
allGoals = session.getGoals();
@@ -158,13 +157,18 @@
try {
if (!buildContext.isIncremental() && isMojoGoalExecuted(lifecycleExecutor, "validate-package", allGoals.toArray(new String[0]))) { // how to detect that "install" contains "package"? how to resolve the given goals?
getLog().info("Skip this mojo as this is not an incremental build and 'validate-package' is executed later on!");
- return;
+ return true;
}
} catch (PluginNotFoundException | PluginResolutionException | PluginDescriptorParsingException | MojoNotFoundException
| NoPluginFoundForPrefixException | InvalidPluginDescriptorException | PluginVersionResolutionException
| LifecyclePhaseNotFoundException | LifecycleNotFoundException | PluginManagerException e1) {
getLog().warn("Could not determine plugin executions", e1);
}
+ return false;
+ }
+
+ @Override
+ public void doExecute() throws MojoExecutionException, MojoFailureException {
disableChecksOnlyWorkingForPackages();
try {
File metaInfoVaultSourceDirectory = AbstractMetadataPackageMojo.getMetaInfVaultSourceDirectory(metaInfVaultDirectory, getLog());