Skip to content

Instantly share code, notes, and snippets.

@bluepapa32
Created December 24, 2011 07:05
Show Gist options
  • Save bluepapa32/1516658 to your computer and use it in GitHub Desktop.
Save bluepapa32/1516658 to your computer and use it in GitHub Desktop.
Apache Lucene DEMO with Gradle
configurations {
demo
source
}
repositories {
mavenCentral()
}
dependencies {
demo 'org.apache.lucene:lucene-core:3.5.0'
demo 'org.apache.lucene:lucene-demo:3.5.0'
source 'org.apache.lucene:lucene-core:3.5.0:sources'
}
task init {
onlyIf { !file('src').exists() }
doLast {
ant.mkdir(dir: 'src')
ant.unzip(src: configurations.source.singleFile, dest: 'src');
}
}
task index(type: JavaExec, dependsOn init) {
main = 'org.apache.lucene.demo.IndexFiles'
classpath configurations.demo
args '-docs', 'src'
}
tasks.addRule("Pattern: ?<query>") { String taskName ->
if (taskName.startsWith("?")) {
task(taskName, type: JavaExec) {
main = 'org.apache.lucene.demo.SearchFiles'
classpath configurations.demo
args '-query', taskName[1..-1]
args '-paging', project.hasProperty('paging') ? paging : 1000
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment