You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2022/12/08 16:18:10 UTC
[jackrabbit-filevault-package-maven-plugin] 01/01: JCRVLT-665 allow standalone usage of validate-package
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch feature/validate-package-without-pom
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault-package-maven-plugin.git
commit 192bd182d01506484e5db95fe60f9d69ab5abef7
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Dec 8 17:18:03 2022 +0100
JCRVLT-665 allow standalone usage of validate-package
---
.ratignore | 1 +
.../maven/packaging/mojo/ValidatePackageMojo.java | 20 ++++++++++----------
.../maven/packaging/it/ValidatePackageIT.java | 1 +
.../resources/test-content/expected-log-lines.txt | 1 +
4 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/.ratignore b/.ratignore
index 4a90b79..e920490 100644
--- a/.ratignore
+++ b/.ratignore
@@ -2,6 +2,7 @@
**/.gitattributes
**/.gitignore
**/pom.properties
+src/test/resources/test-content/**/*.txt
src/test/resources/test-projects/**/*.txt
src/test/resources/test-projects/**/*.xml
src/test/resources/test-projects/**/.vlt
diff --git a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/ValidatePackageMojo.java b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/ValidatePackageMojo.java
index bdcbb71..a9ddca5 100644
--- a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/ValidatePackageMojo.java
+++ b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/ValidatePackageMojo.java
@@ -60,17 +60,17 @@ import org.xml.sax.SAXException;
name = "validate-package", defaultPhase = LifecyclePhase.VERIFY, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = false, threadSafe = true)
public class ValidatePackageMojo extends AbstractValidateMojo {
- /** The main package file to validate. */
- @Parameter(readonly = true, defaultValue = "${project.artifact.file}")
- private File primaryArtifact;
+ /** The path to the main package file to validate. */
+ @Parameter(property = "vault.packageToValidate", defaultValue = "${project.artifact.file}")
+ private File packageFile;
/**
- * If set to {@code true} skips validating the project's primary artifact but only the ones being attached and having a classifier
- * equal to the one(s) in either {@link #classifiers} and/or {@link #classifier}.
+ * If set to {@code true} skips validating the package given via {@link #packageFile} but only validates the ones being attached to the current project
+ * and having a classifier equal to the one(s) in either {@link #classifiers} and/or {@link #classifier}.
* @since 1.3.2
*/
- @Parameter()
- private boolean skipPrimaryArtifact;
+ @Parameter(property = "vault.skipPackageFile")
+ private boolean skipPackageFile;
/** If set to {@code true} always executes all validators also for all sub packages (recursively). */
@Parameter(required = true, defaultValue = "false")
@@ -108,8 +108,8 @@ public class ValidatePackageMojo extends AbstractValidateMojo {
@Override
public void doExecute(ValidationMessagePrinter validationHelper) throws MojoExecutionException, MojoFailureException {
boolean foundPackage = false;
- if (!skipPrimaryArtifact && primaryArtifact != null && primaryArtifact.isFile()) {
- validatePackage(validationHelper, primaryArtifact.toPath());
+ if (!skipPackageFile && packageFile != null && packageFile.isFile()) {
+ validatePackage(validationHelper, packageFile.toPath());
foundPackage = true;
}
if (!attachedArtifacts.isEmpty()) {
@@ -129,7 +129,7 @@ public class ValidatePackageMojo extends AbstractValidateMojo {
}
}
if (!foundPackage) {
- getLog().warn("No packages found to validate.");
+ throw new MojoFailureException("No packages found to validate.");
}
validationHelper.failBuildInCaseOfViolations(failOnValidationWarnings);
}
diff --git a/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/ValidatePackageIT.java b/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/ValidatePackageIT.java
index c009eb6..7c1d9ba 100644
--- a/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/ValidatePackageIT.java
+++ b/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/ValidatePackageIT.java
@@ -84,6 +84,7 @@ class ValidatePackageIT {
.setProperty("vault.packageToValidate", "test-package.zip")
.setVerifyPackageContents(false)
.build();
+ projectBuilder.verifyExpectedLogLines();
}
@Test
diff --git a/src/test/resources/test-content/expected-log-lines.txt b/src/test/resources/test-content/expected-log-lines.txt
new file mode 100644
index 0000000..8651b60
--- /dev/null
+++ b/src/test/resources/test-content/expected-log-lines.txt
@@ -0,0 +1 @@
+[WARNING] ValidationViolation: No package type set, make sure that property 'packageType' is set in the properties.xml! @ META-INF/vault/properties.xml, validator: jackrabbit-packagetype
\ No newline at end of file