diff --git a/processor/src/main/java/org/bsc/maven/plugin/processor/AnnotationProcessorCompiler.java b/processor/src/main/java/org/bsc/maven/plugin/processor/AnnotationProcessorCompiler.java index 89d69c1..e30bbae 100644 --- a/processor/src/main/java/org/bsc/maven/plugin/processor/AnnotationProcessorCompiler.java +++ b/processor/src/main/java/org/bsc/maven/plugin/processor/AnnotationProcessorCompiler.java @@ -414,14 +414,12 @@ public void setLocale(Locale locale) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - // from JDK9 - //@Override + @Override public void addModules(Iterable moduleNames) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - // from JDK9 - //@Override + @Override public Boolean call() { try { return execute(options, compilationUnits, out); diff --git a/test/src/main/java/org/bsc/maven/plugin/processor/test/TESTWikiProcessor.java b/test/src/main/java/org/bsc/maven/plugin/processor/test/TESTWikiProcessor.java index c7fc2fd..55a2c6c 100644 --- a/test/src/main/java/org/bsc/maven/plugin/processor/test/TESTWikiProcessor.java +++ b/test/src/main/java/org/bsc/maven/plugin/processor/test/TESTWikiProcessor.java @@ -7,17 +7,18 @@ import org.bsc.processor.BaseAbstractProcessor; -import java.io.IOException; -import java.util.Set; - -import javax.annotation.processing.*; +import javax.annotation.processing.Filer; +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.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; -import javax.tools.Diagnostic.Kind; import javax.tools.FileObject; import javax.tools.StandardLocation; +import java.io.IOException; +import java.util.Set; /** * @@ -25,8 +26,8 @@ * * */ -//@SupportedSourceVersion(SourceVersion.RELEASE_9) -@SupportedSourceVersion(SourceVersion.RELEASE_8) +//@SupportedSourceVersion(SourceVersion.RELEASE_8) +@SupportedSourceVersion(SourceVersion.RELEASE_9) @SupportedAnnotationTypes( "*" ) //@SupportedOptions( {"subfolder", "filepath", "templateUri"}) //@SupportedAnnotationTypes( {"javax.ws.rs.GET", "javax.ws.rs.PUT", "javax.ws.rs.POST", "javax.ws.rs.DELETE"}) @@ -39,50 +40,46 @@ public class TESTWikiProcessor extends BaseAbstractProcessor { * @throws IOException */ protected FileObject getResourceFormClassPath(Filer filer, final String resource, final String packageName) throws IOException { - FileObject f = filer.getResource(StandardLocation.CLASS_PATH, packageName, resource); + final FileObject f = filer.getResource(StandardLocation.CLASS_PATH, packageName, resource); //java.io.Reader r = f.openReader(true); // ignoreEncodingErrors - java.io.InputStream is = f.openInputStream(); + try(java.io.InputStream is = f.openInputStream()) { - if( is==null ) { - warn( String.format("resource [%s] not found!", resource) ); - return null; + if (is == null) { + warn("resource [%s] not found!", resource); + return null; + } } - return f; } + /** + * + * @param annotations + * @param roundEnv + * @return + */ @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) return false; - final java.util.Map optionMap = processingEnv.getOptions(); - System.out.println( "====> PROCESSOR RUN"); - for( java.util.Map.Entry k : optionMap.entrySet() ) - System.out.printf( "\t[%s] = [%s]\n", k.getKey(), k.getValue()); - + info( "====> PROCESSOR RUN"); + optionMap.entrySet().forEach( k -> info( "\t[%s] = [%s]", k.getKey(), k.getValue())); + for( TypeElement e : annotations ) { - for (Element re : roundEnv.getElementsAnnotatedWith(e)) { + for (Element re : roundEnv.getElementsAnnotatedWith(e)) { if( re.getKind()==ElementKind.METHOD) { - info( String.format("[%s], Element [%s] is [%s] ", re.getEnclosingElement(), re.getKind(), re.getSimpleName())); + info( "[%s], Element [%s] is [%s]", re.getEnclosingElement(), re.getKind(), re.getSimpleName() ); } } } - //final Filer filer = processingEnv.getFiler(); - - //FileObject res = getOutputFile(filer, subfolder, filePath); - - //java.io.Writer w = res.openWriter(); - - //w.close(); - return true; }