Skip to content

Commit

Permalink
add a module testing error-prone integration
Browse files Browse the repository at this point in the history
See google/error-prone#3522 for details why this test
exists. TL;DR error-prone may or may not break with toolchains enabled for some
reason.
  • Loading branch information
Okeanos committed Aug 28, 2024
1 parent 0752b14 commit db559f9
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 0 deletions.
142 changes: 142 additions & 0 deletions error-prone-integration/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>

<parent>
<artifactId>maven-toolchains-exploration</artifactId>
<groupId>com.nikolasgrottendieck</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>error-prone-integration</artifactId>

<properties>
<java.version>21</java.version>
<maven.compiler.release>${java.version}</maven.compiler.release>
<!--
Version Range Specification:
https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
-->
<toolchain.jdk.version>[${java.version},${parsedVersion.nextMajorVersion})</toolchain.jdk.version>

<error-prone.version>2.30.0</error-prone.version>
<findbugs-jsr305.version>3.0.2</findbugs-jsr305.version>
<nullaway.version>0.11.2</nullaway.version>
</properties>

<build>
<plugins>
<!--
Plugin declaration order is the deciding factor when the same phase is targeted
builder-helper-maven-plugin has to execute before maven-toolchains-plugin or else
the expected property will not be available because the selected goals run in the
same phase by default (`validate`).
See:
- https://maven.apache.org/ref/3.9.8/maven-core/lifecycles.html
- https://www.mojohaus.org/build-helper-maven-plugin/parse-version-mojo.html
- https://maven.apache.org/plugins/maven-toolchains-plugin/select-jdk-toolchain-mojo.html
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>parse-version</goal>
</goals>
<configuration>
<versionString>${java.version}</versionString>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>echo</goal>
</goals>
<phase>validate</phase>
<configuration>
<message>Version properties:${line.separator}java.version:
'${java.version}'${line.separator}parsedVersion.nextMajorVersion:
'${parsedVersion.nextMajorVersion}'${line.separator}toolchain.jdk.version:
'${toolchain.jdk.version}'
</message>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>select-jdk-toolchain</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<!--
Treat all warnings as errors as proposed in https://github.com/google/error-prone/issues/424
-->
<arg>-Werror</arg>
<arg>-XDcompilePolicy=simple</arg>
<!--
For details about the standard bug patterns check:
- ErrorProne: https://errorprone.info/bugpatterns
- NullAway: https://github.com/uber/NullAway/wiki/Configuration
Syntax as described here: https://errorprone.info/docs/flags#maven
-->
<arg>
-Xplugin:ErrorProne -Xep:DeduplicateConstants -Xep:DepAnn -Xep:InsecureCryptoUsage -Xep:IterablePathParameter -Xep:LongLiteralLowerCaseSuffix -Xep:PackageLocation:ERROR -Xep:StaticQualifiedUsingExpression -Xep:SystemExitOutsideMain -Xep:AvoidObjectArrays -Xep:CatchingUnchecked -Xep:CheckedExceptionNotThrown -Xep:DifferentNameButSame -Xep:EqualsBrokenForNull -Xep:InitializeInline -Xep:InterfaceWithOnlyStatics -Xep:MissingDefault -Xep:PreferJavaTimeOverload -Xep:PreferredInterfaceType -Xep:RedundantThrows -Xep:StatementSwitchToExpressionSwitch -Xep:SystemOut -Xep:TimeUnitMismatch -Xep:UnnecessarilyFullyQualified -Xep:UnnecessarilyUsedValue -Xep:UnnecessarilyVisible -Xep:UnnecessaryAnonymousClass -Xep:UnnecessaryDefaultInEnumSwitch -Xep:UnnecessaryOptionalGet -Xep:UnusedException -Xep:Varifier -Xep:YodaCondition -Xep:FieldCanBeFinal:WARN -Xep:FieldCanBeLocal:WARN -Xep:FieldCanBeStatic:WARN -Xep:FieldMissingNullable:WARN -Xep:ParameterMissingNullable:WARN -Xep:PrivateConstructorForUtilityClass:WARN -Xep:RemoveUnusedImports:WARN -Xep:ReturnMissingNullable:WARN -Xep:ReturnsNullCollection:WARN -Xep:UseEnumSwitch:WARN -XepExcludedPaths:.*/src/test/.* -XepOpt:NullAway:AnnotatedPackages=com.nikolasgrottendieck -XepOpt:NullAway:ExcludedFieldAnnotations=org.springframework.beans.factory.annotation.Value
</arg>
<!--
Compiler options for Java >= 16 declared in a Maven Toolchains compatible fashion
See https://errorprone.info/docs/installation#maven
-->
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${findbugs-jsr305.version}</version>
</path>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>${error-prone.version}</version>
</path>
<path>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>${nullaway.version}</version>
</path>
</annotationProcessorPaths>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.nikolasgrottendieck;

class HelloWorldApp {
private HelloWorldApp() {}

@SuppressWarnings("SystemOut")
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.nikolasgrottendieck;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

class JavaVersionTest {
@Test
public void runningCorrectJavaVersion() {
assertEquals(21, Runtime.version().feature());
}
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<module>static-ranged-calculated</module>
<module>static-ranged-manual</module>
<module>static-ranged-semver</module>
<module>error-prone-integration</module>
</modules>

<properties>
Expand Down

0 comments on commit db559f9

Please sign in to comment.