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 2023/01/31 15:39:45 UTC

[jackrabbit-filevault-package-maven-plugin] branch bugfix/JCRVLT-681-ignore-gitignore-during-validate-files created (now 6804d80)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a change to branch bugfix/JCRVLT-681-ignore-gitignore-during-validate-files
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault-package-maven-plugin.git


      at 6804d80  JCRVLT-681 fix default excludes in "validate-files"

This branch includes the following new commits:

     new 6804d80  JCRVLT-681 fix default excludes in "validate-files"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[jackrabbit-filevault-package-maven-plugin] 01/01: JCRVLT-681 fix default excludes in "validate-files"

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch bugfix/JCRVLT-681-ignore-gitignore-during-validate-files
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault-package-maven-plugin.git

commit 6804d80f61ff70b24ade51f2a85cbd43d305e0eb
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Jan 31 16:39:38 2023 +0100

    JCRVLT-681 fix default excludes in "validate-files"
    
    Extend test to check that .gitignore files and .gitattributes files are
    ignored for validation (both in validate-package and validate-files)
---
 pom.xml                                            |  7 +++++
 .../mojo/AbstractSourceAndMetadataPackageMojo.java |  3 +-
 .../maven/packaging/mojo/ValidateFilesMojo.java    | 33 ++++++++++++++++++++--
 .../maven/packaging/it/ValidateFilesIT.java        |  8 ++++++
 .../valid-project-with-zip/jcr_root/.gitignore     |  1 +
 .../jcr_root/apps/.gitattributes                   |  0
 6 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 3712bf6..46ccc36 100644
--- a/pom.xml
+++ b/pom.xml
@@ -288,6 +288,13 @@
                             </resources>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>default-testResources</id>
+                        <configuration>
+                            <!-- copy .gitignore as well -->
+                            <addDefaultExcludes>false</addDefaultExcludes>
+                        </configuration>
+                    </execution>
                 </executions>
             </plugin>
             <plugin>
diff --git a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/AbstractSourceAndMetadataPackageMojo.java b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/AbstractSourceAndMetadataPackageMojo.java
index 31de5c3..62e67e8 100644
--- a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/AbstractSourceAndMetadataPackageMojo.java
+++ b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/AbstractSourceAndMetadataPackageMojo.java
@@ -47,7 +47,6 @@ public abstract class AbstractSourceAndMetadataPackageMojo extends AbstractMetad
             + "${project.basedir}/src/content/jcr_root," + "${project.build.outputDirectory}")
     private File[] jcrRootSourceDirectory;
 
-    
     /**
      * The file name patterns to exclude (in addition to the default ones mentioned at {@link AbstractSourceAndMetadataPackageMojo#addDefaultExcludes}. The format of each pattern is described in {@link org.codehaus.plexus.util.DirectoryScanner}.
      * The comparison is against the path relative to the according filter root.
@@ -57,7 +56,7 @@ public abstract class AbstractSourceAndMetadataPackageMojo extends AbstractMetad
      * Each value is either a regex pattern if enclosed within {@code %regex[} and {@code ]}, otherwise an 
      * <a href="https://ant.apache.org/manual/dirtasks.html#patterns">Ant pattern</a>.
      */
-    @Parameter(property = "vault.excludes", defaultValue = "**/.vlt,**/.vltignore,**/.gitignore", required = true)
+    @Parameter(property = "vault.excludes", defaultValue = "**/.vlt,**/.vltignore,**/.gitignore,**/.gitattributes", required = true)
     protected Set<String> excludes;
 
     /**
diff --git a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/ValidateFilesMojo.java b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/ValidateFilesMojo.java
index 3945da9..06d0139 100644
--- a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/ValidateFilesMojo.java
+++ b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/ValidateFilesMojo.java
@@ -149,8 +149,35 @@ public class ValidateFilesMojo extends AbstractValidateMojo {
      * Each value is either a regex pattern if enclosed within {@code %regex[} and {@code ]}, otherwise an 
      * <a href="https://ant.apache.org/manual/dirtasks.html#patterns">Ant pattern</a>.
      */
-    @Parameter(property = "vault.excludes", defaultValue = "**/.vlt,**/.vltignore", required = true)
+    @Parameter(property = "vault.excludes", defaultValue = "**/.vlt,**/.vltignore,**/.gitignore,**/.gitattributes", required = true)
     protected String[] excludes;
+
+    /**
+     * By default certain metadata files are excluded which means they will not be copied into the package. 
+     * If you need them for a particular reason you can do that by setting this parameter to {@code false}. This means
+     * all files matching the following <a href="https://ant.apache.org/manual/dirtasks.html#patterns">Ant patterns</a> won't be copied by default.
+     * <ul>
+     * <li>Misc: &#42;&#42;/&#42;~, &#42;&#42;/#&#42;#, &#42;&#42;/.#&#42;, &#42;&#42;/%&#42;%, &#42;&#42;/._&#42;</li>
+     * <li>CVS: &#42;&#42;/CVS, &#42;&#42;/CVS/&#42;&#42;, &#42;&#42;/.cvsignore</li>
+     * <li>SVN: &#42;&#42;/.svn, &#42;&#42;/.svn/&#42;&#42;</li>
+     * <li>GNU: &#42;&#42;/.arch-ids, &#42;&#42;/.arch-ids/&#42;&#42;</li>
+     * <li>Bazaar: &#42;&#42;/.bzr, &#42;&#42;/.bzr/&#42;&#42;</li>
+     * <li>SurroundSCM: &#42;&#42;/.MySCMServerInfo</li>
+     * <li>Mac: &#42;&#42;/.DS_Store</li>
+     * <li>Serena Dimension: &#42;&#42;/.metadata, &#42;&#42;/.metadata/&#42;&#42;</li>
+     * <li>Mercurial: &#42;&#42;/.hg, &#42;&#42;/.hg/&#42;&#42;</li>
+     * <li>GIT: &#42;&#42;/.git, &#42;&#42;/.git/&#42;&#42;</li>
+     * <li>Bitkeeper: &#42;&#42;/BitKeeper, &#42;&#42;/BitKeeper/&#42;&#42;, &#42;&#42;/ChangeSet,
+     * &#42;&#42;/ChangeSet/&#42;&#42;</li>
+     * <li>Darcs: &#42;&#42;/_darcs, &#42;&#42;/_darcs/&#42;&#42;, &#42;&#42;/.darcsrepo,
+     * &#42;&#42;/.darcsrepo/&#42;&#42;&#42;&#42;/-darcs-backup&#42;, &#42;&#42;/.darcs-temp-mail
+     * </ul>
+     *
+     * @see org.codehaus.plexus.util.AbstractScanner#DEFAULTEXCLUDES
+     * @since 1.3.4
+     */
+    @Parameter(defaultValue = "true")
+    protected boolean addDefaultExcludes;
     //-----
     // End: Copied from AbstractSourceAndMetadataPackageMojo
     // -----
@@ -229,7 +256,9 @@ public class ValidateFilesMojo extends AbstractValidateMojo {
         Scanner scanner = buildContext.newScanner(baseDir.toFile());
         // make sure filtering does work equally as within the package goal
         scanner.setExcludes(excludes);
-        scanner.addDefaultExcludes();
+        if (addDefaultExcludes) {
+            scanner.addDefaultExcludes();
+        }
         scanner.scan();
         getLog().info("Scanning baseDir " + getProjectRelativeFilePath(baseDir) + "...");
         SortedSet<Path> sortedFileAndFolderNames = sortAndEnrichFilesAndDirectories(baseDir, scanner.getIncludedFiles(), scanner.getIncludedDirectories());
diff --git a/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/ValidateFilesIT.java b/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/ValidateFilesIT.java
index 50519c9..d81037e 100644
--- a/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/ValidateFilesIT.java
+++ b/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/ValidateFilesIT.java
@@ -35,4 +35,12 @@ class ValidateFilesIT {
             .build()
             .verifyExpectedLogLines(Paths.get("META-INF","vault","filter.xml").toString());
     }
+
+    @Test
+    void testValidProjectWithZip(ProjectBuilder projectBuilder) throws Exception {
+        projectBuilder
+            .setTestProjectDir("/validator-projects/valid-project-with-zip")
+            .setTestGoals("clean", "package") // make sure the validate-files mojo is not skipped
+            .build();
+    }
 }
diff --git a/src/test/resources/test-projects/validator-projects/valid-project-with-zip/jcr_root/.gitignore b/src/test/resources/test-projects/validator-projects/valid-project-with-zip/jcr_root/.gitignore
new file mode 100644
index 0000000..c480a53
--- /dev/null
+++ b/src/test/resources/test-projects/validator-projects/valid-project-with-zip/jcr_root/.gitignore
@@ -0,0 +1 @@
+sometest
\ No newline at end of file
diff --git a/src/test/resources/test-projects/validator-projects/valid-project-with-zip/jcr_root/apps/.gitattributes b/src/test/resources/test-projects/validator-projects/valid-project-with-zip/jcr_root/apps/.gitattributes
new file mode 100644
index 0000000..e69de29