You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2019/05/13 00:28:08 UTC

[lucene-solr] branch jira/SOLR-13452_gradle updated (d08aa9e -> 9cae774)

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

markrmiller pushed a change to branch jira/SOLR-13452_gradle
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from d08aa9e  SOLR-13452: Add logging for check-source-patterns working and exclude .settings and .out eclipse/gralde folders.
     new b973cf1  SOLR-13452: Fix CheckSourcePatterns to throw correct exception type.
     new 9cae774  SOLR-13452: Get basics for unicodeData task working for analysis/common.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 buildSrc/build.gradle                              |  2 +
 .../lucene/gradle/CheckSourcePatterns.groovy       |  3 +-
 .../groovy/org/apache/lucene/gradle/FixCRLF.groovy | 15 +++-
 .../lucene/gradle/GenerateUnicodeData.groovy       | 81 ++++++++++++++--------
 lucene/analysis/common/build.gradle                | 13 ++++
 5 files changed, 81 insertions(+), 33 deletions(-)
 copy lucene/analysis/common/src/tools/groovy/generate-unicode-data.groovy => buildSrc/src/main/groovy/org/apache/lucene/gradle/GenerateUnicodeData.groovy (65%)


[lucene-solr] 01/02: SOLR-13452: Fix CheckSourcePatterns to throw correct exception type.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch jira/SOLR-13452_gradle
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit b973cf19b2baac0a0dcf5277d6d6011c85d8a206
Author: markrmiller <ma...@apache.org>
AuthorDate: Sun May 12 18:23:03 2019 -0500

    SOLR-13452: Fix CheckSourcePatterns to throw correct exception type.
---
 .../main/groovy/org/apache/lucene/gradle/CheckSourcePatterns.groovy    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/buildSrc/src/main/groovy/org/apache/lucene/gradle/CheckSourcePatterns.groovy b/buildSrc/src/main/groovy/org/apache/lucene/gradle/CheckSourcePatterns.groovy
index b673493..afd05de 100644
--- a/buildSrc/src/main/groovy/org/apache/lucene/gradle/CheckSourcePatterns.groovy
+++ b/buildSrc/src/main/groovy/org/apache/lucene/gradle/CheckSourcePatterns.groovy
@@ -30,6 +30,7 @@ import org.gradle.api.DefaultTask
 import org.gradle.api.GradleException
 import org.gradle.api.tasks.InputDirectory
 import org.gradle.api.tasks.TaskAction
+import org.gradle.api.tasks.TaskExecutionException
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 
@@ -114,7 +115,7 @@ class CheckSourcePatterns extends DefaultTask {
     }
     
     if (found) {
-      throw new GradleException(String.format(Locale.ENGLISH, 'Found %d violations in source files (%s).',
+      throw new TaskExecutionException(String.format(Locale.ENGLISH, 'Found %d violations in source files (%s).',
       found, violations.join(', ')))
     }
   }


[lucene-solr] 02/02: SOLR-13452: Get basics for unicodeData task working for analysis/common.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch jira/SOLR-13452_gradle
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 9cae774d1a2c4f1d41e65cfcbbee8be56b0adfe9
Author: markrmiller <ma...@apache.org>
AuthorDate: Sun May 12 19:27:28 2019 -0500

    SOLR-13452: Get basics for unicodeData task working for analysis/common.
---
 buildSrc/build.gradle                              |   2 +
 .../groovy/org/apache/lucene/gradle/FixCRLF.groovy |  15 ++-
 .../lucene/gradle/GenerateUnicodeData.groovy       | 127 +++++++++++++++++++++
 lucene/analysis/common/build.gradle                |  13 +++
 4 files changed, 155 insertions(+), 2 deletions(-)

diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 496df3a..38752d9 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -7,6 +7,7 @@ group = 'org.apache.lucene.gradle'
 
 repositories {
 	jcenter()
+    mavenCentral()
 }
 
 dependencies {
@@ -16,6 +17,7 @@ dependencies {
 	implementation 'org.eclipse.jgit:org.eclipse.jgit:4.6.0.201612231935-r'
 	implementation 'de.thetaphi:forbiddenapis:2.6'
 	implementation 'org.apache.rat:apache-rat:0.11'
+    implementation 'com.ibm.icu:icu4j:62.1'
 
 }
 
diff --git a/buildSrc/src/main/groovy/org/apache/lucene/gradle/FixCRLF.groovy b/buildSrc/src/main/groovy/org/apache/lucene/gradle/FixCRLF.groovy
index 2a868da..acbba4b 100644
--- a/buildSrc/src/main/groovy/org/apache/lucene/gradle/FixCRLF.groovy
+++ b/buildSrc/src/main/groovy/org/apache/lucene/gradle/FixCRLF.groovy
@@ -28,6 +28,8 @@ import org.eclipse.jgit.errors.*;
 import org.gradle.api.DefaultTask
 import org.gradle.api.GradleException
 import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.InputFile
+import org.gradle.api.tasks.Optional
 import org.gradle.api.tasks.OutputFile
 import org.gradle.api.tasks.TaskAction
 
@@ -35,10 +37,16 @@ import javax.inject.Inject
 
 class FixCRLF extends DefaultTask {
   
+  @InputFile
+  @Optional
+  File file
+  
   @Input
+  @Optional
   String sourceDir
 
   @Input
+  @Optional
   String includes
   
   @Input
@@ -46,8 +54,11 @@ class FixCRLF extends DefaultTask {
 
   @TaskAction
   void fixCRLF() {
-    //ant.get(src: sourceUrl, dest: target)
-    ant.fixcrlf(srcdir: sourceDir, includes: includes, encoding: encoding)
+    if (file != null) {
+      ant.fixcrlf(file: file.getAbsolutePath(), encoding: encoding)
+    } else {
+      ant.fixcrlf(srcdir: sourceDir, includes: includes, encoding: encoding)
+    }
   }
 }
 
diff --git a/buildSrc/src/main/groovy/org/apache/lucene/gradle/GenerateUnicodeData.groovy b/buildSrc/src/main/groovy/org/apache/lucene/gradle/GenerateUnicodeData.groovy
new file mode 100644
index 0000000..8e6d50c
--- /dev/null
+++ b/buildSrc/src/main/groovy/org/apache/lucene/gradle/GenerateUnicodeData.groovy
@@ -0,0 +1,127 @@
+package org.apache.lucene.gradle
+/*
+ * 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.lang.invoke.MethodHandles
+ 
+import org.gradle.api.DefaultTask
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.InputDirectory
+import org.gradle.api.tasks.InputFile
+import org.gradle.api.tasks.TaskAction
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import com.ibm.icu.lang.UCharacter
+import com.ibm.icu.util.VersionInfo
+
+
+class GenerateUnicodeData extends DefaultTask {
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass())
+  
+  @InputFile
+  File unicodePropsFile
+  
+  @TaskAction
+  void generate() {
+    def linesep = System.getProperty("line.separator")
+    
+    def appendChar = { StringBuilder sb, int c ->
+      int len = sb.length()
+      if (len != 0) {
+        sb.append(', ')
+      }
+      if (len == 0 || len - sb.lastIndexOf(linesep) > 100) {
+        sb.append(linesep).append('    ')
+      }
+      sb.append(String.format(Locale.ROOT, "0x%04X", c))
+    }
+    
+    def whitespace = new StringBuilder()
+    for (int c = UCharacter.MIN_CODE_POINT; c <= UCharacter.MAX_CODE_POINT; c++) {
+      if (UCharacter.isUWhiteSpace(c)) {
+        appendChar(whitespace, c)
+      }
+    }
+    
+    def icuVersion = VersionInfo.ICU_VERSION.toString()
+    def unicodeVersion = UCharacter.getUnicodeVersion().toString()
+    
+    def code = """
+// DO NOT EDIT THIS FILE! Use "ant unicode-data" to recreate.
+
+/*
+ * 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.apache.lucene.analysis.util;
+
+import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.SparseFixedBitSet;
+
+/**
+ * This file contains unicode properties used by various {@link CharTokenizer}s.
+ * The data was created using ICU4J v${icuVersion}
+ * <p>
+ * Unicode version: ${unicodeVersion}
+ */
+public final class UnicodeProps {
+  private UnicodeProps() {}
+  
+  /** Unicode version that was used to generate this file: {@value} */
+  public static final String UNICODE_VERSION = "${unicodeVersion}";
+  
+  /** Bitset with Unicode WHITESPACE code points. */
+  public static final Bits WHITESPACE = createBits(${whitespace});
+  
+  private static Bits createBits(final int... codepoints) {
+    final int len = codepoints[codepoints.length - 1] + 1;
+    final SparseFixedBitSet bitset = new SparseFixedBitSet(len);
+    for (int i : codepoints) bitset.set(i);
+    return new Bits() {
+      @Override
+      public boolean get(int index) {
+        return index < len && bitset.get(index);
+      }
+      
+      @Override
+      public int length() {
+        return ${String.format(Locale.ROOT, "0x%X", UCharacter.MAX_CODE_POINT)} + 1;
+      }
+    };
+  }
+}
+"""
+    
+    unicodePropsFile.write(code.trim(), 'UTF-8')
+    
+    logger.info("Unicode data written to: " + unicodePropsFile)
+  }
+}
diff --git a/lucene/analysis/common/build.gradle b/lucene/analysis/common/build.gradle
index 25522be..2add51d 100644
--- a/lucene/analysis/common/build.gradle
+++ b/lucene/analysis/common/build.gradle
@@ -21,3 +21,16 @@ dependencies {
   
   testImplementationTran project(':lucene:lucene-test-framework')
 }
+
+
+task unicodeData(type: org.apache.lucene.gradle.GenerateUnicodeData) {
+  unicodePropsFile = new File("${projectDir}/src/java/org/apache/lucene/analysis/util/UnicodeProps.java")
+}
+
+task fixCRLFUnicodeData(type: org.apache.lucene.gradle.FixCRLF) {
+  file = new File("${projectDir}/src/java/org/apache/lucene/analysis/util/UnicodeProps.java")
+  encoding = "UTF-8"
+}
+
+unicodeData.dependsOn fixCRLFUnicodeData
+