LUCENE-9474: make externalTool a function and add a build-stopping message on Windows for snowball generator.

This commit is contained in:
Dawid Weiss 2020-08-30 17:10:18 +02:00
parent def82ab556
commit d847f40237
7 changed files with 19 additions and 17 deletions

View File

@ -90,12 +90,12 @@ ext {
"flexmark": "0.61.24",
]
// read some external tool locations from system props
externalToolExecutables = [
"python3": propertyOrDefault('python3.exe', 'python3'),
"python2": propertyOrDefault('python2.exe', 'python2'),
"perl": propertyOrDefault('perl.exe', 'perl'),
]
// Allow definiting external tool locations using system props.
externalTool = { name ->
def resolved = propertyOrDefault("${name}.exe", name as String)
logger.info("External tool '${name}' resolved to: ${resolved}")
return resolved
}
}
// Include smaller chunks configuring dedicated build areas.

View File

@ -54,7 +54,7 @@ class ChangesToHtmlTask extends DefaultTask {
def toHtml(File versionsFile) {
def output = new ByteArrayOutputStream()
def result = project.exec {
executable project.externalToolExecutables["perl"]
executable project.externalTool("perl")
standardInput changesFile.newInputStream()
standardOutput project.file("${targetDir.get().getAsFile()}/Changes.html").newOutputStream()
errorOutput = output

View File

@ -149,7 +149,7 @@ configure(project(":lucene:analysis:common")) {
def target = file('src/java/org/apache/lucene/analysis/charfilter/HTMLCharacterEntities.jflex')
target.withOutputStream { output ->
project.exec {
executable = project.externalToolExecutables["python2"]
executable = project.externalTool("python2")
workingDir = target.parentFile
standardOutput = output
args += [

View File

@ -15,6 +15,8 @@
* limitations under the License.
*/
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: "de.undercouch.download"
configure(rootProject) {
@ -99,8 +101,12 @@ configure(project(":lucene:analysis:common")) {
dependsOn downloadSnowballData
doLast {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
throw GradleException("Snowball generation does not work on Windows, use a platform where bash is available.")
}
project.exec {
executable "bash" // TODO: does not work with windows, use project.externalToolExecutables[] instead
executable "bash"
args = [snowballScript, snowballStemmerDir, snowballWebsiteDir, snowballDataDir, projectDir]
}
}

View File

@ -57,7 +57,7 @@ configure(project(":lucene:core")) {
logger.lifecycle("Executing: ${prog} in ${targetDir}")
project.exec {
workingDir targetDir
executable project.externalToolExecutables["python3"]
executable project.externalTool("python3")
args = ['-B', "${prog}"]
}
}
@ -82,7 +82,7 @@ configure(project(":lucene:core")) {
['True', 'False'].each { transpose ->
project.exec {
workingDir targetDir
executable project.externalToolExecutables["python3"]
executable project.externalTool("python3")
args = ['-B', 'createLevAutomata.py', num, transpose, "${momanDir}/finenight/python"]
}
}

View File

@ -16,7 +16,6 @@
*/
configure(rootProject) {
task checkBrokenLinks {
group 'Verification'
description 'Check broken links in the entire documentation'
@ -24,13 +23,10 @@ configure(rootProject) {
dependsOn ':lucene:checkBrokenLinks'
dependsOn ':solr:checkBrokenLinks'
}
}
configure(subprojects.findAll { it.path in [':lucene', ':solr'] }) {
task checkBrokenLinks(type: CheckBrokenLinksTask, 'dependsOn': 'documentation')
check.dependsOn checkBrokenLinks
}
@ -51,7 +47,7 @@ class CheckBrokenLinksTask extends DefaultTask {
def result
outputFile.withOutputStream { output ->
result = project.exec {
executable project.externalToolExecutables["python3"]
executable project.externalTool("python3")
ignoreExitValue = true
standardOutput = output
errorOutput = output

View File

@ -100,7 +100,7 @@ class CheckMissingDocsTask extends DefaultTask {
def checkMissingJavadocs(File dir, String level) {
def output = new ByteArrayOutputStream()
def result = project.exec {
executable project.externalToolExecutables["python3"]
executable project.externalTool("python3")
ignoreExitValue = true
standardOutput = output
errorOutput = output