diff --git a/.github/workflows/deploy-jdk8.yml b/.github/workflows/deploy-jdk8.yml new file mode 100644 index 0000000..a2e4252 --- /dev/null +++ b/.github/workflows/deploy-jdk8.yml @@ -0,0 +1,31 @@ +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path + +name: Deploy New Version + +on: workflow_dispatch +# push: +# branches: [ support/4.x-jdk8 ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: GPG Setup + env: + GPG_KEY_BASE64: ${{ secrets.GPG_KEY_BASE64 }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + run: ./gpg-setup.sh + - name: Deploy to OSS Sonatype + env: + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + # mvn -Prelease source:jar javadoc:jar deploy -Dgpg.passphrase=thephrase + run: mvn -B -Prelease source:jar javadoc:jar deploy --file pom.xml -s settings-template.xml -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} + diff --git a/.github/workflows/deploy-snapshot.yaml b/.github/workflows/deploy-snapshot.yaml new file mode 100644 index 0000000..5498abf --- /dev/null +++ b/.github/workflows/deploy-snapshot.yaml @@ -0,0 +1,26 @@ +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path + +name: Maven Package + +on: + push: + branches: + - develop + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 9 + uses: actions/setup-java@v1 + with: + java-version: 9 + + - name: Build with Maven + env: + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: mvn -B deploy --file pom.xml -s settings-template.xml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a2e4252..45f50a4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,8 +4,10 @@ name: Deploy New Version on: workflow_dispatch +#on: # push: -# branches: [ support/4.x-jdk8 ] +# tags: +# - 'v*' jobs: build: @@ -14,10 +16,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 + - name: Set up JDK 9 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 9 - name: GPG Setup env: GPG_KEY_BASE64: ${{ secrets.GPG_KEY_BASE64 }} diff --git a/README.md b/README.md index 69f1cd3..940e5fa 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,13 @@ This plugin was born as the 'alter ego' of maven apt plugin [apt-maven-plugin](h Date | Version | Info --- | --- | --- +**Dec 22, 2020** | [Release 4.5](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.5) | fix issue [#90](https://github.com/bsorrentino/maven-annotation-plugin/issues/90) +**Dec 22, 2020** | [Release 4.5-jdk8](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.5-jdk8) | --- **Oct 01, 2020** | [Release 4.4](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.4) | merge PR #87. Thanks to [Martijn Dashorst](https://github.com/dashorst) +**Oct 01, 2020** | [Release 4.4-jdk8](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.4-jdk8) | --- **Sep 25, 2020** | [Release 4.3](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.3) | merge PR #85. Thanks to [Martijn Dashorst](https://github.com/dashorst) **Aug 03, 2020** | [Release 4.2](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.2) | merge PR #84. Thanks to [DemonicTutor](https://github.com/DemonicTutor) -**Aug 03, 2020** | [Release 4.2-jdk8](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.2-jdk8) | merge PR #84. Thanks to [DemonicTutor](https://github.com/DemonicTutor) +**Aug 03, 2020** | [Release 4.2-jdk8](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.2-jdk8) | --- **Jul 30, 2020** | [Release 4.1](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.1) | Release based on JDK9 and above **Jul 30, 2020** | [Release 4.1-jdk8](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.1-jdk8) | Maintenance release compatible with JDK8 **Jul 21, 2020** | [Release 4.0-jdk8](https://github.com/bsorrentino/maven-annotation-plugin/releases/tag/v4.0-jdk8) | Maintenance release compatible with JDK8 diff --git a/pom.xml b/pom.xml index 43a4dde..58e33b5 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.bsc.maven maven-processor-plugin-parent pom - 4.4 + 4.5 MAVEN PROCESSOR PLUGIN PARENT A maven plugin to process annotation for jdk6 at compile time @@ -91,7 +91,7 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo. junit junit - 4.13 + 4.13.1 test diff --git a/processor/pom.xml b/processor/pom.xml index 610734c..5aa963b 100644 --- a/processor/pom.xml +++ b/processor/pom.xml @@ -13,7 +13,7 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo. org.bsc.maven maven-processor-plugin-parent - 4.4 + 4.5 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 0002bc7..b7b175c 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 @@ -341,6 +341,26 @@ public abstract class AbstractAnnotationProcessorMojo extends AbstractMojo */ public abstract File getDefaultOutputDirectory(); + /** + * + * @return + */ + private Charset getCharsetFromEncoding() { + + return ofNullable(encoding).map( enc -> { + try { + return Charset.forName(encoding); + } + catch( IllegalCharsetNameException ex1 ) { + getLog().warn( format("the given charset name [%s] is illegal!. default is used", encoding )); + } + catch( UnsupportedCharsetException ex2 ) { + getLog().warn( format("the given charset name [%s] is unsupported!. default is used", encoding )); + } + return Charset.defaultCharset(); + }).orElseGet( () -> Charset.defaultCharset() ); + + } private String buildProcessor() { @@ -565,6 +585,11 @@ private List prepareOptions( JavaCompiler compiler ) { }); }); + ofNullable(encoding).ifPresent( enc -> { + options.add("-encoding"); + options.add( getCharsetFromEncoding().name() ); + }); + if( getLog().isDebugEnabled() ) { for (String option : options) { getLog().debug(format("javac option: %s", option)); @@ -803,28 +828,10 @@ private void executeWithExceptionsHandled() throws Exception return; } - - Charset charset = null; ; - - if( encoding != null ) { - try { - charset = Charset.forName(encoding); - } - catch( IllegalCharsetNameException ex1 ) { - getLog().warn( format("the given charset name [%s] is illegal!. default is used", encoding )); - charset = null; - } - catch( UnsupportedCharsetException ex2 ) { - getLog().warn( format("the given charset name [%s] is unsupported!. default is used", encoding )); - charset = null; - } - } - - final StandardJavaFileManager fileManager = - compiler.getStandardFileManager(null, null, - (charset==null) ? - Charset.defaultCharset() : - charset); + final StandardJavaFileManager fileManager = + compiler.getStandardFileManager(null, + null, + getCharsetFromEncoding()); if( files!=null && !files.isEmpty() ) { 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 55ef8f1..17dbac0 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 @@ -342,6 +342,9 @@ else if( "-s".equals(option) ) { else if( "--release".equals(option) ) { javacConf.setReleaseVersion(ii.next()); } + else if("-encoding".equals(option)) { + javacConf.setSourceEncoding(ii.next()); + } else /*if( option.startsWith("-A") ) */ { // view pull #70 // Just pass through any other arguments javacConf.addCompilerCustomArgument(option, ""); diff --git a/processor/src/test/java/org/bsc/maven/plugin/processor/ProcessorTest.java b/processor/src/test/java/org/bsc/maven/plugin/processor/ProcessorTest.java index 1191e0c..548272b 100644 --- a/processor/src/test/java/org/bsc/maven/plugin/processor/ProcessorTest.java +++ b/processor/src/test/java/org/bsc/maven/plugin/processor/ProcessorTest.java @@ -4,10 +4,12 @@ */ package org.bsc.maven.plugin.processor; -import java.io.File; -import org.junit.Assert; import org.junit.Test; -import org.hamcrest.core.*; + +import java.nio.charset.Charset; + +import static org.junit.Assert.*; + /** * * @author softphone @@ -20,11 +22,11 @@ public void compareFile() { final java.io.File f = new java.io.File( "target/test-classes"); final java.io.File f2 = new java.io.File( "target/classes"); - Assert.assertThat( f.equals(f2), Is.is(false)); + assertFalse( f.equals(f2)); final java.io.File f3 = new java.io.File( "target/classes"); - Assert.assertThat( f3.equals(f2), Is.is(true)); + assertTrue( f3.equals(f2)); } @@ -46,12 +48,25 @@ public void testDuplicatePath() { fileSet.add( f2 ); - Assert.assertThat( fileSet.size(), IsEqual.equalTo(1) ); + assertEquals( 1, fileSet.size() ); fileSet.add( f2 ); fileSet.add(f3); - Assert.assertThat( fileSet.size(), IsEqual.equalTo(2) ); + assertEquals( 2, fileSet.size() ); } + + @Test + public void testEncoding() { + + Charset.availableCharsets().entrySet().forEach( e -> { + System.out.printf( "encoding { key:%s, name:%s, aliases:%s }\n", e.getKey(), e.getValue().name(), e.getValue().aliases()); + }); + + final Charset utf8 = Charset.forName("utf8"); + assertEquals( "UTF-8", utf8.name() ); + } + + } diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..96e0a06 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +.maven-processor-source-files.txt diff --git a/test/pom.xml b/test/pom.xml index 89b26e6..93529fa 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -11,7 +11,7 @@ org.bsc.maven maven-processor-plugin-parent - 4.4 + 4.5 diff --git a/test/src/site/.maven-processor-source-files.txt b/test/src/site/.maven-processor-source-files.txt deleted file mode 100644 index 6256132..0000000 --- a/test/src/site/.maven-processor-source-files.txt +++ /dev/null @@ -1,4 +0,0 @@ -/Users/bsorrentino/WORKSPACES/GITHUB.me/maven-annotation-plugin/test/src/main/java/org/bsc/maven/plugin/processor/test/ParameterDocumentation.java -/Users/bsorrentino/WORKSPACES/GITHUB.me/maven-annotation-plugin/test/src/main/java/org/bsc/maven/plugin/processor/test/TestWikiProcessor.java -/Users/bsorrentino/WORKSPACES/GITHUB.me/maven-annotation-plugin/test/src/main/java/org/bsc/maven/plugin/processor/test/ServiceDocumentation.java -/Users/bsorrentino/WORKSPACES/GITHUB.me/maven-annotation-plugin/test/src/main/java/org/bsc/maven/plugin/processor/test/TestWikiProcessorClass.java diff --git a/utils/pom.xml b/utils/pom.xml index 56d14d4..56d37b9 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -31,7 +31,7 @@ org.bsc.maven maven-processor-plugin-parent - 4.4 + 4.5