Skip to content

Commit

Permalink
Merge branch 'release/3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Apr 10, 2017
2 parents 309d32b + 063f735 commit 344d377
Show file tree
Hide file tree
Showing 7 changed files with 775 additions and 117 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.classpath
.project
.settings/
branch.sh
release.sh
sign-and-deploy.sh
*.sh
target/
issue47.txt
pom.xml.versionsBackup
maven-compiler-plugin/
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@
<img src="https://img.shields.io/github/stars/bsorrentino/maven-annotation-plugin.svg">&nbsp;<a href="https://github.com/bsorrentino/maven-annotation-plugin/issues"><img src="https://img.shields.io/github/issues/bsorrentino/maven-annotation-plugin.svg">
</a>&nbsp;

This plugin helps to use from maven the new annotation processing integrated in java compiler provided from JDK6
This plugin helps to use from maven the new annotation processing integrated in java compiler provided from JDK6

This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.codehaus.org/apt-maven-plugin/

### [Documentation - v3](http://bsorrentino.github.io/maven-annotation-plugin/index.html)
### Documentation

### [Old documentation - v2](http://bsorrentino.github.io/maven-annotation-plugin/site2/index.html)
* [Version 3](http://bsorrentino.github.io/maven-annotation-plugin/index.html)

* [Version 2 (old)](http://bsorrentino.github.io/maven-annotation-plugin/site2/index.html)

## Related plugin ##
| [m2e-apt](https://github.com/jbosstools/m2e-apt) | eclipse plugin from Jboss |
|:-------------------------------------------------|:--------------------------|
| [m2e-annotations](https://github.com/ilx/m2e-annotations) | eclipse plugin |
[m2e-apt](https://github.com/jbosstools/m2e-apt) | eclipse plugin from Jboss
----|----
[m2e-annotations](https://github.com/ilx/m2e-annotations) | eclipse plugin

## Releases ##
Apr 10,2017 | **Release 3.3**. | Available on **[MAVEN CENTRAL REPO](http://search.maven.org/#artifactdetails%7Corg.bsc.maven%7Cmaven-processor-plugin%7C3.3%7Cmaven-plugin)** |
----|----|----

* [Issue 64](https://github.com/bsorrentino/maven-annotation-plugin/issues/64) - Add option to `fork` for JDK9 support
* [Issue 65](https://github.com/bsorrentino/maven-annotation-plugin/issues/65) - Add support for `maven-toolchains-plugin`

|Oct 7,2016 | **Release 3.2.0**. | Available on **[MAVEN CENTRAL REPO](http://search.maven.org/#artifactdetails%7Corg.bsc.maven%7Cmaven-processor-plugin%7C3.2.0%7Cmaven-plugin)** |
|:-----------|:-------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------|

Expand Down
42 changes: 37 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>3.2.0</version>
<version>3.3</version>
<name>MAVEN PROCESSOR PLUGIN - ${project.version}</name>
<description>A maven plugin to process annotation for jdk6 at compile time

Expand Down Expand Up @@ -80,6 +80,26 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
</license>
</licenses>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-manager</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>2.8.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
Expand All @@ -104,7 +124,18 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
<artifactId>plexus-utils</artifactId>
<version>3.0.15</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-manager</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -212,9 +243,9 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
<build>
<plugins>
<!--
=====================================================================
mvn -Prelease release:perform -Darguments=-Dgpg.passphrase=thephrase
=====================================================================
========================================================================
mvn source:jar javadoc:jar deploy -P release -Dgpg.passphrase=thephrase
========================================================================
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -256,6 +287,7 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
<!--
=====================================================
DEPLOY SITE TO GITHUB
mvn site -P report
=====================================================
-->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@
import javax.tools.Diagnostic.Kind;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
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;

Expand Down Expand Up @@ -256,6 +259,38 @@ interface ArtifactClosure {
@Parameter(defaultValue = "false", property = "skipAnnotationProcessing")
protected boolean skip;

/**
* Allows running the compiler in a separate process.
* If false it uses the built in compiler, while if true it will use an executable.
*
* @since 3.3
*/
@Parameter(defaultValue = "false", property = "fork")
protected boolean fork;

/**
* Maven Session
*
* @since 3.3
*/
@Component
protected MavenSession session;

/**
* Plexus compiler manager.
*
* @since 3.3
*/
@Component
protected CompilerManager compilerManager;

/**
*
* @since 3.3
*/
@Component
private ToolchainManager toolchainManager;

/**
* for execution synchronization
*/
Expand Down Expand Up @@ -502,6 +537,7 @@ public void accept(String sourcepath) {

final DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>()
{
@Override
public void report(Diagnostic< ? extends JavaFileObject> diagnostic) {

if (!outputDiagnostics) {
Expand All @@ -510,22 +546,23 @@ public void report(Diagnostic< ? extends JavaFileObject> diagnostic) {

final Kind kind = diagnostic.getKind();

if (Kind.ERROR == kind) {

getLog().error(String.format("diagnostic: %s", diagnostic));

} else if (Kind.MANDATORY_WARNING == kind || Kind.WARNING == kind) {

getLog().warn(String.format("diagnostic: %s", diagnostic));

} else if (Kind.NOTE == kind) {

getLog().info(String.format("diagnostic: %s", diagnostic));

} else if (Kind.OTHER == kind) {

getLog().info(String.format("diagnostic: %s", diagnostic));

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;
}

}
Expand All @@ -550,6 +587,7 @@ public void report(Diagnostic< ? extends JavaFileObject> diagnostic) {

processSourceArtifacts( new ArtifactClosure() {

@Override
public void execute(Artifact artifact) {
try {

Expand Down Expand Up @@ -578,9 +616,23 @@ public void execute(Artifact artifact) {
}
});

// If toolchain is set force fork compilation
if( toolchainManager != null ) {
fork = true;
}

//compileLock.lock();
try {
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();


final JavaCompiler compiler = (fork) ?
AnnotationProcessorCompiler.createOutProcess(
toolchainManager,
compilerManager,
project,
session ) :
AnnotationProcessorCompiler.createInProcess();


if( compiler==null ) {
getLog().error("JVM is not suitable for processing annotation! ToolProvider.getSystemJavaCompiler() is null.");
Expand Down
Loading

0 comments on commit 344d377

Please sign in to comment.