From 48d0f76a9925964f3c95120afda320a2825ae141 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 7 Aug 2017 20:39:17 +0200 Subject: [PATCH] Converted to multimodule, added ann.proc.! Multimodule projects doesn't solve circular dependencies, but is neat anyways --- .project | 17 ++++++++ .settings/org.eclipse.m2e.core.prefs | 4 ++ ButtonCore/pom.xml | 11 +++-- ButtonProcessor/.classpath | 26 ++++++++++++ ButtonProcessor/.gitignore | 1 + ButtonProcessor/.project | 23 ++++++++++ .../org.eclipse.core.resources.prefs | 4 ++ .../.settings/org.eclipse.jdt.core.prefs | 5 +++ .../.settings/org.eclipse.m2e.core.prefs | 4 ++ ButtonProcessor/pom.xml | 41 ++++++++++++++++++ .../buttonproc/ButtonProcessor.java | 35 ++++++++++++++++ .../javax.annotation.processing.Processor | 1 + .../ButtonProcessor/AppTest.java | 38 +++++++++++++++++ pom.xml | 42 +++++++++++++++++++ 14 files changed, 248 insertions(+), 4 deletions(-) create mode 100644 .project create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 ButtonProcessor/.classpath create mode 100644 ButtonProcessor/.gitignore create mode 100644 ButtonProcessor/.project create mode 100644 ButtonProcessor/.settings/org.eclipse.core.resources.prefs create mode 100644 ButtonProcessor/.settings/org.eclipse.jdt.core.prefs create mode 100644 ButtonProcessor/.settings/org.eclipse.m2e.core.prefs create mode 100644 ButtonProcessor/pom.xml create mode 100644 ButtonProcessor/src/main/java/buttondevteam/buttonproc/ButtonProcessor.java create mode 100644 ButtonProcessor/src/main/resources/META-INF/services/javax.annotation.processing.Processor create mode 100644 ButtonProcessor/src/test/java/buttondevteam/ButtonProcessor/AppTest.java create mode 100644 pom.xml diff --git a/.project b/.project new file mode 100644 index 0000000..a3cb20e --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + ButtonCore + + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index fab3d94..732b133 100644 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -1,9 +1,13 @@ 4.0.0 + + com.github.TBMCPlugins + ButtonCore + master-SNAPSHOT + com.github.TBMCPlugins.ButtonCore ButtonCore - master-SNAPSHOT ButtonCore ButtonCore @@ -24,7 +28,6 @@ maven-compiler-plugin - 3.3 1.8 1.8 @@ -145,10 +148,10 @@ provided - com.github.TBMCPlugins + com.github.TBMCPlugins.ButtonCore ButtonProcessor master-SNAPSHOT - compile + provided diff --git a/ButtonProcessor/.classpath b/ButtonProcessor/.classpath new file mode 100644 index 0000000..af1430b --- /dev/null +++ b/ButtonProcessor/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ButtonProcessor/.gitignore b/ButtonProcessor/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/ButtonProcessor/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/ButtonProcessor/.project b/ButtonProcessor/.project new file mode 100644 index 0000000..208ad72 --- /dev/null +++ b/ButtonProcessor/.project @@ -0,0 +1,23 @@ + + + ButtonProcessor + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/ButtonProcessor/.settings/org.eclipse.core.resources.prefs b/ButtonProcessor/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..f9fe345 --- /dev/null +++ b/ButtonProcessor/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/ButtonProcessor/.settings/org.eclipse.jdt.core.prefs b/ButtonProcessor/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..714351a --- /dev/null +++ b/ButtonProcessor/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/ButtonProcessor/.settings/org.eclipse.m2e.core.prefs b/ButtonProcessor/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/ButtonProcessor/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ButtonProcessor/pom.xml b/ButtonProcessor/pom.xml new file mode 100644 index 0000000..6a14248 --- /dev/null +++ b/ButtonProcessor/pom.xml @@ -0,0 +1,41 @@ + + 4.0.0 + + com.github.TBMCPlugins + ButtonCore + master-SNAPSHOT + + com.github.TBMCPlugins.ButtonCore + ButtonProcessor + jar + + ButtonProcessor + http://maven.apache.org + + + + + maven-compiler-plugin + + 1.8 + 1.8 + -proc:none + + + + + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/ButtonProcessor/src/main/java/buttondevteam/buttonproc/ButtonProcessor.java b/ButtonProcessor/src/main/java/buttondevteam/buttonproc/ButtonProcessor.java new file mode 100644 index 0000000..8f71daf --- /dev/null +++ b/ButtonProcessor/src/main/java/buttondevteam/buttonproc/ButtonProcessor.java @@ -0,0 +1,35 @@ +package buttondevteam.buttonproc; + +import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; + +/** * A simple session bean type annotation processor. The implementation * is based on the standard annotation processing API in Java 6. */ +@SupportedSourceVersion(SourceVersion.RELEASE_8) +@SupportedAnnotationTypes("buttondevteam.*") +public class ButtonProcessor extends AbstractProcessor { + /** * Check if both @Stateful and @Stateless are present in an * session bean. If so, emits a warning message. */ + @Override + public boolean process(Set typeElements, RoundEnvironment roundEnv) { // TODO: SEparate JAR + for (TypeElement te : typeElements) { + Set elements = roundEnv.getElementsAnnotatedWith(te); + for (Element element : elements) { + System.out.println("Processing " + element); + List annotationMirrors = element.getAnnotationMirrors(); + System.out.println("Annotations: " + annotationMirrors); + for (AnnotationMirror annotation : annotationMirrors) { + String type = annotation.getAnnotationType().toString(); + System.out.println("Type: " + type); + } + } + } + return true; // claim the annotations + } +} diff --git a/ButtonProcessor/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/ButtonProcessor/src/main/resources/META-INF/services/javax.annotation.processing.Processor new file mode 100644 index 0000000..2869804 --- /dev/null +++ b/ButtonProcessor/src/main/resources/META-INF/services/javax.annotation.processing.Processor @@ -0,0 +1 @@ +buttondevteam.buttonproc.ButtonProcessor \ No newline at end of file diff --git a/ButtonProcessor/src/test/java/buttondevteam/ButtonProcessor/AppTest.java b/ButtonProcessor/src/test/java/buttondevteam/ButtonProcessor/AppTest.java new file mode 100644 index 0000000..0b65143 --- /dev/null +++ b/ButtonProcessor/src/test/java/buttondevteam/ButtonProcessor/AppTest.java @@ -0,0 +1,38 @@ +package buttondevteam.ButtonProcessor; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..672f423 --- /dev/null +++ b/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + + com.github.TBMCPlugins + ButtonCore + pom + master-SNAPSHOT + ButtonCore Parent + + + ButtonCore + ButtonProcessor + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + + + + + + + + + junit + junit + 3.8.1 + test + + + \ No newline at end of file