Skip to content

Commit

Permalink
Merge branch 'release/4.0-rc1'
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Apr 17, 2020
2 parents 0f61c44 + 2262a4d commit de8fb77
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 66 deletions.
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,36 @@
## Next release
### Generic changes

**move to next release version**


[4146d73e88ea389](https://github.com/bsorrentino/maven-annotation-plugin/commit/4146d73e88ea389) bartolomeo sorrentino *2020-04-17 15:37:40*

**remove default source and target compiler option**


[5ef8f3b48474e13](https://github.com/bsorrentino/maven-annotation-plugin/commit/5ef8f3b48474e13) bartolomeo sorrentino *2020-04-16 23:55:38*

**add maven enforcer**


[8efac77492e7274](https://github.com/bsorrentino/maven-annotation-plugin/commit/8efac77492e7274) bartolomeo sorrentino *2020-04-16 22:24:57*

**update readme**


[807678003bfcd70](https://github.com/bsorrentino/maven-annotation-plugin/commit/807678003bfcd70) bartolomeo sorrentino *2020-04-16 18:39:07*

**update changelog template**


[8ae0d2f095d87b0](https://github.com/bsorrentino/maven-annotation-plugin/commit/8ae0d2f095d87b0) bartolomeo sorrentino *2020-03-20 09:22:18*

**update changelog**


[7e2cd9fb361848e](https://github.com/bsorrentino/maven-annotation-plugin/commit/7e2cd9fb361848e) bartolomeo sorrentino *2020-03-20 09:22:00*

**add utils javadoc to the site**


Expand All @@ -15,6 +45,26 @@

[bcfd9b3ecc46e6a](https://github.com/bsorrentino/maven-annotation-plugin/commit/bcfd9b3ecc46e6a) bsorrentino *2020-03-02 20:03:36*

**move to next developer version**


[785c31b31785d2f](https://github.com/bsorrentino/maven-annotation-plugin/commit/785c31b31785d2f) bsorrentino *2020-03-02 19:59:10*


### [#80](https://github.com/bsorrentino/maven-annotation-plugin/issues/80) How to exclude module-info.java file? *work in progress*

**issue #80**

* add support for -source and -target compiler options that are filled by maven.compiler.* properties

[18212a3518d162e](https://github.com/bsorrentino/maven-annotation-plugin/commit/18212a3518d162e) bartolomeo sorrentino *2020-04-17 15:32:19*

**issue #80**

* add support of javac option --module-path

[8d6d9c34e0c5722](https://github.com/bsorrentino/maven-annotation-plugin/commit/8d6d9c34e0c5722) bartolomeo sorrentino *2020-04-16 23:37:10*


## v4.0-beta1
### Generic changes
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ Currently | **[Release 4.0-SNAPSHOT](https://oss.sonatype.org/content/repositori

Date | Info
--- | ---
**Mar 02, 2020** | [Release 4.0-beta1](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.0-beta1)
**Apr 17, 2020** | [Release 4.0-rc1](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.0-rc1)
**Mar 02, 2020** | [Release 4.0-beta1](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.0-beta1)


## History


Aug 12,2018 | **Release 3.3.3**. | Available on **[MAVEN CENTRAL REPO](http://search.maven.org/#artifactdetails%7Corg.bsc.maven%7Cmaven-processor-plugin%7C3.3.3%7Cmaven-plugin)** |
----|----|----

Expand Down
23 changes: 21 additions & 2 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-parent</artifactId>
<packaging>pom</packaging>
<version>4.0-beta1</version>
<version>4.0-rc1</version>
<name>MAVEN PROCESSOR PLUGIN PARENT</name>
<description>A maven plugin to process annotation for jdk6 at compile time

Expand Down Expand Up @@ -130,7 +130,26 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
</pluginManagement>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.5.2</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!--
mvn git-changelog-maven-plugin:git-changelog -N -DtoRef=refs/heads/release/...
-->
Expand Down
2 changes: 1 addition & 1 deletion processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
<parent>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin-parent</artifactId>
<version>4.0-beta1</version>
<version>4.0-rc1</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,6 @@

package org.bsc.maven.plugin.processor;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
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;
import javax.tools.*;
import javax.tools.Diagnostic.Kind;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
Expand All @@ -52,6 +32,35 @@
import org.codehaus.plexus.compiler.manager.CompilerManager;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.ArtifactTypeRegistry;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.aether.resolution.ArtifactResult;

import javax.tools.Diagnostic.Kind;
import javax.tools.DiagnosticListener;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

// 3.0.5
/*
Expand All @@ -64,16 +73,8 @@
import org.sonatype.aether.resolution.ArtifactResult;
import org.sonatype.aether.util.artifact.DefaultArtifact;
*/

// 3.1.0
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.ArtifactTypeRegistry;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.aether.resolution.ArtifactResult;
import static java.util.Optional.ofNullable;


/**
Expand All @@ -83,11 +84,7 @@
*/
public abstract class AbstractAnnotationProcessorMojo extends AbstractMojo
{
interface ArtifactClosure {

void execute( Artifact artifact );
}


private static final String SOURCE_CLASSIFIER = "sources";

/**
Expand Down Expand Up @@ -358,6 +355,8 @@ private String buildProcessor()
return result.toString();
}

protected abstract java.util.Set<String> getResourcesElements( java.util.Set<String> result );

protected abstract java.util.Set<String> getClasspathElements( java.util.Set<String> result );

private String buildCompileSourcepath( Consumer<String> onSuccess) {
Expand All @@ -379,7 +378,11 @@ private String buildCompileClasspath()
{

final java.util.Set<String> pathElements = new java.util.LinkedHashSet<>();


getResourcesElements(pathElements);

getClasspathElements(pathElements);

if( pluginArtifacts!=null ) {

for( Artifact a : pluginArtifacts ) {
Expand All @@ -389,13 +392,13 @@ private String buildCompileClasspath()
java.io.File f = a.getFile();

if( f!=null ) pathElements.add( a.getFile().getAbsolutePath() );

}

}
}

getClasspathElements(pathElements);



final StringBuilder result = new StringBuilder();

for( String elem : pathElements ) {
Expand All @@ -404,6 +407,13 @@ private String buildCompileClasspath()
return result.toString();
}

private String buildModulePath()
{

return getClasspathElements(new java.util.LinkedHashSet<>())
.stream()
.collect(Collectors.joining( File.pathSeparator) );
}

/**
*
Expand Down Expand Up @@ -505,7 +515,7 @@ private void executeWithExceptionsHandled() throws Exception
final String includesString = ( includes==null || includes.length==0) ? "**/*.java" : StringUtils.join(includes, ",");
final String excludesString = ( excludes==null || excludes.length==0) ? null : StringUtils.join(excludes, ",");

java.util.Set<File> sourceDirs = getSourceDirectories(new java.util.HashSet<File>( 5 ));
java.util.Set<File> sourceDirs = getSourceDirectories(new java.util.HashSet<>( 5 ));

if( addCompileSourceRoots ) {
final java.util.List<String> sourceRoots = project.getCompileSourceRoots();
Expand Down Expand Up @@ -557,7 +567,10 @@ private void executeWithExceptionsHandled() throws Exception

options.add("-cp");
options.add(compileClassPath);


options.add("--module-path");
options.add( buildModulePath() );

buildCompileSourcepath( sourcepath -> {
options.add("-sourcepath");
options.add(sourcepath);
Expand All @@ -581,11 +594,22 @@ private void executeWithExceptionsHandled() throws Exception
options.add("-s");
options.add(outputDirectory.getPath());

if( releaseVersion!=null ) {
ofNullable(releaseVersion).ifPresent( release -> {
options.add("--release");
options.add( releaseVersion );
}
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) {
Expand Down Expand Up @@ -886,13 +910,13 @@ private Artifact resolveSourceArtifact( Artifact dep ) throws ArtifactResolution
return RepositoryUtils.toArtifact(result.getArtifact());
}

private void processSourceArtifacts( ArtifactClosure closure ) {
private void processSourceArtifacts( Consumer<Artifact> closure ) {

for (Artifact dep : this.project.getDependencyArtifacts()) {
if (dep.hasClassifier() && SOURCE_CLASSIFIER.equals(dep.getClassifier()) ) {

if( appendSourceArtifacts ) {
closure.execute(dep);
closure.accept(dep);
}
//getLog().debug("Append source artifact to classpath: " + dep.getGroupId() + ":" + dep.getArtifactId());
//this.sourceArtifacts.add(dep.getFile());
Expand All @@ -901,7 +925,7 @@ private void processSourceArtifacts( ArtifactClosure closure ) {
try {
final Artifact sourcesDep = resolveSourceArtifact(dep);
if( sourcesDep != null ) {
closure.execute(sourcesDep);
closure.accept(sourcesDep);
}

} catch (ArtifactResolutionException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import java.io.File;
import java.util.List;
import java.util.Set;

import org.apache.maven.model.Resource;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
Expand All @@ -39,10 +41,9 @@ public class MainAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo
* project classpath
*
*/
@SuppressWarnings("rawtypes")
//@MojoParameter(expression = "${project.compileClasspathElements}", required = true, readonly = true)
@Parameter( defaultValue="${project.compileClasspathElements}", required=true, readonly=true)
private List classpathElements;
private List<String> classpathElements;

/**
* project sourceDirectory
Expand Down Expand Up @@ -94,17 +95,21 @@ public java.util.Set<File> getSourceDirectories( final java.util.Set<File> resul
}

@Override
@SuppressWarnings("unchecked")
protected java.util.Set<String> getClasspathElements( final java.util.Set<String> result) {

List<Resource> resources = project.getResources();
protected Set<String> getResourcesElements(Set<String> result) {
final List<Resource> resources = project.getResources();

if( resources!=null ) {
for( Resource r : resources ) {
result.add(r.getDirectory());
}
}

return result;
}

@Override
protected java.util.Set<String> getClasspathElements( final java.util.Set<String> result) {

result.addAll( classpathElements );

return result;
Expand Down
Loading

0 comments on commit de8fb77

Please sign in to comment.