mirror of
https://github.com/apache/lucene.git
synced 2025-02-07 10:38:40 +00:00
On newer linux distros, at least, 'python' now means python3. So we can't rely on what version of python it will invoke (at least for a few years). For example in Fedora Linux: https://fedoraproject.org/wiki/Changes/Python_means_Python3 For python2.x code, explicitly call 'python2.7' and for python3.x code, explicitly call 'python3'. Ant variable names are cleaned up, e.g. 'python.exe' is renamed to 'python2.exe' and 'python32.exe' is renamed to 'python3.exe'. This also makes it easy to identify remaining python 2.x code that should be migrated to python 3.x
99 lines
3.0 KiB
Groovy
99 lines
3.0 KiB
Groovy
/*
|
|
* 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) {
|
|
ext {
|
|
momanDir = file("${buildDir}/moman")
|
|
}
|
|
|
|
task moman() {
|
|
description "Regenerate Moman-based sources for ...lucene/util/automaton and ...lucene/util/packed."
|
|
group "generation"
|
|
|
|
dependsOn ":lucene:core:utilGenPacked"
|
|
dependsOn ":lucene:core:utilGenLev"
|
|
}
|
|
|
|
task installMoman(type: Download) {
|
|
def momanZip = file("${momanDir}/moman.zip")
|
|
|
|
src "https://bitbucket.org/jpbarrette/moman/get/5c5c2a1e4dea.zip"
|
|
dest momanZip
|
|
onlyIfModified true
|
|
|
|
doLast {
|
|
ant.unzip(src: momanZip, dest: momanDir, overwrite: "true") {
|
|
ant.cutdirsmapper(dirs: "1")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
configure(project(":lucene:core")) {
|
|
task utilGenPacked(dependsOn: rootProject.installMoman) {
|
|
description "Regenerate util/PackedBulkOperationsPacked*.java and Packed64SingleBlock.java"
|
|
group "generation"
|
|
|
|
doLast {
|
|
def targetDir = file("src/java/org/apache/lucene/util/packed")
|
|
|
|
['gen_BulkOperation.py', 'gen_Packed64SingleBlock.py'].each { prog ->
|
|
logger.lifecycle("Executing: ${prog} in ${targetDir}")
|
|
project.exec {
|
|
workingDir targetDir
|
|
executable "python2.7"
|
|
args = ['-B', "${prog}"]
|
|
}
|
|
}
|
|
// Correct line endings for Windows.
|
|
project.ant.fixcrlf(
|
|
srcDir: targetDir,
|
|
includes: 'Packed64SingleBlock.java, BulkOperation*.java',
|
|
encoding: 'UTF-8',
|
|
eol: 'lf'
|
|
)
|
|
}
|
|
}
|
|
|
|
task utilGenLev(dependsOn: rootProject.installMoman) {
|
|
description "Regenerate util/automaton Lev*ParametricDescription.java"
|
|
group "generation"
|
|
|
|
doLast {
|
|
def targetDir = file("src/java/org/apache/lucene/util/automaton")
|
|
|
|
['1', '2'].each { num ->
|
|
['True', 'False'].each { transpose ->
|
|
project.exec {
|
|
workingDir targetDir
|
|
executable "python2.7"
|
|
args = ['-B', 'createLevAutomata.py', num, transpose, "${momanDir}/finenight/python"]
|
|
}
|
|
}
|
|
}
|
|
project.ant.fixcrlf(
|
|
srcDir: targetDir,
|
|
includes: '*ParametricDescription.java',
|
|
encoding: 'UTF-8',
|
|
eol: 'lf'
|
|
)
|
|
}
|
|
}
|
|
}
|