Skip to content

Commit 69516ce

Browse files
authored
v1.3.0 (#7)
* #6 - Make @ReflectableClass a @repeatable annotation
1 parent 4aeff1a commit 69516ce

File tree

7 files changed

+132
-37
lines changed

7 files changed

+132
-37
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8

build.gradle

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,25 @@
1-
buildscript {
2-
repositories {
3-
maven { url "https://plugins.gradle.org/m2/" }
4-
jcenter()
5-
}
6-
dependencies {
7-
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.27.1"
8-
}
9-
}
10-
111
plugins {
12-
id "com.github.spotbugs" version "4.5.0"
2+
id 'java'
3+
id 'maven-publish'
4+
id 'signing'
5+
id 'checkstyle'
6+
id 'com.diffplug.spotless' version '6.17.0'
7+
id 'com.github.spotbugs' version '5.0.14'
8+
id 'com.github.ben-manes.versions' version '0.46.0'
139
}
1410

15-
apply plugin: 'java-library'
16-
apply plugin: 'maven-publish'
17-
apply plugin: 'checkstyle'
18-
apply plugin: 'signing'
19-
apply plugin: 'com.diffplug.gradle.spotless'
20-
21-
sourceCompatibility = JavaVersion.VERSION_11
22-
targetCompatibility = JavaVersion.VERSION_11
23-
2411
group 'com.formkiq'
25-
version '1.2.0'
12+
version '1.3.0'
2613

2714
dependencies {
28-
annotationProcessor group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc7'
29-
compileOnly group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc7'
30-
compileOnly group: 'com.google.auto.service', name: 'auto-service-annotations', version: '1.0-rc7'
15+
annotationProcessor group: 'com.google.auto.service', name: 'auto-service', version: '1.0.1'
16+
compileOnly group: 'com.google.auto.service', name: 'auto-service', version: '1.0.1'
17+
compileOnly group: 'com.google.auto.service', name: 'auto-service-annotations', version: '1.0.1'
3118

32-
implementation group: 'com.formkiq', name: 'graalvm-annotations', version: '1.1.0'
33-
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
19+
implementation group: 'com.formkiq', name: 'graalvm-annotations', version: '1.2.0'
20+
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
3421
testImplementation group: 'junit', name: 'junit', version:'4.+'
35-
testImplementation group: 'com.google.testing.compile', name: 'compile-testing', version: '0.18'
22+
testImplementation group: 'com.google.testing.compile', name: 'compile-testing', version: '0.21.0'
3623
}
3724

3825
compileJava {
@@ -45,14 +32,16 @@ spotless {
4532
}
4633
}
4734

35+
spotbugs {
36+
excludeFilter = file("$rootDir/config/gradle/spotbugs-exclude.xml")
37+
}
38+
4839
spotbugsMain {
49-
reports {
50-
html {
51-
enabled = true
52-
destination = file("$buildDir/reports/spotbugs/main/spotbugs.html")
53-
stylesheet = 'fancy-hist.xsl'
54-
}
40+
reports {
41+
html {
42+
enabled = true
5543
}
44+
}
5645
}
5746

5847
checkstyle {
@@ -84,6 +73,10 @@ check {
8473
java {
8574
withJavadocJar()
8675
withSourcesJar()
76+
77+
toolchain {
78+
languageVersion.set(JavaLanguageVersion.of(11))
79+
}
8780
}
8881

8982
javadoc {

config/gradle/spotbugs-exclude.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<!-- Spotbugs filtering.
19+
20+
Spotbugs is a static code analysis tool run as part of the "check" phase of the build.
21+
This file dictates which categories of bugs and individual false positives that we suppress.
22+
23+
For a detailed description of spotbugs bug categories, see https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html
24+
-->
25+
<FindBugsFilter>
26+
27+
<!-- false positive in Java 11, see https://github.com/spotbugs/spotbugs/issues/756 -->
28+
<Match>
29+
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
30+
</Match>
31+
32+
<!-- false positive in Java 11, see https://github.com/spotbugs/spotbugs/issues/756 -->
33+
<Match>
34+
<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
35+
</Match>
36+
37+
<Match>
38+
<Bug pattern="EI_EXPOSE_REP"/>
39+
<OR>
40+
<Class name="com.formkiq.graalvm.processors.Reflect"/>
41+
</OR>
42+
</Match>
43+
44+
<Match>
45+
<Bug pattern="EI_EXPOSE_REP2"/>
46+
<OR>
47+
<Class name="com.formkiq.graalvm.processors.Reflect"/>
48+
</OR>
49+
</Match>
50+
51+
</FindBugsFilter>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4+
networkTimeout=10000
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

spotless.eclipseformat.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
154154
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
155155
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/>
156-
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
156+
<setting id="org.eclipse.jdt.core.formatter.alignment_for_MODULE_statements" value="16"/>
157157
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
158158
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
159159
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>

src/main/java/com/formkiq/graalvm/processors/GraalvmReflectAnnontationProcessor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"com.formkiq.graalvm.annotations.Reflectable",
6262
"com.formkiq.graalvm.annotations.ReflectableImport",
6363
"com.formkiq.graalvm.annotations.ReflectableClasses",
64-
"com.formkiq.graalvm.annotations.ReflectableClass"
64+
"com.formkiq.graalvm.annotations.ReflectableClass",
65+
"com.formkiq.graalvm.annotations.ReflectableClass.ReflectableClasses"
6566
})
6667
@SupportedSourceVersion(SourceVersion.RELEASE_11)
6768
public class GraalvmReflectAnnontationProcessor extends AbstractProcessor {
@@ -344,7 +345,11 @@ private void processReflectableClasses(final RoundEnvironment roundEnv) {
344345
}
345346
}
346347

347-
for (Element element : roundEnv.getElementsAnnotatedWith(ReflectableClass.class)) {
348+
Set<? extends Element> reflectableClasses =
349+
roundEnv.getElementsAnnotatedWithAny(
350+
Set.of(ReflectableClass.class, ReflectableClass.ReflectableClasses.class));
351+
352+
for (Element element : reflectableClasses) {
348353
String className = getClassName(element);
349354
LOGGER.log(LOGLEVEL, "processing 'ReflectableClasses' annotation on class " + className);
350355

src/test/java/com/formkiq/graalvm/processors/GraalvmReflectAnnontationProcessorTest.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,49 @@ public void testReflectableClass03() throws IOException {
245245
assertEquals(Boolean.TRUE, map.get(0).get("allDeclaredFields"));
246246
}
247247

248+
/**
249+
* test multiple @ReflectableClass.
250+
*
251+
* @throws IOException IOException
252+
*/
253+
@Test
254+
public void testReflectableClass04() throws IOException {
255+
Compilation compilation =
256+
javac()
257+
.withProcessors(new GraalvmReflectAnnontationProcessor())
258+
.compile(
259+
JavaFileObjects.forSourceString(
260+
"Test",
261+
"package test;\n"
262+
+ "import com.formkiq.graalvm.annotations.*;\n"
263+
+ "@ReflectableClass("
264+
+ "className=com.formkiq.graalvm.processors.Test5.Test5Inner.class"
265+
+ ")\n"
266+
+ "@ReflectableClass("
267+
+ "className=com.formkiq.graalvm.processors.Test4.class"
268+
+ ")\n"
269+
+ "public class Test { }\n"));
270+
271+
List<Map<String, Object>> map = getReflectConf(compilation);
272+
273+
assertEquals(2, map.size());
274+
assertEquals("com.formkiq.graalvm.processors.Test4", map.get(0).get("name"));
275+
assertEquals(Boolean.TRUE, map.get(0).get("allPublicConstructors"));
276+
assertEquals(Boolean.TRUE, map.get(0).get("allPublicMethods"));
277+
assertEquals(Boolean.TRUE, map.get(0).get("allPublicFields"));
278+
assertEquals(Boolean.FALSE, map.get(0).get("allDeclaredConstructors"));
279+
assertEquals(Boolean.TRUE, map.get(0).get("allDeclaredMethods"));
280+
assertEquals(Boolean.TRUE, map.get(0).get("allDeclaredFields"));
281+
282+
assertEquals("com.formkiq.graalvm.processors.Test5$Test5Inner", map.get(1).get("name"));
283+
assertEquals(Boolean.TRUE, map.get(1).get("allPublicConstructors"));
284+
assertEquals(Boolean.TRUE, map.get(1).get("allPublicMethods"));
285+
assertEquals(Boolean.TRUE, map.get(1).get("allPublicFields"));
286+
assertEquals(Boolean.FALSE, map.get(1).get("allDeclaredConstructors"));
287+
assertEquals(Boolean.TRUE, map.get(1).get("allDeclaredMethods"));
288+
assertEquals(Boolean.TRUE, map.get(1).get("allDeclaredFields"));
289+
}
290+
248291
/**
249292
* testReflectableImportFile01.
250293
*

0 commit comments

Comments
 (0)