Created
April 14, 2017 10:01
-
-
Save tauty/56cb67506013536fe976fcea0fbce3c6 to your computer and use it in GitHub Desktop.
The build script which allows you to develop lombok extension easily.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is based on a question of StackOverflow below: | |
// http://stackoverflow.com/questions/35550460/writing-custom-lombok-annotation-handlers | |
group 'com.github.tauty' | |
version '1.0-SNAPSHOT' | |
apply plugin: 'java' | |
sourceCompatibility = 1.8 | |
repositories { | |
jcenter() | |
} | |
configurations { | |
lombok | |
compileOnly | |
} | |
def unpackedAndRenamedLombokDir = file("$buildDir/lombok") | |
task unpackAndRenameLombok { | |
inputs.files configurations.lombok | |
outputs.dir unpackedAndRenamedLombokDir | |
doFirst { | |
mkdir unpackedAndRenamedLombokDir | |
delete unpackedAndRenamedLombokDir.listFiles() | |
} | |
doLast { | |
copy { | |
from zipTree(configurations.lombok.singleFile) | |
into unpackedAndRenamedLombokDir | |
rename "(.*)[.]SCL[.]lombok", '$1.class' | |
} | |
} | |
} | |
sourceSets { | |
main { | |
compileClasspath += configurations.compileOnly | |
output.dir(unpackedAndRenamedLombokDir, builtBy: unpackAndRenameLombok) | |
} | |
} | |
def classFilesDir = file("$buildDir/classes/main") | |
tasks.compileJava { | |
dependsOn unpackAndRenameLombok | |
doLast { | |
copy { | |
from classFilesDir | |
into unpackedAndRenamedLombokDir | |
include '**/handlers/*.class' | |
rename "(.*)[.]class", '$1.SCL.lombok' | |
} | |
copy { | |
from classFilesDir | |
into unpackedAndRenamedLombokDir | |
exclude '**/handlers/*.class' | |
} | |
} | |
doLast { | |
FileTree tree = fileTree(dir: classFilesDir | |
,include: '**/handlers/*.class' | |
,exclude: '**/handlers/*$*.class') | |
def handlerFile = file(unpackedAndRenamedLombokDir.path + '/META-INF/services/lombok.javac.JavacAnnotationHandler') | |
tree.each {File file -> | |
def className = file.path.substring(classFilesDir.path.length() + 1).replace('/', '.') | |
handlerFile << className.replace('.class', '') + '\n' | |
} | |
} | |
} | |
dependencies { | |
compile files("${System.properties['java.home']}/../lib/tools.jar") | |
compile "org.eclipse.jdt:org.eclipse.jdt.core:3.10.0" | |
compile 'javax.inject:javax.inject:1' | |
lombok 'org.projectlombok:lombok:1.16.16' | |
compileOnly files(unpackedAndRenamedLombokDir) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a hacker in my area. Finding these files all over in devices. Pcs phones my firestorm. There's hundreds of files with hundreds of folders of I assume different people being hacked. The numbers go into the 30k range. Wth. Why is oracle the creator of some files. They the hackers?