You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jl...@apache.org on 2017/09/24 18:09:34 UTC

incubator-netbeans-tools git commit: Adding pattern for BSD license.

Repository: incubator-netbeans-tools
Updated Branches:
  refs/heads/master 97d41efb6 -> 6756d08c0


Adding pattern for BSD license.


Project: http://git-wip-us.apache.org/repos/asf/incubator-netbeans-tools/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-netbeans-tools/commit/6756d08c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-netbeans-tools/tree/6756d08c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-netbeans-tools/diff/6756d08c

Branch: refs/heads/master
Commit: 6756d08c0b7b76295a480b5e0335a86c68ae11c2
Parents: 97d41ef
Author: Jan Lahoda <jl...@netbeans.org>
Authored: Sun Sep 24 18:06:08 2017 +0200
Committer: Jan Lahoda <jl...@netbeans.org>
Committed: Sun Sep 24 18:06:08 2017 +0200

----------------------------------------------------------------------
 convert/src/convert/CategorizeLicenses.java |  6 +--
 convert/src/convert/Convert.java            | 54 +++++++++++++++++-------
 2 files changed, 42 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-netbeans-tools/blob/6756d08c/convert/src/convert/CategorizeLicenses.java
----------------------------------------------------------------------
diff --git a/convert/src/convert/CategorizeLicenses.java b/convert/src/convert/CategorizeLicenses.java
index ee22b8c..1935f72 100644
--- a/convert/src/convert/CategorizeLicenses.java
+++ b/convert/src/convert/CategorizeLicenses.java
@@ -131,7 +131,7 @@ public class CategorizeLicenses {
                         "javx", "c", "h", "cpp", "pass", "hint", "css", "java", "js", "jj");
         enterExtensions(code -> snipLicense(code, "<!--+", "-+->", "^[ \t]*(-[ \t]*)?", CommentType.XML),
                         "html", "xsd", "xsl", "dtd", "settings", "wstcgrp", "wstcref",
-                        "wsgrp", "xml", "xslt");
+                        "wsgrp", "xml", "xslt", "fxml", "wsdl", "sun-resource");
         enterExtensions(code -> snipLicenseBundle(code, "#!.*", "#", CommentType.PROPERTIES), "sh");
         enterExtensions(code -> snipLicenseBundle(code, null, "#", CommentType.PROPERTIES), "properties");
         enterExtensions(code -> snipLicenseBundle(code, null, "rem", CommentType.BAT1), "bat");
@@ -212,9 +212,9 @@ public class CategorizeLicenses {
     }
 
     private static Description createUnifiedDescriptionOrNull(int start, int end, String lic, CommentType commentType) {
-        if (lic != null && lic.contains("CDDL")) {
+        if (lic != null && (lic.contains("CDDL") || lic.contains("Redistribution"))) {
             if (start == (-1)) {
-                System.err.println("!!!");
+                throw new IllegalStateException();
             }
             lic = YEARS_PATTERN.matcher(lic).replaceAll(Matcher.quoteReplacement("<YEARS>"));
             lic = lic.replaceAll("\\Q<p/>\\E", "\n"); //normalize <p/> to newlines

http://git-wip-us.apache.org/repos/asf/incubator-netbeans-tools/blob/6756d08c/convert/src/convert/Convert.java
----------------------------------------------------------------------
diff --git a/convert/src/convert/Convert.java b/convert/src/convert/Convert.java
index d47d9c4..5efa8e8 100644
--- a/convert/src/convert/Convert.java
+++ b/convert/src/convert/Convert.java
@@ -80,6 +80,31 @@ public class Convert {
             "|)" +
             "(\\QIf you wish your version of this file to be governed by only the CDDL or only the GPL Version 2, indicate your decision by adding \"[Contributor] elects to include this software in this distribution under the [CDDL or GPL Version 2] license.\" If you do not indicate a single choice of license, a recipient has the option to distribute your version of this file under either the CDDL, the GPL Version 2 or to extend the choice of license to its licensees as provided above. However, if you add GPL Version 2 code and therefore, elected the GPL Version 2 license, then the option applies only if the new code is made subject to such option by the copyright holder.\\E\\s*)?";
 
+    private static final String LICENSE_INPUT_PATTERN2 =
+            "(" +
+            "\\QCopyright (c) <YEARS>, Oracle. All rights reserved.\\E\\s*" +
+            "|" +
+            "\\QCopyright (c) <YEARS> Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.\\E\\s*" +
+            "|" +
+            "\\QCopyright (c) <YEARS>, Sun Microsystems, Inc. All rights reserved.\\E\\s*" +
+            ")" +
+            "(\\QThis file is available and licensed under the following license:\\E\\s*)?" +
+            "\\QRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\\E\\s*" +
+            "(" +
+            "\\Q* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Oracle nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\\E\\s*" +
+            "|" +
+            "\\Q- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of Oracle Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\\E\\s*" +
+            "|" +
+            "\\Q* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\\E\\s*" +
+            "\\Q* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\\E\\s*" +
+            "\\Q* Neither the name of Sun Microsystems, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\\E\\s*" +
+            "|" +
+            "\\Q* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\\E\\s*" +
+            "\\Q* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\\E\\s*" +
+            "\\Q* Neither the name of Oracle nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\\E\\s*" +
+            ")" +
+            "\\QTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\\E\\s*";
+
     private static final String JAVA_OUTPUT =
             "/**\n" +
             " * Licensed to the Apache Software Foundation (ASF) under one\n" +
@@ -181,7 +206,8 @@ public class Convert {
             System.err.println("Use: Convert <source-directory> [<statistics-file>]");
             return ;
         }
-        Pattern headerPattern = Pattern.compile(LICENSE_INPUT_PATTERN1, Pattern.MULTILINE);
+        Pattern headerPattern1 = Pattern.compile(LICENSE_INPUT_PATTERN1, Pattern.MULTILINE);
+        Pattern headerPattern2 = Pattern.compile(LICENSE_INPUT_PATTERN2, Pattern.MULTILINE);
         Path root = Paths.get(args[0]);
         int[] count = new int[1];
         Set<String> converted = new HashSet<>();
@@ -192,23 +218,21 @@ public class Convert {
                 try {
                     String path = root.relativize(p).toString();
                     String code = new String(Files.readAllBytes(p));
+                    boolean success = false;
+                    CategorizeLicenses.Description lic = CategorizeLicenses.snipUnifiedLicenseOrNull(code, p);
 
-                    if (code.contains("CDDL")) {
-                        boolean success = false;
-                        CategorizeLicenses.Description lic = CategorizeLicenses.snipUnifiedLicenseOrNull(code, p);
-
-                        if (lic != null) {
-                            if (headerPattern.matcher(lic.header).matches()) {
-                                success = fixHeader(p, code, lic);
-                                count[0]++;
-                            }
+                    if (lic != null) {
+                        if (headerPattern1.matcher(lic.header).matches() ||
+                            headerPattern2.matcher(lic.header).matches()) {
+                            success = fixHeader(p, code, lic);
+                            count[0]++;
                         }
+                    }
 
-                        if (success) {
-                            converted.add(path);
-                        } else {
-                            cddlNoRewrite.add(path);
-                        }
+                    if (success) {
+                        converted.add(path);
+                    } else if (code.contains("CDDL")) {
+                        cddlNoRewrite.add(path);
                     } else {
                         noCDDL.add(path);
                     }