diff --git a/pom.xml b/pom.xml index d035a1b..ce5ff5f 100644 --- a/pom.xml +++ b/pom.xml @@ -29,8 +29,6 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo. - 1.9 - 1.9 UTF-8 sonatype-repo @@ -238,6 +236,33 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo. + + + + JDK8 + + 1.8 + + + 1.8 + 1.8 + + + + + + + JDK9.and.beyond + + [1.9,) + + + 1.9 + 1.9 + + + + diff --git a/processor/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java b/processor/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java index 1b99d56..2409f06 100644 --- a/processor/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java +++ b/processor/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java @@ -499,7 +499,72 @@ private Toolchain getToolchain(final Map jdkToolchain) return tc; } - + private List prepareOptions( JavaCompiler compiler ) { + + final List options = new ArrayList<>(10); + + final String compileClassPath = buildCompileClasspath(); + + final String processor = buildProcessor(); + + options.add("-cp"); + options.add(compileClassPath); + + if( compiler.isSupportedOption("--module-path") == 1 ) { + options.add("--module-path"); + options.add(buildModulePath()); + } + + buildCompileSourcepath( sourcepath -> { + options.add("-sourcepath"); + options.add(sourcepath); + }); + + options.add("-proc:only"); + + addCompilerArguments(options); + + if (processor != null) { + options.add("-processor"); + options.add(processor); + } + else + { + getLog().warn("No processors specified. Using default discovery mechanism."); + } + options.add("-d"); + options.add(getOutputClassDirectory().getPath()); + + options.add("-s"); + options.add(outputDirectory.getPath()); + + ofNullable(releaseVersion).ifPresent( release -> { + options.add("--release"); + options.add( releaseVersion ); + }); + + ofNullable(project.getProperties()).ifPresent( properties -> { + + ofNullable(properties.getProperty( "maven.compiler.source" )).ifPresent( source -> { + options.add("-source"); + options.add(source); + }); + ofNullable(properties.getProperty( "maven.compiler.target" )) .ifPresent( target -> { + options.add("-target"); + options.add(target); + }); + }); + + if( getLog().isDebugEnabled() ) { + for (String option : options) { + getLog().debug(String.format("javac option: %s", option)); + } + } + + return options; + + } + private void executeWithExceptionsHandled() throws Exception { if (outputDirectory == null) @@ -559,64 +624,6 @@ private void executeWithExceptionsHandled() throws Exception files.addAll( FileUtils.getFiles(sourceDir, includesString, excludesString) ); } - final String compileClassPath = buildCompileClasspath(); - - final String processor = buildProcessor(); - - final List options = new ArrayList<>(10); - - options.add("-cp"); - options.add(compileClassPath); - - options.add("--module-path"); - options.add( buildModulePath() ); - - buildCompileSourcepath( sourcepath -> { - options.add("-sourcepath"); - options.add(sourcepath); - }); - - options.add("-proc:only"); - - addCompilerArguments(options); - - if (processor != null) { - options.add("-processor"); - options.add(processor); - } - else - { - getLog().warn("No processors specified. Using default discovery mechanism."); - } - options.add("-d"); - options.add(getOutputClassDirectory().getPath()); - - options.add("-s"); - options.add(outputDirectory.getPath()); - - ofNullable(releaseVersion).ifPresent( release -> { - options.add("--release"); - options.add( releaseVersion ); - }); - - ofNullable(project.getProperties()).ifPresent( properties -> { - - ofNullable(properties.getProperty( "maven.compiler.source" )).ifPresent( source -> { - options.add("-source"); - options.add(source); - }); - ofNullable(properties.getProperty( "maven.compiler.target" )) .ifPresent( target -> { - options.add("-target"); - options.add(target); - }); - }); - - if( getLog().isDebugEnabled() ) { - for (String option : options) { - getLog().debug(String.format("javac option: %s", option)); - } - } - final DiagnosticListener dl = diagnostic -> { if (!outputDiagnostics) { @@ -704,8 +711,7 @@ private void executeWithExceptionsHandled() throws Exception //compileLock.lock(); try { - - + final JavaCompiler compiler = (fork) ? AnnotationProcessorCompiler.createOutProcess( tc, @@ -719,7 +725,8 @@ private void executeWithExceptionsHandled() throws Exception getLog().error("JVM is not suitable for processing annotation! ToolProvider.getSystemJavaCompiler() is null."); return; } - + + Charset charset = null; ; if( encoding != null ) { @@ -755,7 +762,9 @@ private void executeWithExceptionsHandled() throws Exception getLog().warn( "no source file(s) detected! Processor task will be skipped"); return; } - + + final List options = prepareOptions( compiler ); + final CompilationTask task = compiler.getTask( new PrintWriter(System.out), fileManager, 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 6d52b2f..89d69c1 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,12 +414,14 @@ public void setLocale(Locale locale) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - @Override + // from JDK9 + //@Override public void addModules(Iterable moduleNames) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - - @Override + + // from JDK9 + //@Override public Boolean call() { try { return execute(options, compilationUnits, out); diff --git a/test/pom.xml b/test/pom.xml index 80ebf84..7a98819 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -6,14 +6,13 @@ maven-processor-plugin-test jar MAVEN PROCESSOR PLUGIN TEST - 4.0-SNAPSHOT - - 1.9 - 1.9 - UTF-8 - + + org.bsc.maven + maven-processor-plugin-parent + 4.1-SNAPSHOT + 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 feb4fe0..c7fc2fd 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 @@ -25,7 +25,8 @@ * * */ -@SupportedSourceVersion(SourceVersion.RELEASE_9) +//@SupportedSourceVersion(SourceVersion.RELEASE_9) +@SupportedSourceVersion(SourceVersion.RELEASE_8) @SupportedAnnotationTypes( "*" ) //@SupportedOptions( {"subfolder", "filepath", "templateUri"}) //@SupportedAnnotationTypes( {"javax.ws.rs.GET", "javax.ws.rs.PUT", "javax.ws.rs.POST", "javax.ws.rs.DELETE"})