Skip to content

Apache Lucene open-source search software

Correct snowball download/unzip sequence to be always consistent.

Dawid Weissbb5db1e16deb
diff --git a/gradle/generation/snowball.gradle b/gradle/generation/snowball.gradle
index 7a5adf898a8..5f2ff716367 100644
--- a/gradle/generation/snowball.gradle
+++ b/gradle/generation/snowball.gradle
@@ -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