Annotation processor cleanup
This commit is contained in:
@@ -14,29 +14,12 @@ import javax.tools.Diagnostic.*;
|
|||||||
import javax.tools.*;
|
import javax.tools.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
|
||||||
@SupportedAnnotationTypes("mindustry.annotations.Annotations.StyleDefaults")
|
@SupportedAnnotationTypes("mindustry.annotations.Annotations.StyleDefaults")
|
||||||
public class AssetsAnnotationProcessor extends AbstractProcessor{
|
public class AssetsAnnotationProcessor extends BaseProcessor{
|
||||||
/** Name of the base package to put all the generated classes. */
|
|
||||||
private static final String packageName = "mindustry.gen";
|
|
||||||
private String path;
|
private String path;
|
||||||
private int round;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void init(ProcessingEnvironment processingEnv){
|
public void process(RoundEnvironment env) throws Exception{
|
||||||
super.init(processingEnv);
|
|
||||||
//put all relevant utils into utils class
|
|
||||||
Utils.typeUtils = processingEnv.getTypeUtils();
|
|
||||||
Utils.elementUtils = processingEnv.getElementUtils();
|
|
||||||
Utils.filer = processingEnv.getFiler();
|
|
||||||
Utils.messager = processingEnv.getMessager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv){
|
|
||||||
if(round++ != 0) return false; //only process 1 round
|
|
||||||
|
|
||||||
try{
|
|
||||||
path = Fi.get(Utils.filer.createResource(StandardLocation.CLASS_OUTPUT, "no", "no")
|
path = Fi.get(Utils.filer.createResource(StandardLocation.CLASS_OUTPUT, "no", "no")
|
||||||
.toUri().toURL().toString().substring(System.getProperty("os.name").contains("Windows") ? 6 : "file:".length()))
|
.toUri().toURL().toString().substring(System.getProperty("os.name").contains("Windows") ? 6 : "file:".length()))
|
||||||
.parent().parent().parent().parent().parent().parent().toString();
|
.parent().parent().parent().parent().parent().parent().toString();
|
||||||
@@ -44,13 +27,7 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
|||||||
|
|
||||||
processSounds("Sounds", path + "/assets/sounds", "arc.audio.Sound");
|
processSounds("Sounds", path + "/assets/sounds", "arc.audio.Sound");
|
||||||
processSounds("Musics", path + "/assets/music", "arc.audio.Music");
|
processSounds("Musics", path + "/assets/music", "arc.audio.Music");
|
||||||
processUI(roundEnv.getElementsAnnotatedWith(StyleDefaults.class));
|
processUI(env.getElementsAnnotatedWith(StyleDefaults.class));
|
||||||
|
|
||||||
return true;
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void processUI(Set<? extends Element> elements) throws Exception{
|
void processUI(Set<? extends Element> elements) throws Exception{
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package mindustry.annotations;
|
||||||
|
|
||||||
|
import javax.annotation.processing.*;
|
||||||
|
import javax.lang.model.*;
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||||
|
public abstract class BaseProcessor extends AbstractProcessor{
|
||||||
|
/** Name of the base package to put all the generated classes. */
|
||||||
|
public static final String packageName = "mindustry.gen";
|
||||||
|
|
||||||
|
private int round;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void init(ProcessingEnvironment processingEnv){
|
||||||
|
super.init(processingEnv);
|
||||||
|
//put all relevant utils into utils class
|
||||||
|
Utils.typeUtils = processingEnv.getTypeUtils();
|
||||||
|
Utils.elementUtils = processingEnv.getElementUtils();
|
||||||
|
Utils.filer = processingEnv.getFiler();
|
||||||
|
Utils.messager = processingEnv.getMessager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv){
|
||||||
|
if(round++ != 0) return false; //only process 1 round
|
||||||
|
try{
|
||||||
|
process(roundEnv);
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void process(RoundEnvironment env) throws Exception;
|
||||||
|
}
|
||||||
@@ -14,23 +14,16 @@ import java.lang.reflect.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.zip.*;
|
import java.util.zip.*;
|
||||||
|
|
||||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
|
||||||
@SupportedAnnotationTypes("mindustry.annotations.Annotations.Serialize")
|
@SupportedAnnotationTypes("mindustry.annotations.Annotations.Serialize")
|
||||||
public class SerializeAnnotationProcessor extends AbstractProcessor{
|
public class SerializeAnnotationProcessor extends BaseProcessor{
|
||||||
/** Target class name. */
|
/** Target class name. */
|
||||||
private static final String className = "Serialization";
|
private static final String className = "Serialization";
|
||||||
/** Name of the base package to put all the generated classes. */
|
/** Name of the base package to put all the generated classes. */
|
||||||
private static final String packageName = "mindustry.gen";
|
|
||||||
private static final String data = "eJztV0tvGzcQvvfQ3zDRIeDCKhsbQVDUsgP5UViH2IHl9BIEBsUdSYxX3C3Jlawm+XH9Z53hUg/bkuOmOfRQwfDuDme++ebBWe6PfwU3/wTwUU2VLJQdSYfDAnWQvxkschjCAUyMzWtPetJikF2nzzG8deXU5OjkW6VvMPTRGVWYP0mgC+W9HGE4Qbp1mEcg0Zo5E9C1sn2AofQYulqj92ZQoAiuxqVc2Loo2iCU03JYWy2PS+v3OndJNF7bDW1rSnk0D3hUD4foDjNRtWGQwU+HQIGZoajAWB+U1VgOYROOZx+Wgm4eMzJ7ghpoyo14Cl5FsQ2I4PsPcE2/XXpssk7kOMw6mEJe9KXxXZu70uTM4Jjz2Hl9CJ79xCc5LN25mqBoqUZPVosy9DEEY0eebnTtMKZ5iaDddgRd2oA2MGO+XqIvi2mq0xJAqQ0ARHzA8dncywWar91QaZwanMkUS7eqCqNVMKW9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xkDJZKeCcnUfYLl4+f2MFEhbG8pE0uMhqXt4Gntk/hM3Ti8k0JTSgM8zCWqg7LKPiyWcurKYr1PDaYi0x+Wi08gVaOkdYT85paa+Enbubo4NTWE3QRvtO87eg1Qy/gWeluerQd47w9BCRSsHWdfd6XebGcGptMoKw58Dhe4IwrXJYFKkspEKnYfImdRB0R7+GAasezjRIXamdhSP2M+1/rjv7cB5xI5Zya67KaN2BteNFOFvE2CtPUYObJxbN/1Sxb9hw8f/7dgbsMnKoMcAbjlIezWAcecJRxkmHcGacFTmg48xrLuYBnyuUzerl185y8UPkW6YbPn+HZWFJhtmlmMSKUY+XfUC8m8NgBG52uDeXrVFnYhv3Py3u9sb7X9wu8eMUE9x1GArUoAW0rNyVw42r3WwfwanDQHx1+9FhcMYii4y6E/6fvf3T6UiaZLA3BtXO9Zvvf0Xn2MahNEfmv1unr42peYe9Cxk+chD6gU5qcNla8/GQbSwfhJyvXvslmpC2oxOXAUIe9TgegXfgVXizXOSxN4RSlW9nEnK4eGzsGolO9pw+6xXC6d/pa0yDBzs7db6ZHGEczPgSbO+88qBpVMYjSbH/Trgn0vUM8+oE+O67otMbt8uWHvwGqGwCj";
|
||||||
|
|
||||||
private int round;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv){
|
public void process(RoundEnvironment env) throws Exception{
|
||||||
if(round++ != 0) return false; //only process 1 round
|
Set<TypeElement> elements = ElementFilter.typesIn(env.getElementsAnnotatedWith(Serialize.class));
|
||||||
|
|
||||||
try{
|
|
||||||
Set<TypeElement> elements = ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(Serialize.class));
|
|
||||||
|
|
||||||
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC);
|
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC);
|
||||||
classBuilder.addStaticBlock(CodeBlock.of(new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(data)))).readUTF()));
|
classBuilder.addStaticBlock(CodeBlock.of(new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(data)))).readUTF()));
|
||||||
@@ -101,22 +94,6 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
|
|
||||||
//write result
|
//write result
|
||||||
JavaFile.builder(packageName, classBuilder.build()).build().writeTo(Utils.filer);
|
JavaFile.builder(packageName, classBuilder.build()).build().writeTo(Utils.filer);
|
||||||
|
|
||||||
return true;
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void init(ProcessingEnvironment processingEnv){
|
|
||||||
super.init(processingEnv);
|
|
||||||
//put all relevant utils into utils class
|
|
||||||
Utils.typeUtils = processingEnv.getTypeUtils();
|
|
||||||
Utils.elementUtils = processingEnv.getElementUtils();
|
|
||||||
Utils.filer = processingEnv.getFiler();
|
|
||||||
Utils.messager = processingEnv.getMessager();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void name(MethodSpec.Builder builder, String name){
|
static void name(MethodSpec.Builder builder, String name){
|
||||||
|
|||||||
@@ -17,31 +17,14 @@ import java.util.Set;
|
|||||||
* Generates ""value types"" classes that are packed into integer primitives of the most aproppriate size.
|
* Generates ""value types"" classes that are packed into integer primitives of the most aproppriate size.
|
||||||
* It would be nice if Java didn't make crazy hacks like this necessary.
|
* It would be nice if Java didn't make crazy hacks like this necessary.
|
||||||
*/
|
*/
|
||||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
|
||||||
@SupportedAnnotationTypes({
|
@SupportedAnnotationTypes({
|
||||||
"mindustry.annotations.Annotations.Struct"
|
"mindustry.annotations.Annotations.Struct"
|
||||||
})
|
})
|
||||||
public class StructAnnotationProcessor extends AbstractProcessor{
|
public class StructAnnotationProcessor extends BaseProcessor{
|
||||||
/** Name of the base package to put all the generated classes. */
|
|
||||||
private static final String packageName = "mindustry.gen";
|
|
||||||
private int round;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void init(ProcessingEnvironment processingEnv){
|
public void process(RoundEnvironment env) throws Exception{
|
||||||
super.init(processingEnv);
|
Set<TypeElement> elements = ElementFilter.typesIn(env.getElementsAnnotatedWith(Struct.class));
|
||||||
//put all relevant utils into utils class
|
|
||||||
Utils.typeUtils = processingEnv.getTypeUtils();
|
|
||||||
Utils.elementUtils = processingEnv.getElementUtils();
|
|
||||||
Utils.filer = processingEnv.getFiler();
|
|
||||||
Utils.messager = processingEnv.getMessager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv){
|
|
||||||
if(round++ != 0) return false; //only process 1 round
|
|
||||||
|
|
||||||
try{
|
|
||||||
Set<TypeElement> elements = ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(Struct.class));
|
|
||||||
|
|
||||||
for(TypeElement elem : elements){
|
for(TypeElement elem : elements){
|
||||||
|
|
||||||
@@ -154,11 +137,6 @@ public class StructAnnotationProcessor extends AbstractProcessor{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static String bitString(int offset, int size, int totalSize){
|
static String bitString(int offset, int size, int totalSize){
|
||||||
|
|||||||
+3
-1
@@ -308,8 +308,10 @@ project(":annotations"){
|
|||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
|
def arcVersion = "e287fdce0449a87fb15599c67b5167ac0273bcb6"
|
||||||
|
|
||||||
compile 'com.squareup:javapoet:1.11.0'
|
compile 'com.squareup:javapoet:1.11.0'
|
||||||
compile "com.github.Anuken.Arc:arc-core:b77767039334b2658f44d69e72d1ef6bc84f95b0"
|
compile "com.github.Anuken.Arc:arc-core:$arcVersion"
|
||||||
compile files("${System.getProperty('java.home')}/../lib/tools.jar")
|
compile files("${System.getProperty('java.home')}/../lib/tools.jar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import java.util.*;
|
|||||||
|
|
||||||
import static arc.Core.settings;
|
import static arc.Core.settings;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class Vars implements Loadable{
|
public class Vars implements Loadable{
|
||||||
/** Whether to load locales.*/
|
/** Whether to load locales.*/
|
||||||
public static boolean loadLocales = true;
|
public static boolean loadLocales = true;
|
||||||
@@ -60,7 +59,7 @@ public class Vars implements Loadable{
|
|||||||
public static final String serverJsonURL = "https://raw.githubusercontent.com/Anuken/Mindustry/master/servers.json";
|
public static final String serverJsonURL = "https://raw.githubusercontent.com/Anuken/Mindustry/master/servers.json";
|
||||||
/** URL to the JSON file containing all the BE servers. Only queried in BE. */
|
/** URL to the JSON file containing all the BE servers. Only queried in BE. */
|
||||||
public static final String serverJsonBeURL = "https://raw.githubusercontent.com/Anuken/Mindustry/master/servers_be.json";
|
public static final String serverJsonBeURL = "https://raw.githubusercontent.com/Anuken/Mindustry/master/servers_be.json";
|
||||||
/** URL the links to the wiki's modding guide.*/
|
/** URL of the github issue report template.*/
|
||||||
public static final String reportIssueURL = "https://github.com/Anuken/Mindustry/issues/new?template=bug_report.md";
|
public static final String reportIssueURL = "https://github.com/Anuken/Mindustry/issues/new?template=bug_report.md";
|
||||||
/** list of built-in servers.*/
|
/** list of built-in servers.*/
|
||||||
public static final Array<String> defaultServers = Array.with();
|
public static final Array<String> defaultServers = Array.with();
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=bf5f253d458e0b8bddf9efcc3642a644f4b48fb6
|
archash=e287fdce0449a87fb15599c67b5167ac0273bcb6
|
||||||
|
|||||||
Reference in New Issue
Block a user