diff --git a/gradle/generation/kuromoji.gradle b/gradle/generation/kuromoji.gradle index c865a13eaed..8dc082b233d 100644 --- a/gradle/generation/kuromoji.gradle +++ b/gradle/generation/kuromoji.gradle @@ -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 - ] - }) } } } diff --git a/gradle/generation/nori.gradle b/gradle/generation/nori.gradle index eb6afa153b9..78da8cc2863 100644 --- a/gradle/generation/nori.gradle +++ b/gradle/generation/nori.gradle @@ -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 - ] - }) } } }