You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2016/03/07 09:15:36 UTC

svn commit: r1733876 - in /maven/plugins/trunk/maven-resources-plugin: ./ src/it/include-git-ignore/ src/it/include-git-ignore/src/ src/it/include-git-ignore/src/main/ src/it/include-git-ignore/src/main/resources/ src/main/java/org/apache/maven/plugins...

Author: khmarbaise
Date: Mon Mar  7 08:15:35 2016
New Revision: 1733876

URL: http://svn.apache.org/viewvc?rev=1733876&view=rev
Log:
[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.

Added:
    maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/
    maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/pom.xml
    maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/setup.bsh
    maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/src/
    maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/src/main/
    maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/src/main/resources/
    maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/verify.bsh
Modified:
    maven/plugins/trunk/maven-resources-plugin/pom.xml
    maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java

Modified: maven/plugins/trunk/maven-resources-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/pom.xml?rev=1733876&r1=1733875&r2=1733876&view=diff
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-resources-plugin/pom.xml Mon Mar  7 08:15:35 2016
@@ -169,6 +169,7 @@ under the License.
               <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 @@ under the License.
           </plugins>
         </pluginManagement>
         <plugins>
+          <!--
+           ! Why is the following needed?
+          -->
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-jar-plugin</artifactId>

Added: maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/pom.xml?rev=1733876&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/pom.xml (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/pom.xml Mon Mar  7 08:15:35 2016
@@ -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>

Added: maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/setup.bsh?rev=1733876&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/setup.bsh (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/setup.bsh Mon Mar  7 08:15:35 2016
@@ -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;

Added: maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/verify.bsh?rev=1733876&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/verify.bsh (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/it/include-git-ignore/verify.bsh Mon Mar  7 08:15:35 2016
@@ -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;

Modified: maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java?rev=1733876&r1=1733875&r2=1733876&view=diff
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java (original)
+++ maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugins/resources/ResourcesMojo.java Mon Mar  7 08:15:35 2016
@@ -204,6 +204,36 @@ public class ResourcesMojo
     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 @@ public class ResourcesMojo
             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 );