Better annotation processing

This commit is contained in:
Anuken
2020-01-24 18:31:54 -05:00
parent 83f44abb5a
commit aefc4ed83c
17 changed files with 266 additions and 304 deletions

View File

@@ -132,6 +132,19 @@ allprojects{
props.store(pfile.newWriter(), "Autogenerated file. Do not modify.")
}
}
writeProcessors = {
def processorFile = new File(rootDir, "annotations/src/main/resources/META-INF/services/javax.annotation.processing.Processor")
def text = new StringBuilder()
def files = new File(rootDir, "annotations/src/main/java")
files.eachFileRecurse(groovy.io.FileType.FILES){ file ->
if(file.name.endsWith(".java") && (file.text.contains(" extends BaseProcessor") || (file.text.contains(" extends AbstractProcessor") && !file.text.contains("abstract class")))){
text.append(file.path.substring(files.path.length() + 1)).append("\n")
}
}
processorFile.text = text.toString().replace(".java", "").replace("/", ".").replace("\\", ".")
}
}
repositories{
@@ -205,6 +218,7 @@ project(":core"){
outputs.upToDateWhen{ false }
generateLocales()
writeVersion()
writeProcessors()
}
task copyChangelog{
@@ -229,31 +243,6 @@ project(":core"){
}
dependencies{
if(System.properties["user.name"] == "anuke"){
task cleanGen{
doFirst{
delete{
delete "../core/src/mindustry/gen/"
}
}
}
task copyGen{
doLast{
copy{
from("../core/build/generated/sources/annotationProcessor/java/main/mindustry/gen"){
include "**/*.java"
}
into "../core/src/mindustry/gen"
}
}
}
compileJava.dependsOn(cleanGen)
compileJava.finalizedBy(copyGen)
}
compileJava.dependsOn(preGen)
compile "org.lz4:lz4-java:1.4.1"