diff --git a/pom.xml b/pom.xml
index 29cc5d1..e8096e8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
https://github.com/bsorrentino/maven-annotation-plugin
- 3.1
+ 3.5
@@ -26,15 +26,15 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
${snapshot.repo.url}
false
-
- ${release.site.id}
- ${release.site.url}
-
+ 1.9
+ 1.9
UTF-8
- 3.1.0
+ 3.5.4
+ 3.6.0
+ 2.8.3
sonatype-repo
https://oss.sonatype.org/content/repositories/snapshots
@@ -81,49 +81,49 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
-
-
-
- org.codehaus.plexus
- plexus-compiler-api
- 2.8.2
-
-
- org.codehaus.plexus
- plexus-compiler-manager
- 2.8.2
-
-
- org.codehaus.plexus
- plexus-compiler-javac
- 2.8.2
- compile
-
-
-
-
+
+
+
+ org.codehaus.plexus
+ plexus-compiler-api
+ ${plexus.compiler.version}
+
+
+ org.codehaus.plexus
+ plexus-compiler-manager
+ ${plexus.compiler.version}
+
+
+ org.codehaus.plexus
+ plexus-compiler-javac
+ ${plexus.compiler.version}
+ compile
+
+
+
+
org.apache.maven
maven-plugin-api
- ${maven.release}
+ ${maven.plugin.version}
org.apache.maven
maven-core
- ${maven.release}
+ ${maven.version}
org.apache.maven.plugin-tools
maven-plugin-annotations
- 3.2
+ ${maven.plugin.version}
org.codehaus.plexus
plexus-utils
- 3.0.15
+ 3.1.1
org.codehaus.plexus
@@ -147,25 +147,42 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ ${maven.plugin.version}
+
+
+
+ org.apache.maven.plugins
+ maven-project-info-reports-plugin
+ 2.4
+
+
+
+ false
+
+
+
+
+
+
-
org.apache.maven.plugins
maven-compiler-plugin
- 3.1
-
-
- 1.6
-
+ 3.8.1
org.apache.maven.plugins
maven-plugin-plugin
- 3.1
+ ${maven.plugin.version}
true
@@ -194,65 +211,35 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
org.apache.maven.plugins
maven-site-plugin
- 3.4
+ 3.8.2
org.apache.maven.plugin-tools
maven-plugin-annotations
- 3.4
+ ${maven.plugin.version}
runtime
org.apache.maven.reporting
maven-reporting-exec
- 1.2
+ 1.4
org.apache.maven.doxia
doxia-module-markdown
- 1.6
+ 1.9.1
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- 3.4
-
-
-
- org.apache.maven.plugins
- maven-project-info-reports-plugin
- 2.4
-
-
-
- false
-
-
-
-
-
-
@@ -309,7 +296,6 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
mvn site -P report
=====================================================
-->
-
com.github.github
site-maven-plugin
diff --git a/src/main/java/org/bsc/function/Consumer.java b/src/main/java/org/bsc/function/Consumer.java
deleted file mode 100644
index 0d3e485..0000000
--- a/src/main/java/org/bsc/function/Consumer.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.bsc.function;
-
-/**
- *
- * @author bsorrentino
- * @param
- */
-public interface Consumer {
-
- void accept(T t);
-}
diff --git a/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java b/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java
index 69901a6..56f0a72 100644
--- a/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java
+++ b/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java
@@ -33,6 +33,7 @@
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.Consumer;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.tools.JavaCompiler.CompilationTask;
@@ -48,7 +49,6 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainManager;
-import org.bsc.function.Consumer;
import org.codehaus.plexus.compiler.manager.CompilerManager;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
@@ -101,8 +101,7 @@ interface ArtifactClosure {
/**
*
*/
- //@MojoParameter(expression = "${project}", readonly = true, required = true)
- @Component
+ @Parameter( defaultValue = "${project}", readonly = true )
protected MavenProject project;
/**
@@ -288,7 +287,7 @@ interface ArtifactClosure {
*
* @since 3.3
*/
- @Component
+ @Parameter( defaultValue = "${session}", readonly = true )
protected MavenSession session;
/**
@@ -379,7 +378,7 @@ private String buildCompileSourcepath( Consumer onSuccess) {
private String buildCompileClasspath()
{
- java.util.Set pathElements = new java.util.LinkedHashSet();
+ final java.util.Set pathElements = new java.util.LinkedHashSet<>();
if( pluginArtifacts!=null ) {
@@ -522,14 +521,12 @@ private void executeWithExceptionsHandled() throws Exception
if( additionalSourceDirectories != null && !additionalSourceDirectories.isEmpty() ) {
sourceDirs.addAll( additionalSourceDirectories );
}
-
-
+
if( sourceDirs == null ) {
throw new IllegalStateException("getSourceDirectories is null!");
}
-
-
- List files = new java.util.ArrayList();
+
+ final List files = new java.util.ArrayList<>();
for( File sourceDir : sourceDirs ) {
@@ -548,35 +545,29 @@ private void executeWithExceptionsHandled() throws Exception
getLog().warn( String.format("source directory [%s] is invalid! Processor task will be skipped!", sourceDir.getPath()));
continue;
}
-
files.addAll( FileUtils.getFiles(sourceDir, includesString, excludesString) );
}
-
final String compileClassPath = buildCompileClasspath();
final String processor = buildProcessor();
- final List options = new ArrayList(10);
+ final List options = new ArrayList<>(10);
options.add("-cp");
options.add(compileClassPath);
- buildCompileSourcepath( new Consumer() {
- public void accept(String sourcepath) {
-
+ buildCompileSourcepath( sourcepath -> {
options.add("-sourcepath");
options.add(sourcepath);
- }
});
options.add("-proc:only");
addCompilerArguments(options);
- if (processor != null)
- {
+ if (processor != null) {
options.add("-processor");
options.add(processor);
}
@@ -602,45 +593,39 @@ public void accept(String sourcepath) {
}
}
- final DiagnosticListener dl = new DiagnosticListener()
- {
- @Override
- public void report(Diagnostic< ? extends JavaFileObject> diagnostic) {
+ final DiagnosticListener dl = diagnostic -> {
- if (!outputDiagnostics) {
- return;
- }
-
- final Kind kind = diagnostic.getKind();
-
- if (null != kind)
- switch (kind) {
- case ERROR:
- getLog().error(String.format("diagnostic: %s", diagnostic));
- break;
- case MANDATORY_WARNING:
- case WARNING:
- getLog().warn(String.format("diagnostic: %s", diagnostic));
- break;
- case NOTE:
- getLog().info(String.format("diagnostic: %s", diagnostic));
- break;
- case OTHER:
- getLog().info(String.format("diagnostic: %s", diagnostic));
- break;
- default:
- break;
- }
+ if (!outputDiagnostics) {
+ return;
+ }
+ final Kind kind = diagnostic.getKind();
+
+ if (null != kind)
+ switch (kind) {
+ case ERROR:
+ getLog().error(String.format("diagnostic: %s", diagnostic));
+ break;
+ case MANDATORY_WARNING:
+ case WARNING:
+ getLog().warn(String.format("diagnostic: %s", diagnostic));
+ break;
+ case NOTE:
+ getLog().info(String.format("diagnostic: %s", diagnostic));
+ break;
+ case OTHER:
+ getLog().info(String.format("diagnostic: %s", diagnostic));
+ break;
+ default:
+ break;
}
+
};
- if (systemProperties != null)
- {
+ if (systemProperties != null) {
java.util.Set< Map.Entry> pSet = systemProperties.entrySet();
- for ( Map.Entry e : pSet )
- {
+ for ( Map.Entry e : pSet ) {
getLog().debug( String.format("set system property : [%s] = [%s]", e.getKey(), e.getValue() ));
System.setProperty(e.getKey(), e.getValue());
}
@@ -650,36 +635,32 @@ public void report(Diagnostic< ? extends JavaFileObject> diagnostic) {
//
// add to allSource the files coming out from source archives
//
- final List allSources = new java.util.ArrayList();
+ final List allSources = new java.util.ArrayList<>();
- processSourceArtifacts( new ArtifactClosure() {
+ processSourceArtifacts( artifact -> {
+ try {
- @Override
- public void execute(Artifact artifact) {
- try {
-
- java.io.File f = artifact.getFile();
+ File f = artifact.getFile();
- ZipFile zipFile = new ZipFile(f);
- Enumeration extends ZipEntry> entries = zipFile.entries();
- int sourceCount = 0;
+ ZipFile zipFile = new ZipFile(f);
+ Enumeration extends ZipEntry> entries = zipFile.entries();
+ int sourceCount = 0;
- while (entries.hasMoreElements()) {
- ZipEntry entry = (ZipEntry) entries.nextElement();
+ while (entries.hasMoreElements()) {
+ final ZipEntry entry = entries.nextElement();
- if (entry.getName().endsWith(".java")) {
- ++sourceCount;
- allSources.add(ZipFileObject.create(zipFile, entry));
+ if (entry.getName().endsWith(".java")) {
+ ++sourceCount;
+ allSources.add(ZipFileObject.create(zipFile, entry));
- }
}
-
- getLog().debug(String.format("** Discovered %d java sources in %s", sourceCount, f.getAbsolutePath()));
-
- } catch (Exception ex) {
- getLog().warn(String.format("Problem reading source archive [%s]", artifact.getFile().getPath()));
- getLog().debug(ex);
}
+
+ getLog().debug(String.format("** Discovered %d java sources in %s", sourceCount, f.getAbsolutePath()));
+
+ } catch (Exception ex) {
+ getLog().warn(String.format("Problem reading source archive [%s]", artifact.getFile().getPath()));
+ getLog().debug(ex);
}
});
@@ -743,26 +724,20 @@ public void execute(Artifact artifact) {
allSources.add(f);
};
-
-
-
+
}
-
-
-
+
if( allSources.isEmpty() ) {
getLog().warn( "no source file(s) detected! Processor task will be skipped");
return;
}
- final Iterable classes = null;
-
- CompilationTask task = compiler.getTask(
+ final CompilationTask task = compiler.getTask(
new PrintWriter(System.out),
fileManager,
dl,
options,
- classes,
+ null,
allSources);
/*
@@ -775,9 +750,7 @@ public void execute(Artifact artifact) {
*/
// Perform the compilation task.
- if (!task.call())
- {
-
+ if (!task.call()) {
throw new Exception("error during compilation");
}
}
@@ -804,18 +777,14 @@ private List scanSourceDirectorySources(File sourceDir) throws IOException
final String includesString = ( includes==null || includes.length==0) ? "**/*.java" : StringUtils.join(includes, ",");
final String excludesString = ( excludes==null || excludes.length==0) ? null : StringUtils.join(excludes, ",");
- List files = FileUtils.getFiles(sourceDir, includesString, excludesString);
+ final List files = FileUtils.getFiles(sourceDir, includesString, excludesString);
return files;
}
- private void addCompilerArguments(List options)
- {
- if (!StringUtils.isEmpty(compilerArguments))
- {
- for (String arg : compilerArguments.split(" "))
- {
- if (!StringUtils.isEmpty(arg))
- {
+ private void addCompilerArguments(List options) {
+ if (!StringUtils.isEmpty(compilerArguments)) {
+ for (String arg : compilerArguments.split(" ")) {
+ if (!StringUtils.isEmpty(arg)) {
arg = arg.trim();
getLog().debug(String.format("Adding compiler arg: %s", arg));
options.add(arg);
@@ -838,8 +807,7 @@ private void addCompilerArguments(List options)
private void addOutputToSourcesIfNeeded()
{
final Boolean add = addOutputDirectoryToCompilationSources;
- if (add == null || add.booleanValue())
- {
+ if (add == null || add.booleanValue()) {
getLog().debug(String.format("Source directory: %s added", outputDirectory));
addCompileSourceRoot(project, outputDirectory.getAbsolutePath());
}
@@ -848,8 +816,7 @@ private void addOutputToSourcesIfNeeded()
private void ensureOutputDirectoryExists()
{
final File f = outputDirectory;
- if (!f.exists())
- {
+ if (!f.exists()) {
f.mkdirs();
}
if( !getOutputClassDirectory().exists()) {
@@ -900,13 +867,11 @@ private Artifact resolveSourceArtifact( Artifact dep ) throws ArtifactResolution
final ArtifactTypeRegistry typeReg = repoSession.getArtifactTypeRegistry();
- final String extension = null;
-
- final DefaultArtifact artifact =
+ final DefaultArtifact artifact =
new DefaultArtifact( dep.getGroupId(),
dep.getArtifactId(),
SOURCE_CLASSIFIER,
- extension,
+ null,
dep.getVersion(),
typeReg.get(dep.getType()));
diff --git a/src/main/java/org/bsc/maven/plugin/processor/Debug.java b/src/main/java/org/bsc/maven/plugin/processor/Debug.java
deleted file mode 100644
index 3b371ef..0000000
--- a/src/main/java/org/bsc/maven/plugin/processor/Debug.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2009 2010 2011 Bartolomeo Sorrentino
- *
- * This file is part of maven-annotation-plugin.
- *
- * maven-annotation-plugin is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * maven-annotation-plugin is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with maven-annotation-plugin. If not, see .
- */
-package org.bsc.maven.plugin.processor;
-
-import java.io.File;
-import java.util.Collection;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.ArtifactUtils;
-import org.apache.maven.project.MavenProject;
-
-/**
- * Debug helpers
- */
-class Debug
-{
- private final MavenProject project;
-
- public Debug(MavenProject project)
- {
- if (project == null)
- {
- throw new IllegalArgumentException("Argument 'project' cannot be null");
- }
- this.project = project;
- }
-
- public void println(String name, Collection e)
- {
- System.out.println(name);
- if (null == e)
- {
- return;
- }
-
- for (T a : e)
- {
- System.out.printf("\t[%s] %s\n", a.getClass().getName(), a.toString());
- }
-
- }
-
- public void printDeps(String name, Collection dependencies)
- {
- System.out.println(name);
- for (org.apache.maven.model.Dependency d : dependencies)
- {
-
- System.out.printf("dependency [%s]\n", d.toString());
-
- String versionlessKey = ArtifactUtils.versionlessKey(d.getGroupId(), d.getArtifactId());
-
- Artifact artifact = (Artifact)project.getArtifactMap().get(versionlessKey);
-
- if (null != artifact)
- {
- File file = artifact.getFile();
- System.out.printf("artifact [%s]\n", file.getPath());
- }
- }
- }
-
- public void printDebugInfo() throws Exception //DependencyResolutionRequiredException
- {
- //println("project.getCompileClasspathElements", project.getCompileClasspathElements());
- println("project.getCompileArtifacts", project.getCompileArtifacts());
- println("project.getCompileDependencies", project.getCompileDependencies());
- println("project.getDependencyArtifacts", project.getDependencyArtifacts());
- println("project.getArtifactMap", project.getArtifactMap().keySet());
- println("project.getArtifacts", project.getArtifacts());
- printDeps("project.getRuntimeDependencies", project.getRuntimeDependencies());
- printDeps("project.getDependencies", project.getDependencies());
- }
-
-}
diff --git a/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java b/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java
index a91c5ba..a8ac2b3 100644
--- a/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java
+++ b/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java
@@ -69,26 +69,25 @@ public class MainAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo
private File outputClassDirectory;
@Override
- protected File getOutputClassDirectory()
- {
+ protected File getOutputClassDirectory() {
+
return outputClassDirectory;
}
@Override
- protected void addCompileSourceRoot(MavenProject project, String dir)
- {
+ protected void addCompileSourceRoot(MavenProject project, String dir) {
+
project.addCompileSourceRoot(dir);
}
@Override
- public File getDefaultOutputDirectory()
- {
+ public File getDefaultOutputDirectory() {
+
return defaultOutputDirectory;
}
@Override
- public java.util.Set getSourceDirectories( final java.util.Set result )
- {
+ public java.util.Set getSourceDirectories( final java.util.Set result ) {
result.add( sourceDirectory );
return result;
@@ -96,8 +95,7 @@ public java.util.Set getSourceDirectories( final java.util.Set resul
@Override
@SuppressWarnings("unchecked")
- protected java.util.Set getClasspathElements( final java.util.Set result)
- {
+ protected java.util.Set getClasspathElements( final java.util.Set result) {
List resources = project.getResources();
diff --git a/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java b/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java
index 8f06599..ebdd5cd 100644
--- a/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java
+++ b/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java
@@ -33,8 +33,7 @@
*
*/
@Mojo(name="process-test",threadSafe=true,requiresDependencyResolution= ResolutionScope.TEST,defaultPhase= LifecyclePhase.GENERATE_TEST_SOURCES)
-public class TestAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo
-{
+public class TestAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo {
/**
* project classpath
@@ -69,26 +68,25 @@ public class TestAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo
private File outputClassDirectory;
@Override
- protected void addCompileSourceRoot(MavenProject project, String dir)
- {
+ protected void addCompileSourceRoot(MavenProject project, String dir) {
+
project.addTestCompileSourceRoot(dir);
}
@Override
- public File getDefaultOutputDirectory()
- {
+ public File getDefaultOutputDirectory() {
+
return defaultOutputDirectory;
}
@Override
- protected File getOutputClassDirectory()
- {
+ protected File getOutputClassDirectory() {
+
return outputClassDirectory;
}
@Override
- public java.util.Set getSourceDirectories( final java.util.Set result )
- {
+ public java.util.Set getSourceDirectories( final java.util.Set result ) {
result.add( sourceDirectory );
return result;
@@ -97,9 +95,8 @@ public java.util.Set getSourceDirectories( final java.util.Set resul
@SuppressWarnings("unchecked")
@Override
- protected java.util.Set getClasspathElements( final java.util.Set result )
- {
- List resources = project.getTestResources();
+ protected java.util.Set getClasspathElements( final java.util.Set result ) {
+ final List resources = project.getTestResources();
if( resources!=null ) {
for( Resource r : resources ) {
diff --git a/src/site/site.xml b/src/site/site.xml
index ad3f04a..8eeec97 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -7,7 +7,7 @@
org.apache.maven.skins
maven-fluido-skin
- 1.3.1
+ 1.8