1
0
Fork 0
mirror of https://github.com/ethauvin/version-processor.git synced 2025-04-24 23:47:11 -07:00
This commit is contained in:
Cedric Beust 2015-11-10 15:13:45 -08:00
parent ebb8c3503a
commit 72ed28c902
7 changed files with 32 additions and 17 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
.idea/tasks.xml
.kobalt
kobaltBuild
out

7
.idea/compiler.xml generated
View file

@ -15,7 +15,14 @@
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processor name="com.beust.apt.processor.MainProcessor" />
<processorPath useClasspath="true">
<entry name="$PROJECT_DIR$/processor/src/main/java" />
</processorPath>
</profile>
<profile default="false" name="VersionProcessor" enabled="true">
<processorPath useClasspath="true" />
<module name="example" />
</profile>
</annotationProcessing>
</component>

View file

@ -1,12 +0,0 @@
<component name="libraryTable">
<library name="KotlinJavaRuntime">
<CLASSES>
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime-sources.jar!/" />
</SOURCES>
</library>
</component>

View file

@ -7,7 +7,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="module" module-name="processor" />
<orderEntry type="module" module-name="processor" exported="" />
</component>
</module>

View file

@ -2,14 +2,25 @@ package com.beust.apt.example;
import com.beust.apt.processor.Version;
import java.io.File;
@Version("1.2")
class Example {
public Example() {
System.out.println("Instantiating Example");
}
public static void main(String[] argv) {
public static void main(String[] argv) throws Exception {
String[] args = new String[] {
// "-proc:only",
"-classpath", "/Users/beust/home/java/java-apt-example/processor/kobaltBuild/libs/processor-0.1.jar",
"-processor", "com.beust.apt.processor.MainProcessor",
"/Users/beust/java/java-apt-example/example/src/main/java/com/beust/apt/example/Example.java"
};
com.sun.tools.javac.Main.main(args);
File file = new File(".");
System.out.println("Instantiating Example()");
new Example();
}
}

View file

@ -8,6 +8,5 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>

View file

@ -2,11 +2,16 @@ package com.beust.apt.processor;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import java.util.HashSet;
import java.util.Set;
public class MainProcessor extends AbstractProcessor {
public MainProcessor() {
System.out.println("Instantiating MainProcessor");
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
System.out.println("Processing annotations $annotations");
@ -18,4 +23,9 @@ public class MainProcessor extends AbstractProcessor {
result.add("Version");
return result;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.RELEASE_7;
}
}