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

rfscholte pushed a commit to branch ARCHETYPE-606
in repository https://gitbox.apache.org/repos/asf/maven-archetype.git

commit 79db20abe81ee5b0ea2c9e353e15fd5d28f2718c
Author: Peter Lamby <[email protected]>
AuthorDate: Fri Oct 9 14:36:23 2020 +0200

    Make exclude behaviour configurable
---
 .../src/main/java/org/apache/maven/archetype/mojos/JarMojo.java  | 9 ++++++++-
 maven-archetype-plugin/src/site/fml/faq.fml                      | 8 ++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git 
a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/JarMojo.java
 
b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/JarMojo.java
index 2e72a4e..e651d33 100644
--- 
a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/JarMojo.java
+++ 
b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/JarMojo.java
@@ -51,6 +51,7 @@ import java.util.Map;
 public class JarMojo
     extends AbstractMojo
 {
+
     /**
      * Directory containing the classes.
      */
@@ -70,6 +71,12 @@ public class JarMojo
     private File outputDirectory;
 
     /**
+     * Exclude some files from the archetype like .gitignore.
+     * */
+    @Parameter( defaultValue = "true" )
+    private boolean useDefaultExcludes;
+
+    /**
      * The Maven project.
      */
     @Parameter( defaultValue = "${project}", readonly = true, required = true )
@@ -139,7 +146,7 @@ public class JarMojo
         {
             DefaultFileSet fs = DefaultFileSet.fileSet( archetypeDirectory 
).prefixed( "" )
                 .includeExclude( null,  null ).includeEmptyDirs( true );
-            fs.setUsingDefaultExcludes( false );
+            fs.setUsingDefaultExcludes( useDefaultExcludes );
             archiver.getArchiver().addFileSet( fs );
 
             archiver.createArchive( session, project, archive );
diff --git a/maven-archetype-plugin/src/site/fml/faq.fml 
b/maven-archetype-plugin/src/site/fml/faq.fml
index 018a407..131beaa 100644
--- a/maven-archetype-plugin/src/site/fml/faq.fml
+++ b/maven-archetype-plugin/src/site/fml/faq.fml
@@ -55,6 +55,14 @@ under the License.
       </answer>
     </faq>
 
+    <faq id="excludes">
+      <question>How do I get files like <code>.gitignore</code> included into 
my archetype?</question>
+      <answer>
+        <p>First make sure you set <code>addDefaultExcludes</code> to 
<code>false</code> in the <code>maven-resources-plugin</code>
+        so that the archetype-plugin gets to see these files.</p>
+        <p>Then set <code>useDefaultExcludes</code> to <code>false</code> in 
the <code>maven-archetype-plugin</code>.</p>
+      </answer>
+    </faq>
   </part>
 
 </faqs>

Reply via email to