Skip to content

Commit

Permalink
[#22,#11,#18] java >=9 compatibility, replaced maven pom, test cover…
Browse files Browse the repository at this point in the history
…age (#23)

* Updated travis config for development on fork

* Updated Readme for Fork

Linked  badges for travis and codecov for fork

* [#22] Enhanced Java >= 9 compatibility.

Removed google.compiletesting dependency to achieve this.

* [#22] Active builds on Travis with JDKs >= 9

* [#22]Replaced cobertura plugin by jacoco plugin

* [#22] Removed Travis Build support for java 11

* [#22] Fixed NPE during test with created resource during compilation

* [#22] Removed Travis Build support for java 10 and added 11 again

* Increase unit test coverage

* Increase unit test coverage

* Increase unit test coverage
Introduced SPI for Asserts - allows support of junit5 and other test frameworks

* Minor refactorings and increase test coverage

* Fix tests

* Fix build for jdk >=9

* Increase unit test coverage

* [#22,#11,#18] Achieve java >=9 compatibility

Replace google compile-testing framework by toolisticon compile-testing framework.
Replaced maven parent.
  • Loading branch information
tobiasstamann authored Dec 18, 2018
1 parent 955a107 commit 076078a
Show file tree
Hide file tree
Showing 59 changed files with 4,144 additions and 3,486 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ jdk:
- openjdk7
- openjdk8
- oraclejdk8
- oraclejdk9
- oraclejdk11
- openjdk10
install: mvn install -DskipTests=true -q
script:
- mvn verify -B -q
- mvn -Danimal.sniffer.skip=true cobertura:cobertura

after_success:
- bash <(curl -s https://codecov.io/bash)
- ! '[[ $TRAVIS_BRANCH == "master" && $TRAVIS_REPO_SLUG == "holisticon/annotation-processor-toolkit"
- ! '[[ $TRAVIS_BRANCH == "master" && $TRAVIS_REPO_SLUG == "tobiasstamann/annotation-processor-toolkit"
&& $TRAVIS_PULL_REQUEST == "false" ]] && { curl https://raw.githubusercontent.com/holisticon/travis-configuration/master/settings.xml --location --create-dirs -o target/travis/settings.xml; }'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Annotation-Processor-Toolkit

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.annotationprocessortoolkit/annotationprocessortoolkit-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.annotationprocessortoolkit/annotationprocessortoolkit-parent)
[![Build Status](https://api.travis-ci.org/toolisticon/annotation-processor-toolkit.svg)](https://travis-ci.org/toolisticon/annotation-processor-toolkit)
[![codecov](https://codecov.io/gh/toolisticon/annotation-processor-toolkit/branch/master/graph/badge.svg)](https://codecov.io/gh/toolisticon/annotation-processor-toolkit)
[![Build Status](https://api.travis-ci.org/tobiasstamann/annotation-processor-toolkit.svg)](https://travis-ci.org/tobiasstamann/annotation-processor-toolkit)
[![codecov](https://codecov.io/gh/tobiasstamann/annotation-processor-toolkit/branch/master/graph/badge.svg)](https://codecov.io/gh/tobiasstamann/annotation-processor-toolkit)

Please check detailed documentation at the projects [github page](https://toolisticon.github.io/annotation-processor-toolkit/)

Expand Down
87 changes: 78 additions & 9 deletions annotationprocessor/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>annotationprocessor</artifactId>
Expand Down Expand Up @@ -31,13 +32,6 @@
</dependency>


<dependency>
<groupId>com.google.testing.compile</groupId>
<artifactId>compile-testing</artifactId>
<scope>test</scope>
</dependency>


</dependencies>


Expand All @@ -55,9 +49,84 @@
</configuration>
</plugin>

<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.0.4,)</version>
</requireMavenVersion>
<requireJavaVersion>
<version>1.6</version>
</requireJavaVersion>
<bannedDependencies>
<searchTransitive>false</searchTransitive>
<excludes>
<exclude>*</exclude>
</excludes>
<includes>
<include>io.toolisticon.annotationprocessortoolkit:*</include>
<include>com.sun:tools:*</include>
<include>*:*:*:*:test:*</include>
<include>*:*:*:*:provided:*</include>
</includes>
</bannedDependencies>
</rules>
</configuration>
</execution>
</executions>
</plugin>

</plugins>

</build>

</build>
<profiles>

<profile>
<id>tools-jar</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
<profile>
<id>classes-jar</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<exists>${java.home}/../Classes/classes.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<!--<version>${java.version}</version>-->
<scope>system</scope>
<systemPath>${java.home}/../Classes/classes.jar</systemPath>
</dependency>
</dependencies>
</profile>


</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static String createMessage(ValidationMessage message, Object... messageP

}

private static String argToString(Object arg){
protected static String argToString(Object arg){

if(arg == null) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ public static <T> List<T> convertVarargsToList(T... varargs) {
* @param <T>
* @return a array that contains all varargs arguments or an array of length 0 if no varargs arguments have been used
*/
public static <T> T[] convertVarargsToArray(T... varargs) {
public static <T> T[] convertVarargsToArray(T... varargs) { final Object[] e = {};

if (varargs == null) {
return (T[])new Object[0];
}
return varargs;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum CoreMatcherValidationMessages implements ValidationMessage {
HAS_PUBLIC_NOARG_CONSTRUCTOR("CM_HAS_PUBLIC_NOARG_CONSTURCTOR", "Element must ${0} have a public noarg constructor or just the default constructor"),
IS_GETTER_METHOD("CM_IS_GETTER_METHOD", "Element must ${0} be a getter method : public, not abstract, not static, non void return type, no parameters, with 'get' as name prefix or 'is' or 'has' for boolean return types."),
IS_SETTER_METHOD("CM_IS_SETTER_METHOD", "Element must ${0} be a setter method : public, not abstract, not static, void return type, one parameter, with 'set' as name prefix"),
IS_ATTRIBUTE_FIELD("CM_IS_ATTRIBUTE_FIELD", "Element must ${0} not be static and must have a public getter and setter method"),
IS_EXECUTABLE_ELEMENT("CM_IS_EXECTUABLE_ELEMENT", "Element must ${0} be a ExecutableElement"),
IS_TYPE_ELEMENT("CM_IS_TYPE_ELEMENT", "Element must ${0} be a TypeElement"),
IS_VARIABLE_ELEMENT("CM_IS_VARIABLE_ELEMENT", "Element must ${0} be a VariableElement"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.toolisticon.annotationprocessortoolkit.tools.matcher.impl.HasVoidReturnTypeMatcher;
import io.toolisticon.annotationprocessortoolkit.tools.matcher.impl.IsAnnotationTypeMatcher;
import io.toolisticon.annotationprocessortoolkit.tools.matcher.impl.IsAssignableToMatcher;
import io.toolisticon.annotationprocessortoolkit.tools.matcher.impl.IsAttributeFieldMatcher;
import io.toolisticon.annotationprocessortoolkit.tools.matcher.impl.IsClassMatcher;
import io.toolisticon.annotationprocessortoolkit.tools.matcher.impl.IsConstructorMatcher;
import io.toolisticon.annotationprocessortoolkit.tools.matcher.impl.IsEnumMatcher;
Expand Down Expand Up @@ -185,6 +186,13 @@ private CoreMatchers() {
*/
public final static ImplicitCoreMatcher<ExecutableElement> IS_SETTER_METHOD = new ImplicitCoreMatcher<ExecutableElement>(new IsSetterMethodMatcher(), CoreMatcherValidationMessages.IS_SETTER_METHOD);

/**
* Matcher to check if passed element represents an attribute.
* Passed VariableElement for field must not be static and must have valid getter and setter methods.
*/
public final static ImplicitCoreMatcher<VariableElement> IS_ATTRIBUTE_FIELD = new ImplicitCoreMatcher<VariableElement>(new IsAttributeFieldMatcher(), CoreMatcherValidationMessages.IS_ATTRIBUTE_FIELD);



// ---------------------------------------------------------------------------------
// -- IS CORE MATCHER
Expand Down Expand Up @@ -256,4 +264,6 @@ private CoreMatchers() {
public final static IsElementBasedCoreMatcher<VariableElement> IS_PARAMETER = new IsElementBasedCoreMatcher<VariableElement>(new IsParameterMatcher<Element>(), CoreMatcherValidationMessages.IS_PARAMETER);




}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ public static PlainValidationMessage create(String message) {
public static PlainValidationMessage create(String code, String message) {
return new PlainValidationMessage(code, message);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,12 @@ public class Matcher<MT extends BaseMatcher> {
/**
* Constructor that allows passing in of the {@link Matcher} to be wrapped.
*
* @param matcher
* @param matcher the matcher to be wrapped within
*/
public Matcher(MT matcher) {
this.matcher = matcher;
}

/**
* Hidden constructor.
*/
private Matcher() {
this.matcher = null;
}

/**
* Gets the wrapped Matcher.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfiguration;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfigurationBuilder;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.TestAnnotation;
import io.toolisticon.annotationprocessortoolkit.tools.MessagerUtils;
import io.toolisticon.annotationprocessortoolkit.tools.corematcher.CoreMatchers;
import io.toolisticon.annotationprocessortoolkit.tools.fluentfilter.FluentElementFilter;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand All @@ -27,6 +29,11 @@ public AbstractAnnotationProcessorTest(String message, AnnotationProcessorUnitTe
super(configuration);
}

@Before
public void init() {
MessagerUtils.setPrintMessageCodes(true);
}

@Parameterized.Parameters(name = "{index}: {0}")
public static List<Object[]> data() {
return Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.toolisticon.annotationprocessortoolkit.tools;

import com.google.testing.compile.JavaFileObjects;
import io.toolisticon.annotationprocessortoolkit.testhelper.AbstractAnnotationProcessorUnitTest;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AbstractUnitTestAnnotationProcessorClass;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfiguration;
Expand All @@ -10,6 +9,7 @@
import io.toolisticon.annotationprocessortoolkit.tools.annotationutilstestclasses.DefaultValueAnnotation;
import io.toolisticon.annotationprocessortoolkit.tools.corematcher.CoreMatchers;
import io.toolisticon.annotationprocessortoolkit.tools.fluentfilter.FluentElementFilter;
import io.toolisticon.compiletesting.JavaFileObjectUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
Expand Down Expand Up @@ -380,7 +380,7 @@ protected void testCase(TypeElement element) {

@Override
protected JavaFileObject getSourceFileForCompilation() {
return JavaFileObjects.forResource("AnnotationClassAttributeTestClass.java");
return JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.toolisticon.annotationprocessortoolkit.tools;

import com.google.testing.compile.JavaFileObjects;
import io.toolisticon.annotationprocessortoolkit.testhelper.AbstractAnnotationProcessorUnitTest;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AbstractUnitTestAnnotationProcessorClass;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfiguration;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfigurationBuilder;
import io.toolisticon.annotationprocessortoolkit.tools.annotationvalueutilstestclasses.AnnotationValueTestAnnotation;
import io.toolisticon.compiletesting.JavaFileObjectUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
Expand Down Expand Up @@ -1094,7 +1094,6 @@ protected void testCase(TypeElement element) {
MatcherAssert.assertThat(AnnotationValueUtils.isAnnotationArray(null), Matchers.is(false));



}
}
)
Expand All @@ -1112,7 +1111,7 @@ protected void testCase(TypeElement element) {

@Override
protected JavaFileObject getSourceFileForCompilation() {
return JavaFileObjects.forResource("AnnotationValueUtilsTestClass.java");
return JavaFileObjectUtils.readFromResource("/AnnotationValueUtilsTestClass.java");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.toolisticon.annotationprocessortoolkit.tools;

import com.google.testing.compile.JavaFileObjects;
import io.toolisticon.annotationprocessortoolkit.FilterTestAnnotation1;
import io.toolisticon.annotationprocessortoolkit.testhelper.AbstractAnnotationProcessorUnitTest;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AbstractUnitTestAnnotationProcessorClass;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfiguration;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfigurationBuilder;
import io.toolisticon.annotationprocessortoolkit.tools.corematcher.CoreMatchers;
import io.toolisticon.compiletesting.JavaFileObjectUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
Expand Down Expand Up @@ -450,7 +450,7 @@ protected void testCase(TypeElement element) {

@Override
protected JavaFileObject getSourceFileForCompilation() {
return JavaFileObjects.forResource("AnnotationProcessorTestClass.java");
return JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.toolisticon.annotationprocessortoolkit.tools;

import com.google.testing.compile.JavaFileObjects;
import io.toolisticon.annotationprocessortoolkit.testhelper.AbstractAnnotationProcessorUnitTest;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AbstractUnitTestAnnotationProcessorClass;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfiguration;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfigurationBuilder;
import io.toolisticon.compiletesting.JavaFileObjectUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
Expand Down Expand Up @@ -138,8 +138,6 @@ protected void testCase(TypeElement element) {
MatcherAssert.assertThat(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElementOfKindType(typeElement), Matchers.nullValue());




}
}
)
Expand Down Expand Up @@ -251,7 +249,7 @@ protected void testCase(TypeElement element) {

@Override
protected JavaFileObject getSourceFileForCompilation() {
return JavaFileObjects.forResource("AnnotationProcessorTestClass.java");
return JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.toolisticon.annotationprocessortoolkit.tools;

import com.google.testing.compile.JavaFileObjects;
import io.toolisticon.annotationprocessortoolkit.testhelper.AbstractAnnotationProcessorIntegrationTest;
import io.toolisticon.annotationprocessortoolkit.testhelper.integrationtest.AnnotationProcessorIntegrationTestConfiguration;
import io.toolisticon.annotationprocessortoolkit.testhelper.integrationtest.AnnotationProcessorIntegrationTestConfigurationBuilder;
import io.toolisticon.annotationprocessortoolkit.tools.generators.FileObjectUtilsTestAnnotationProcessor;
import io.toolisticon.compiletesting.JavaFileObjectUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -32,9 +32,9 @@ public static List<Object[]> data() {
{
"Test valid usage",
AnnotationProcessorIntegrationTestConfigurationBuilder.createTestConfig()
.setSourceFileToCompile("testcases/generators/FilerUtilsTestClass.java")
.setSourceFileToCompile("/testcases/generators/FilerUtilsTestClass.java")
.compilationShouldSucceed()
.javaFileObjectShouldMatch(JavaFileObjects.forResource("testcases/generators/expectedResult.txt"))
.javaFileObjectShouldMatch(JavaFileObjectUtils.readFromResource("/testcases/generators/expectedResult.txt"))
.build()
},

Expand Down
Loading

0 comments on commit 076078a

Please sign in to comment.