You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/10/30 19:02:46 UTC

[maven-archetype] branch master updated: [ARCHETYPE-606] There is no way to include .gitignore files for the jar goal

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5351651  [ARCHETYPE-606] There is no way to include .gitignore files for the jar goal
5351651 is described below

commit 5351651b33fde2cb046e2f103bbc6be3c38acbab
Author: rfscholte <rf...@apache.org>
AuthorDate: Fri Oct 30 20:02:29 2020 +0100

    [ARCHETYPE-606] There is no way to include .gitignore files for the jar goal
    
    Author: Peter Lamby <pe...@direkt-gruppe.de>
    Signed-off-by: rfscholte <rf...@apache.org>
---
 .../archetype.properties                           | 18 ++++++
 .../invoker.properties                             | 18 ++++++
 .../ARCHETYPE-606_include-gitignore/pom.xml        | 75 ++++++++++++++++++++++
 .../ARCHETYPE-606_include-gitignore/setup.groovy   | 30 +++++++++
 .../META-INF/maven/archetype-metadata.xml          | 40 ++++++++++++
 .../src/main/resources/archetype-resources/pom.xml | 50 +++++++++++++++
 .../archetype-resources/src/main/java/App.java     | 36 +++++++++++
 .../resources/projects/archetype.pom.properties    | 21 ++++++
 .../test/resources/projects/archetype.properties   | 21 ++++++
 .../resources/projects/basic/archetype.properties  | 21 ++++++
 .../src/test/resources/projects/basic/goal.txt     |  1 +
 .../resources/projects/basic/reference/pom.xml     | 50 +++++++++++++++
 .../src/main/java/build/archetype/App.java         | 36 +++++++++++
 .../test-settings.xml                              | 55 ++++++++++++++++
 .../org/apache/maven/archetype/mojos/JarMojo.java  | 13 +++-
 maven-archetype-plugin/src/site/fml/faq.fml        |  8 +++
 16 files changed, 492 insertions(+), 1 deletion(-)

diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/archetype.properties b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/archetype.properties
new file mode 100644
index 0000000..74cf9cb
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/archetype.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+excludePatterns=build.log,invoker.properties,verify.groovy
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/invoker.properties b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/invoker.properties
new file mode 100644
index 0000000..e71f103
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/invoker.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.goals = clean verify
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/pom.xml
new file mode 100644
index 0000000..82eadc3
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.archetype.its</groupId>
+  <artifactId>build-archetype-and-run-its</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>maven-archetype</packaging>
+
+  <name>build-archetype-and-run-its</name>
+  <description>packages an archetype then runs IT (archetype:integration-test)</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <extensions>
+      <extension>
+        <groupId>org.apache.maven.archetype</groupId>
+        <artifactId>archetype-packaging</artifactId>
+        <version>@project.version@</version>
+      </extension>
+    </extensions>
+
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-archetype-plugin</artifactId>
+          <version>@project.version@</version>
+          <configuration>
+            <settingsFile>${basedir}/test-settings.xml</settingsFile>
+            <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+            <ignoreEOLStyle>true</ignoreEOLStyle>
+            <useDefaultExcludes>false</useDefaultExcludes>
+            <properties>
+              <maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
+              <maven.compiler.target>${maven.compiler.target}</maven.compiler.target>
+              <!-- e.g. ensure that Java7 picks up TLSv1.2 when connecting with Central -->
+              <https.protocols>${https.protocols}</https.protocols>
+            </properties>
+          </configuration>
+        </plugin>
+        <plugin>
+          <artifactId>maven-resources-plugin</artifactId>
+          <configuration>
+            <includeEmptyDirs>true</includeEmptyDirs>
+            <addDefaultExcludes>false</addDefaultExcludes>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/setup.groovy b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/setup.groovy
new file mode 100644
index 0000000..8affb5d
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/setup.groovy
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// This is a workaround. The invoker-plugin does not copy the .gitignore file to the clone
+// target directory. So we create the .gitignore here in the setup task.
+
+import java.io.*;
+import org.codehaus.plexus.util.*;
+
+srcGitignore = new File ( basedir, "src/main/resources/archetype-resources/.gitignore" );
+targetGitignore = new File ( basedir, "src/test/resources/projects/basic/reference/.gitignore" );
+
+FileUtils.fileWrite(srcGitignore, "UTF-8", "#Dummy");
+FileUtils.fileWrite(targetGitignore, "UTF-8", "#Dummy");
\ No newline at end of file
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/main/resources/META-INF/maven/archetype-metadata.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..abe5546
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<archetype-descriptor xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+    name="build-archetype-IT">
+  <fileSets>
+    <fileSet encoding="UTF-8">
+      <directory></directory>
+      <includes>
+        <include>.gitignore</include>
+      </includes>
+    </fileSet>
+    <fileSet filtered="true" packaged="true" encoding="UTF-8">
+      <directory>src/main/java</directory>
+      <includes>
+        <include>**/*.java</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</archetype-descriptor>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/main/resources/archetype-resources/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..aa77176
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+## There should be no parent specified, as it should be set automatically
+
+  <groupId>${groupId}</groupId>
+  <artifactId>${artifactId}</artifactId>
+  <version>${version}</version>
+
+  <name>archetype build IT</name>
+
+  <properties>
+    <javaVersion>6</javaVersion>
+    <maven.compiler.source>1.${javaVersion}</maven.compiler.source>
+    <maven.compiler.target>1.${javaVersion}</maven.compiler.target>    
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.7.0</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/main/resources/archetype-resources/src/main/java/App.java b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/main/resources/archetype-resources/src/main/java/App.java
new file mode 100644
index 0000000..eb9b6c7
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/main/resources/archetype-resources/src/main/java/App.java
@@ -0,0 +1,36 @@
+package ${package};
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hello world!
+ *
+ */
+public class App
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+        System.out.println( "groupId = ${groupId}" );
+        System.out.println( "artifactId = ${artifactId}" );
+        System.out.println( "package = ${package}" );
+        System.out.println( "packageInPathFormat = ${packageInPathFormat}" );
+    }
+}
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/archetype.pom.properties b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/archetype.pom.properties
new file mode 100644
index 0000000..627146f
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/archetype.pom.properties
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# https://github.com/mojohaus/pom-root, creates simple pom with packaging pom
+groupId=org.codehaus.mojo.archetypes
+artifactId=pom-root
+version=1.1
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/archetype.properties b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/archetype.properties
new file mode 100644
index 0000000..75a95e1
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/archetype.properties
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+groupId=com.company 
+artifactId=project
+version=1.0-SNAPSHOT
+package=com.company.project
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/archetype.properties b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/archetype.properties
new file mode 100644
index 0000000..3560bb4
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/archetype.properties
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
+package=build.archetype
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/goal.txt b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/goal.txt
new file mode 100644
index 0000000..f8808ba
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/goal.txt
@@ -0,0 +1 @@
+compile
\ No newline at end of file
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/reference/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/reference/pom.xml
new file mode 100644
index 0000000..1039f6a
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/reference/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>project</artifactId>
+    <groupId>com.company</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>archetype.it</groupId>
+  <artifactId>basic</artifactId>
+  <version>0.1-SNAPSHOT</version>
+
+  <name>archetype build IT</name>
+
+  <properties>
+    <javaVersion>6</javaVersion>
+    <maven.compiler.source>1.${javaVersion}</maven.compiler.source>
+    <maven.compiler.target>1.${javaVersion}</maven.compiler.target>    
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.7.0</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/reference/src/main/java/build/archetype/App.java b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/reference/src/main/java/build/archetype/App.java
new file mode 100644
index 0000000..d507638
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/src/test/resources/projects/basic/reference/src/main/java/build/archetype/App.java
@@ -0,0 +1,36 @@
+package build.archetype;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hello world!
+ *
+ */
+public class App
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+        System.out.println( "groupId = archetype.it" );
+        System.out.println( "artifactId = basic" );
+        System.out.println( "package = build.archetype" );
+        System.out.println( "packageInPathFormat = build/archetype" );
+    }
+}
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/test-settings.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/test-settings.xml
new file mode 100644
index 0000000..ab9e16e
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-606_include-gitignore/test-settings.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<settings>
+  <profiles>
+    <profile>
+      <id>it-repo</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <repositories>
+        <repository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </repository>
+      </repositories>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+  </profiles>
+</settings>
\ No newline at end of file
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 c950f38..690731b 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
@@ -37,6 +37,7 @@ import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.util.DefaultFileSet;
 
 import java.io.File;
 import java.util.Map;
@@ -50,6 +51,7 @@ import java.util.Map;
 public class JarMojo
     extends AbstractMojo
 {
+
     /**
      * Directory containing the classes.
      */
@@ -69,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 )
@@ -136,7 +144,10 @@ public class JarMojo
 
         try
         {
-            archiver.getArchiver().addDirectory( archetypeDirectory );
+            DefaultFileSet fs = DefaultFileSet.fileSet( archetypeDirectory ).prefixed( "" )
+                .includeExclude( null,  null ).includeEmptyDirs( true );
+            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>