mirror of https://github.com/apache/lucene.git
LUCENE-9546: Configure Nori and Kuromoji generation lazily when java plugin is applied to the projects
This commit is contained in:
parent
8b329a09c2
commit
3ae0b50646
|
@ -30,102 +30,103 @@ def recompileDictionary(project, dictionaryName, Closure closure) {
|
|||
}
|
||||
|
||||
configure(project(":lucene:analysis:kuromoji")) {
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: "de.undercouch.download"
|
||||
|
||||
ext {
|
||||
targetDir = file("src/resources")
|
||||
}
|
||||
plugins.withType(JavaPlugin) {
|
||||
ext {
|
||||
targetDir = file("src/resources")
|
||||
}
|
||||
|
||||
task deleteDictionaryData() {
|
||||
// There should really be just one but since we don't know which
|
||||
// one it'll be, let's process all of them.
|
||||
doFirst {
|
||||
sourceSets.main.resources.srcDirs.each { location ->
|
||||
delete fileTree(dir: location, include: "org/apache/lucene/analysis/ja/dict/*.dat")
|
||||
task deleteDictionaryData() {
|
||||
// There should really be just one but since we don't know which
|
||||
// one it'll be, let's process all of them.
|
||||
doFirst {
|
||||
sourceSets.main.resources.srcDirs.each { location ->
|
||||
delete fileTree(dir: location, include: "org/apache/lucene/analysis/ja/dict/*.dat")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task compileMecab(type: Download) {
|
||||
description "Recompile dictionaries from Mecab data."
|
||||
group "generation"
|
||||
task compileMecab(type: Download) {
|
||||
description "Recompile dictionaries from Mecab data."
|
||||
group "generation"
|
||||
|
||||
dependsOn deleteDictionaryData
|
||||
dependsOn sourceSets.main.runtimeClasspath
|
||||
dependsOn deleteDictionaryData
|
||||
dependsOn sourceSets.main.runtimeClasspath
|
||||
|
||||
def dictionaryName = "mecab-ipadic-2.7.0-20070801"
|
||||
def dictionarySource = "https://jaist.dl.sourceforge.net/project/mecab/mecab-ipadic/2.7.0-20070801/${dictionaryName}.tar.gz"
|
||||
def dictionaryFile = file("${buildDir}/generate/${dictionaryName}.tar.gz")
|
||||
def unpackedDir = file("${buildDir}/generate/${dictionaryName}")
|
||||
def dictionaryName = "mecab-ipadic-2.7.0-20070801"
|
||||
def dictionarySource = "https://jaist.dl.sourceforge.net/project/mecab/mecab-ipadic/2.7.0-20070801/${dictionaryName}.tar.gz"
|
||||
def dictionaryFile = file("${buildDir}/generate/${dictionaryName}.tar.gz")
|
||||
def unpackedDir = file("${buildDir}/generate/${dictionaryName}")
|
||||
|
||||
src dictionarySource
|
||||
dest dictionaryFile
|
||||
onlyIfModified true
|
||||
src dictionarySource
|
||||
dest dictionaryFile
|
||||
onlyIfModified true
|
||||
|
||||
doLast {
|
||||
// Unpack the downloaded archive.
|
||||
delete unpackedDir
|
||||
ant.untar(src: dictionaryFile, dest: unpackedDir, compression: "gzip") {
|
||||
ant.cutdirsmapper(dirs: "1")
|
||||
doLast {
|
||||
// Unpack the downloaded archive.
|
||||
delete unpackedDir
|
||||
ant.untar(src: dictionaryFile, dest: unpackedDir, compression: "gzip") {
|
||||
ant.cutdirsmapper(dirs: "1")
|
||||
}
|
||||
|
||||
// Apply patch via local git.
|
||||
project.exec {
|
||||
workingDir = unpackedDir
|
||||
executable "git" // TODO: better use jgit to apply patch, this is not portable!!!
|
||||
args += [
|
||||
"apply",
|
||||
file("src/tools/patches/Noun.proper.csv.patch").absolutePath
|
||||
]
|
||||
}
|
||||
|
||||
// Compile the dictionary
|
||||
recompileDictionary(project, dictionaryName, {
|
||||
args += [
|
||||
"ipadic",
|
||||
unpackedDir,
|
||||
targetDir,
|
||||
"euc-jp",
|
||||
false
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// Apply patch via local git.
|
||||
project.exec {
|
||||
workingDir = unpackedDir
|
||||
executable "git" // TODO: better use jgit to apply patch, this is not portable!!!
|
||||
args += [
|
||||
"apply",
|
||||
file("src/tools/patches/Noun.proper.csv.patch").absolutePath
|
||||
]
|
||||
}
|
||||
|
||||
// Compile the dictionary
|
||||
recompileDictionary(project, dictionaryName, {
|
||||
args += [
|
||||
"ipadic",
|
||||
unpackedDir,
|
||||
targetDir,
|
||||
"euc-jp",
|
||||
false
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
task compileNaist(type: Download) {
|
||||
description "Recompile dictionaries from Naist data."
|
||||
group "generation"
|
||||
task compileNaist(type: Download) {
|
||||
description "Recompile dictionaries from Naist data."
|
||||
group "generation"
|
||||
|
||||
dependsOn deleteDictionaryData
|
||||
dependsOn sourceSets.main.runtimeClasspath
|
||||
dependsOn deleteDictionaryData
|
||||
dependsOn sourceSets.main.runtimeClasspath
|
||||
|
||||
def dictionaryName = "mecab-naist-jdic-0.6.3b-20111013"
|
||||
def dictionarySource = "https://rwthaachen.dl.osdn.jp/naist-jdic/53500/${dictionaryName}.tar.gz"
|
||||
def dictionaryFile = file("${buildDir}/generate/${dictionaryName}.tar.gz")
|
||||
def unpackedDir = file("${buildDir}/generate/${dictionaryName}")
|
||||
def dictionaryName = "mecab-naist-jdic-0.6.3b-20111013"
|
||||
def dictionarySource = "https://rwthaachen.dl.osdn.jp/naist-jdic/53500/${dictionaryName}.tar.gz"
|
||||
def dictionaryFile = file("${buildDir}/generate/${dictionaryName}.tar.gz")
|
||||
def unpackedDir = file("${buildDir}/generate/${dictionaryName}")
|
||||
|
||||
src dictionarySource
|
||||
dest dictionaryFile
|
||||
onlyIfModified true
|
||||
src dictionarySource
|
||||
dest dictionaryFile
|
||||
onlyIfModified true
|
||||
|
||||
doLast {
|
||||
// Unpack the downloaded archive.
|
||||
delete unpackedDir
|
||||
ant.untar(src: dictionaryFile, dest: unpackedDir, compression: "gzip") {
|
||||
ant.cutdirsmapper(dirs: "1")
|
||||
doLast {
|
||||
// Unpack the downloaded archive.
|
||||
delete unpackedDir
|
||||
ant.untar(src: dictionaryFile, dest: unpackedDir, compression: "gzip") {
|
||||
ant.cutdirsmapper(dirs: "1")
|
||||
}
|
||||
|
||||
// Compile the dictionary
|
||||
recompileDictionary(project, dictionaryName, {
|
||||
args += [
|
||||
"ipadic",
|
||||
unpackedDir,
|
||||
targetDir,
|
||||
"euc-jp",
|
||||
false
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// Compile the dictionary
|
||||
recompileDictionary(project, dictionaryName, {
|
||||
args += [
|
||||
"ipadic",
|
||||
unpackedDir,
|
||||
targetDir,
|
||||
"euc-jp",
|
||||
false
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,55 +30,56 @@ def recompileDictionary(project, dictionaryName, Closure closure) {
|
|||
}
|
||||
|
||||
configure(project(":lucene:analysis:nori")) {
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: "de.undercouch.download"
|
||||
|
||||
ext {
|
||||
targetDir = file("src/resources")
|
||||
}
|
||||
plugins.withType(JavaPlugin) {
|
||||
ext {
|
||||
targetDir = file("src/resources")
|
||||
}
|
||||
|
||||
task deleteDictionaryData() {
|
||||
// There should really be just one but since we don't know which
|
||||
// one it'll be, let's process all of them.
|
||||
doFirst {
|
||||
sourceSets.main.resources.srcDirs.each { location ->
|
||||
delete fileTree(dir: location, include: "org/apache/lucene/analysis/ko/dict/*.dat")
|
||||
task deleteDictionaryData() {
|
||||
// There should really be just one but since we don't know which
|
||||
// one it'll be, let's process all of them.
|
||||
doFirst {
|
||||
sourceSets.main.resources.srcDirs.each { location ->
|
||||
delete fileTree(dir: location, include: "org/apache/lucene/analysis/ko/dict/*.dat")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task compileMecabKo(type: Download) {
|
||||
description "Recompile dictionaries from Mecab-Ko data."
|
||||
group "generation"
|
||||
task compileMecabKo(type: Download) {
|
||||
description "Recompile dictionaries from Mecab-Ko data."
|
||||
group "generation"
|
||||
|
||||
dependsOn deleteDictionaryData
|
||||
dependsOn sourceSets.main.runtimeClasspath
|
||||
dependsOn deleteDictionaryData
|
||||
dependsOn sourceSets.main.runtimeClasspath
|
||||
|
||||
def dictionaryName = "mecab-ko-dic-2.0.3-20170922"
|
||||
def dictionarySource = "https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/${dictionaryName}.tar.gz"
|
||||
def dictionaryFile = file("${buildDir}/generate/${dictionaryName}.tar.gz")
|
||||
def unpackedDir = file("${buildDir}/generate/${dictionaryName}")
|
||||
def dictionaryName = "mecab-ko-dic-2.0.3-20170922"
|
||||
def dictionarySource = "https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/${dictionaryName}.tar.gz"
|
||||
def dictionaryFile = file("${buildDir}/generate/${dictionaryName}.tar.gz")
|
||||
def unpackedDir = file("${buildDir}/generate/${dictionaryName}")
|
||||
|
||||
src dictionarySource
|
||||
dest dictionaryFile
|
||||
onlyIfModified true
|
||||
src dictionarySource
|
||||
dest dictionaryFile
|
||||
onlyIfModified true
|
||||
|
||||
doLast {
|
||||
// Unpack the downloaded archive.
|
||||
delete unpackedDir
|
||||
ant.untar(src: dictionaryFile, dest: unpackedDir, compression: "gzip") {
|
||||
ant.cutdirsmapper(dirs: "1")
|
||||
doLast {
|
||||
// Unpack the downloaded archive.
|
||||
delete unpackedDir
|
||||
ant.untar(src: dictionaryFile, dest: unpackedDir, compression: "gzip") {
|
||||
ant.cutdirsmapper(dirs: "1")
|
||||
}
|
||||
|
||||
// Compile the dictionary
|
||||
recompileDictionary(project, dictionaryName, {
|
||||
args += [
|
||||
unpackedDir,
|
||||
targetDir,
|
||||
"utf-8",
|
||||
false
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// Compile the dictionary
|
||||
recompileDictionary(project, dictionaryName, {
|
||||
args += [
|
||||
unpackedDir,
|
||||
targetDir,
|
||||
"utf-8",
|
||||
false
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue