[MRESOURCE-190] Regression: The plugin is now silently ignoring .gitignore files.
 o Added an option (addDefaultExcludes) to be able to turn off usage of the
   default excludes list. This option is by default true which means we are 
   backward compatible.


git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1733876 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 95c9c6d..62d4f9e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -169,6 +169,7 @@
               <configuration>
                 <debug>true</debug>
                 <postBuildHookScript>verify</postBuildHookScript>
+                <preBuildHookScript>setup</preBuildHookScript>
                 <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
                 <goals>
                   <goal>clean</goal>
@@ -184,6 +185,9 @@
           </plugins>
         </pluginManagement>
         <plugins>
+          <!--
+           ! Why is the following needed?
+          -->
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-jar-plugin</artifactId>
diff --git a/src/it/include-git-ignore/pom.xml b/src/it/include-git-ignore/pom.xml
new file mode 100644
index 0000000..b1ca9e6
--- /dev/null
+++ b/src/it/include-git-ignore/pom.xml
@@ -0,0 +1,57 @@
+<?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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>maven-resources-plugin-it-includeEmptyDirs</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+      </resource>
+    </resources>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>@project.version@</version>
+          <configuration>
+            <addDefaultExcludes>false</addDefaultExcludes>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+      </plugin>      
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/include-git-ignore/setup.bsh b/src/it/include-git-ignore/setup.bsh
new file mode 100644
index 0000000..800c1aa
--- /dev/null
+++ b/src/it/include-git-ignore/setup.bsh
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+
+import org.codehaus.plexus.util.*;
+
+boolean result = true;
+
+try
+{
+    File resources = new File( basedir, "src/main/resources" );
+    File gitIgnore = new File ( resources, ".gitignore" );
+
+
+    BufferedWriter writer;
+    try {
+
+      writer = new BufferedWriter(new FileWriter(gitIgnore));
+      writer.write ("# Test for .gitignore");
+      writer.newLine();
+    }
+    finally {
+      try {
+        // Close the writer regardless of what happens...
+        writer.close();
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+    }
+
+}
+catch( IOException e )
+{
+    e.printStackTrace();
+    result = false;
+}
+
+try
+{
+    File resources = new File( basedir, "src/main/resources/dir-with-dot-file" );
+
+    if ( !resources.mkdirs() ) {
+      System.out.println ( "Failed to created dir-with-dot-file folder." );
+      result = false;
+    }
+    File gitIgnore = new File ( resources, ".gitignore" );
+
+
+    BufferedWriter writer;
+    try {
+
+      writer = new BufferedWriter(new FileWriter(gitIgnore));
+      writer.write ("# Test for .gitignore");
+      writer.newLine();
+    }
+    finally {
+      try {
+        // Close the writer regardless of what happens...
+        writer.close();
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+    }
+
+}
+catch( IOException e )
+{
+    e.printStackTrace();
+    result = false;
+}
+return result;
diff --git a/src/it/include-git-ignore/verify.bsh b/src/it/include-git-ignore/verify.bsh
new file mode 100644
index 0000000..c3e8f57
--- /dev/null
+++ b/src/it/include-git-ignore/verify.bsh
@@ -0,0 +1,73 @@
+
+/*
+ * 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.
+ */
+
+import java.io.*;
+
+import org.codehaus.plexus.util.*;
+
+boolean result = true;
+
+try
+{
+    File target = new File( basedir, "target" );
+    if ( !target.exists() || !target.isDirectory() )
+    {
+        System.err.println( "target file is missing or not a directory." );
+        return false;
+    }
+
+    File classes = new File( target, "classes" );
+    if ( !classes.exists() || !classes.isDirectory() )
+    {
+        System.err.println( "target/classes file is missing or not a directory." );
+        return false;
+    }
+
+    File gitIngoreInClasses = new File ( classes, ".gitignore" );
+    if ( !gitIngoreInClasses.exists() || !gitIngoreInClasses.isFile() )
+    {
+        System.err.println( "target/classes/.gitignore file is missing." );
+        return false;
+    }
+
+
+
+    File dirWithDotFile = new File( classes, "dir-with-dot-file" );
+    if ( !dirWithDotFile.exists() || !dirWithDotFile.isDirectory() )
+    {
+        System.err.println( "target/classes/dir-with-dot-file file is missing or not a directory." );
+        return false;
+    }
+
+    File gitIngoreInDirWithDotFile = new File ( dirWithDotFile, ".gitignore" );
+    if ( !gitIngoreInDirWithDotFile.exists() || !gitIngoreInDirWithDotFile.isFile() )
+    {
+        System.err.println( "target/classes/dir-with-dot-file/.gitignore file is missing." );
+        return false;
+    }
+
+}
+catch( IOException e )
+{
+    e.printStackTrace();
+    result = false;
+}
+
+return result;
diff --git a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java
index 0a67779..b4f5b9c 100644
--- a/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java
@@ -204,6 +204,36 @@
     protected boolean useDefaultDelimiters;
 
     /**
+     * By default files like {@code .gitignore}, {@code .cvsignore} etc. are excluded which means they will not being
+     * copied. If you need them for a particular reason you can do that by settings this to {@code false}. This means
+     * all files like the following will be copied.
+     * <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>RCS: &#42;&#42;/RCS, &#42;&#42;/RCS/&#42;&#42;</li>
+     * <li>SCCS: &#42;&#42;/SCCS, &#42;&#42;/SCCS/&#42;&#42;</li>
+     * <li>VSSercer: &#42;&#42;/vssver.scc</li>
+     * <li>MKS: &#42;&#42;/project.pj</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;/.gitignore, &#42;&#42;/.gitattributes, &#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>
+     *
+     * @since 3.0.0
+     */
+    @Parameter( defaultValue = "true" )
+    protected boolean addDefaultExcludes;
+
+    /**
      * <p>
      * List of plexus components hint which implements
      * {@link MavenResourcesFiltering#filterResources(MavenResourcesExecution)}. They will be executed after the
@@ -291,6 +321,7 @@
             mavenResourcesExecution.setIncludeEmptyDirs( includeEmptyDirs );
             mavenResourcesExecution.setSupportMultiLineFiltering( supportMultiLineFiltering );
             mavenResourcesExecution.setFilterFilenames( fileNameFiltering );
+            mavenResourcesExecution.setAddDefaultExcludes( addDefaultExcludes );
 
             // if these are NOT set, just use the defaults, which are '${*}' and '@'.
             mavenResourcesExecution.setDelimiters( delimiters, useDefaultDelimiters );