Skip to content

Instantly share code, notes, and snippets.

@ArneBab
Forked from ivv-private/jdee.gradle
Last active September 2, 2018 11:24
Show Gist options
  • Save ArneBab/fe3fcbcab418d99432d8e8fec8c91545 to your computer and use it in GitHub Desktop.
Save ArneBab/fe3fcbcab418d99432d8e8fec8c91545 to your computer and use it in GitHub Desktop.
jdee.gradle
// use by adding
// apply from:'jdee.gradle'
// to build.gradle
def prj = { project ->
"(jdee-project-file-version" (["1.0"])
"(jdee-set-variables" {
"'(jdee-compile-option-directory" ([project.sourceSets.main.output.classesDir])
"'(jdee-junit-working-directory" ([project.projectDir])
"'(jdee-compile-option-source" {
"'(" (["default"])
}
"'(jdee-compile-option-target" {
"'(" (["default"])
}
"'(jdee-compile-option-command-line-args" {
"'(" (["-source"] + ["${project.sourceCompatibility}"])
}
"'(jdee-sourcepath" {
"'(" (
project.sourceSets.main.allSource.srcDirs
+ project.sourceSets.test.allSource.srcDirs)
}
"'(jdee-global-classpath" {
"'(" (
[] + project.sourceSets.main.output.classesDir
+ project.sourceSets.test.output.classesDir
+ project.sourceSets.main.allSource.srcDirs
+ project.sourceSets.test.allSource.srcDirs
+ (([] as Set) + project.configurations.compile.getFiles()
+ project.configurations.testCompile.getFiles()))
}
}
}
projects {
task("jdee") << {
def output = new File(project.projectDir, "prj.el").newPrintWriter()
try {
prj.delegate = new NodeBuilder() {
def lev = 0
def write = { Object file ->
output.print '\n' + ''.padRight(lev, ' ') + "\"${file}\"".tr('\\', '/')
}
Object createNode(Object name) {
output.print '\n' + ''.padRight(lev++, ' ') + name
return name
}
Object createNode(Object name, Object value) {
createNode(name)
value.each write
return name
}
void nodeCompleted(Object parent, Object child) {
output.print ")"
lev--
}
}
prj(project)
output.close()
} finally {
output.flush()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment