Correct snowball download/unzip sequence to be always consistent.

This commit is contained in:
Dawid Weiss 2021-03-24 15:16:12 +01:00
parent 34f589b0aa
commit bb5db1e16d
1 changed files with 17 additions and 13 deletions

View File

@ -38,19 +38,27 @@ configure(project(":lucene:analysis:common")) {
snowballScript = rootProject.file("gradle/generation/snowball.sh")
}
def unpackFromZip = { zipFile, targetDir ->
project.sync {
from(zipTree(zipFile), {
eachFile { fcd ->
fcd.relativePath = new RelativePath(true, fcd.relativePath.segments.drop(1))
}
})
into targetDir
}
}
// downloads snowball stemmers (or use cached copy)
task downloadSnowballStemmers(type: Download) {
inputs.file(snowballPatchFile)
src "https://github.com/snowballstem/snowball/archive/${snowballStemmerCommit}.zip"
def snowballStemmerZip = file("${snowballStemmerDir}.zip")
dest snowballStemmerZip
dest file("${snowballStemmerDir}.zip")
overwrite false
tempAndMove true
doLast {
ant.unzip(src: snowballStemmerZip, dest: snowballStemmerDir, overwrite: "true") {
ant.cutdirsmapper(dirs: "1")
}
unpackFromZip(dest, snowballStemmerDir)
ant.patch(patchfile: snowballPatchFile, dir: snowballStemmerDir, strip: "1", failonerror: true)
}
}
@ -64,9 +72,7 @@ configure(project(":lucene:analysis:common")) {
tempAndMove true
doLast {
ant.unzip(src: snowballWebsiteZip, dest: snowballWebsiteDir, overwrite: "true") {
ant.cutdirsmapper(dirs: "1")
}
unpackFromZip(snowballWebsiteZip, snowballWebsiteDir)
}
}
@ -79,9 +85,7 @@ configure(project(":lucene:analysis:common")) {
tempAndMove true
doLast {
ant.unzip(src: snowballDataZip, dest: snowballDataDir, overwrite: "true") {
ant.cutdirsmapper(dirs: "1")
}
unpackFromZip(snowballDataZip, snowballDataDir)
}
}
@ -90,11 +94,11 @@ configure(project(":lucene:analysis:common")) {
description "Regenerates snowball stemmers."
group "generation"
// Don't even bother adding dependencies.
// Don't even bother adding dependencies on Windows.
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
doFirst {
// Just emit a big fat error message but don't fail the build.
logger.error("Snowball generation does not work on Windows, use a platform where bash is available.")
logger.error("Snowball generation does not work on Windows (patch and bash must be available).")
}
} else {
dependsOn downloadSnowballStemmers