You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by GitBox <gi...@apache.org> on 2017/12/03 11:49:10 UTC

[GitHub] ebarboni closed pull request #252: NETBEANS-134 wip attempt to get ignore from .gitgnore

ebarboni closed pull request #252: NETBEANS-134 wip attempt to get ignore from .gitgnore
URL: https://github.com/apache/incubator-netbeans/pull/252
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/RatGitIgnorePatternSetTask.java b/nbbuild/antsrc/org/netbeans/nbbuild/RatGitIgnorePatternSetTask.java
new file mode 100644
index 000000000..265fee6b2
--- /dev/null
+++ b/nbbuild/antsrc/org/netbeans/nbbuild/RatGitIgnorePatternSetTask.java
@@ -0,0 +1,91 @@
+/**
+ * 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.
+ */
+package org.netbeans.nbbuild;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.PatternSet;
+
+/**
+ *
+ * @author skygo
+ */
+public class RatGitIgnorePatternSetTask extends Task {
+
+    /**
+     * https://issues.apache.org/jira/browse/RAT-171
+     *
+     */
+    private File rootFolder;
+    private String name;
+
+    /**
+     * gitingore file
+     *
+     * @param rootFolder
+     */
+    public void setRootFolder(File rootFolder) {
+        this.rootFolder = rootFolder;
+    }
+
+    /**
+     * name of property to set
+     *
+     * @param name
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public void execute() throws BuildException {
+        List<String> commandAndArgs = new ArrayList<>();
+        commandAndArgs.add("git");
+        commandAndArgs.add("ls-files");
+        commandAndArgs.add("--others");
+        commandAndArgs.add("--ignored");
+        commandAndArgs.add("--exclude-standard");
+        PatternSet ps = new PatternSet();
+        try {
+            Process p = new ProcessBuilder(commandAndArgs).directory(rootFolder).start();
+            try (BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
+                String line;
+                while ((line = r.readLine()) != null) {
+                    // add every non empty line to exclude 
+                    if (!line.trim().isEmpty()) {
+                        PatternSet.NameEntry createExclude = ps.createExclude();
+                        createExclude.setName(line);
+                    }
+                }
+            } catch (IOException ex) {
+                throw new BuildException("Cannot evaluate git information", ex);
+            }
+        } catch (IOException ex) {
+            throw new BuildException("git process issue", ex);
+        }
+
+        getProject().addReference(name, ps);
+    }
+}
diff --git a/nbbuild/build.xml b/nbbuild/build.xml
index 5a0c39c84..90b4242e6 100644
--- a/nbbuild/build.xml
+++ b/nbbuild/build.xml
@@ -2026,6 +2026,8 @@ It is possible to use -Ddebug.port=3234 -Ddebug.pause=y to start the system in d
                 <pathelement location="external/apache-rat-0.12.jar"/>
             </classpath>
         </taskdef>
+        <taskdef name="ratgitignore" classname="org.netbeans.nbbuild.RatGitIgnorePatternSetTask" classpath="${build.ant.classes.dir}"/>
+        <ratgitignore name="git.non.rat" rootFolder="../" />
         <patternset id="non.rat">
             <!--add new one alphabetically-->
             <exclude name="**/*.exists" /> <!--no degree of creativity-->
@@ -2207,6 +2209,7 @@ It is possible to use -Ddebug.port=3234 -Ddebug.pause=y to start the system in d
             <rat:approvedLicense familyName="International Organization for Standardization for SGML"/>
 	    <fileset dir="${nb_all}">
                 <patternset refid="non.rat" />
+                <patternset refid="git.non.rat" />
             </fileset>
         </rat:report>
         <rat:report xmlns:rat="antlib:org.apache.rat.anttasks" format="xml" reportfile="build/rat-report.xml">
@@ -2226,6 +2229,7 @@ It is possible to use -Ddebug.port=3234 -Ddebug.pause=y to start the system in d
             <rat:approvedLicense familyName="WSDL Schema Files" />
 	    <fileset dir="${nb_all}">
                 <patternset refid="non.rat" />
+                <patternset refid="git.non.rat" />
             </fileset>
         </rat:report>
         <taskdef name="rattotest" classname="org.netbeans.nbbuild.RatReportTask" classpath="${build.ant.classes.dir}"/>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services