You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2020/02/11 23:56:26 UTC
[lucene-solr] branch master updated: LUCENE-9134: Port
ant-regenerate tasks to Gradle build (util and packed) (#1251)
This is an automated email from the ASF dual-hosted git repository.
erick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new f9357ab LUCENE-9134: Port ant-regenerate tasks to Gradle build (util and packed) (#1251)
f9357ab is described below
commit f9357ab0d210302aacaea9ac8c4d8f4d59d1585f
Author: Erick Erickson <er...@gmail.com>
AuthorDate: Tue Feb 11 18:56:11 2020 -0500
LUCENE-9134: Port ant-regenerate tasks to Gradle build (util and packed) (#1251)
* LUCENE-9134: Port ant-regenerate tasks to Gradle build
---
build.gradle | 2 +
gradle/generation/util.gradle | 100 +++++++++++++++++++++
lucene/core/build.xml | 4 +
.../lucene/util/automaton/createLevAutomata.py | 19 ++--
4 files changed, 117 insertions(+), 8 deletions(-)
diff --git a/build.gradle b/build.gradle
index 5db7b02..1af14b8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -23,6 +23,7 @@ plugins {
id "com.palantir.consistent-versions" version "1.14.0"
id 'de.thetaphi.forbiddenapis' version '2.7' apply false
id "org.owasp.dependencycheck" version "5.3.0"
+ id "de.undercouch.download" version "4.0.2" apply false
}
// Project version and main properties. Applies to all projects.
@@ -83,6 +84,7 @@ apply from: file('gradle/validation/owasp-dependency-check.gradle')
// Source or data regeneration tasks
apply from: file('gradle/generation/jflex.gradle')
apply from: file('gradle/generation/javacc.gradle')
+apply from: file('gradle/generation/util.gradle')
// Additional development aids.
apply from: file('gradle/maven/maven-local.gradle')
diff --git a/gradle/generation/util.gradle b/gradle/generation/util.gradle
new file mode 100644
index 0000000..7719d7a
--- /dev/null
+++ b/gradle/generation/util.gradle
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+apply plugin: "de.undercouch.download"
+
+configure(rootProject) {
+ configurations {
+ utilgen
+ }
+
+ task utilgen {
+ description "Regenerate sources for ...lucene/util/automaton and ...lucene/util/packed."
+ group "generation"
+
+ dependsOn ":lucene:core:utilGenPacked"
+ dependsOn ":lucene:core:utilGenLev"
+ }
+}
+
+def momanDir = new File(buildDir, "moman").getAbsolutePath()
+task installMoman(type: Download) {
+
+ def momanZip = new File(momanDir, "moman.zip").getAbsolutePath()
+
+ src "https://bitbucket.org/jpbarrette/moman/get/5c5c2a1e4dea.zip"
+ dest momanZip
+ onlyIfModified true
+
+ doLast {
+ logger.lifecycle("Downloading moman to: ${buildDir}")
+ ant.unzip(src: momanZip, dest: momanDir, overwrite: "true") {
+ ant.cutdirsmapper(dirs: "1")
+ }
+ }
+}
+
+configure(project(":lucene:core")) {
+ task utilGenPacked(dependsOn: installMoman) {
+ description "Regenerate util/PackedBulkOperationsPacked*.java and Packed64SingleBlock.java"
+ group "generation"
+
+ def workDir = "src/java/org/apache/lucene/util/packed"
+
+ doLast {
+ ['gen_BulkOperation.py', 'gen_Packed64SingleBlock.py'].each { prog ->
+ logger.lifecycle("Executing: ${prog} in ${workDir}")
+ project.exec {
+ workingDir workDir
+ executable "python"
+ args = ['-B', "${prog}"]
+ }
+ }
+ // Correct line endings for Windows.
+ project.ant.fixcrlf(
+ srcDir: workDir,
+ includes: 'Packed64SingleBlock.java, BulkOperation*.java',
+ encoding: 'UTF-8',
+ eol: 'lf'
+ )
+ }
+ }
+
+ task utilGenLev(dependsOn: installMoman) {
+ description "Regenerate util/automaton Lev*ParametricDescription.java"
+ group "generation"
+
+ doLast {
+ def workDir = 'src/java/org/apache/lucene/util/automaton'
+
+ ['1', '2'].each { num ->
+ ['True', 'False'].each { transpose ->
+ project.exec {
+ workingDir workDir
+ executable "python"
+ args = ['-B', 'createLevAutomata.py', num, transpose, "${momanDir}/finenight/python"]
+ }
+ }
+ }
+ project.ant.fixcrlf(
+ srcDir: workDir,
+ includes: '*ParametricDescription.java',
+ encoding: 'UTF-8',
+ eol: 'lf'
+ )
+ }
+ }
+}
diff --git a/lucene/core/build.xml b/lucene/core/build.xml
index ce73bb3..be42c56 100644
--- a/lucene/core/build.xml
+++ b/lucene/core/build.xml
@@ -75,6 +75,8 @@
<arg value="createLevAutomata.py"/>
<arg value="@{n}"/>
<arg value="True"/>
+ <!-- Hack while transitioning to Gradle build in 9.0 -->
+ <arg value="../../../../../../../../build/core/moman/finenight/python"/>
</exec>
<exec dir="src/java/org/apache/lucene/util/automaton"
executable="${python.exe}" failonerror="true">
@@ -83,6 +85,8 @@
<arg value="createLevAutomata.py"/>
<arg value="@{n}"/>
<arg value="False"/>
+ <!-- Hack while transitioning to Gradle build in 9.0 -->
+ <arg value="../../../../../../../../build/core/moman/finenight/python"/>
</exec>
<fixcrlf srcdir="src/java/org/apache/lucene/util/automaton" includes="*ParametricDescription.java" encoding="UTF-8"/>
</sequential>
diff --git a/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py b/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py
index bd0ab45..529baef 100644
--- a/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py
+++ b/lucene/core/src/java/org/apache/lucene/util/automaton/createLevAutomata.py
@@ -21,12 +21,7 @@
import math
import os
import sys
-# sys.path.insert(0, 'moman/finenight/python')
-sys.path.insert(0, '../../../../../../../../build/core/moman/finenight/python')
-try:
- from possibleStates import genTransitions
-except ImportError:
- from finenight.possibleStates import genTransitions
+
MODE = 'array'
PACKED = True
@@ -96,9 +91,9 @@ def charVarNumber(charVar):
def main():
- if len(sys.argv) != 3:
+ if len(sys.argv) != 4:
print
- print 'Usage: python -u %s N <True/False>' % sys.argv[0]
+ print 'Usage: python -u %s N <True/False> path_to_moman_dir' % sys.argv[0]
print
print 'NOTE: the resulting .java file is created in the current working dir!'
print
@@ -108,6 +103,14 @@ def main():
transpose = (sys.argv[2] == "True")
+ sys.path.insert(0, sys.argv[3])
+
+ try:
+ from possibleStates import genTransitions
+ except ImportError:
+ from finenight.possibleStates import genTransitions
+
+
tables = genTransitions(n, transpose)
stateMap = {}