Skip to content

Commit

Permalink
Bump CI from java 15 to 17 (#1094)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Jan 13, 2022
2 parents 659ecaa + e578a9d commit 32bdfc6
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Expand Up @@ -77,11 +77,11 @@ jobs:
docker:
- image: cimg/openjdk:11.0
<<: *test_nomaven
test_nomaven_15:
# latest JDK, replace with 16 when it comes out
test_nomaven_17:
# latest JDK
<<: *env_gradle_large
docker:
- image: cimg/openjdk:15.0
- image: cimg/openjdk:17.0
<<: *test_nomaven
test_justmaven_11:
<< : *env_gradle
Expand Down Expand Up @@ -275,7 +275,7 @@ workflows:
- test_nomaven_11:
requires:
- assemble_testClasses
- test_nomaven_15:
- test_nomaven_17:
requires:
- assemble_testClasses
- test_npm_8:
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -10,6 +10,8 @@ This document is intended for Spotless developers.
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).

## [Unreleased]
### Changed
* Bump CI from Java 15 to 17 ([#1094](https://github.com/diffplug/spotless/pull/1094)).

## [2.22.0] - 2022-01-13
### Added
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
@@ -1,6 +1,5 @@
# To fix metaspace errors
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8
name=spotless
description=Spotless - keep your code spotless with Gradle
org=diffplug
Expand Down
1 change: 0 additions & 1 deletion gradle/java-publish.gradle
Expand Up @@ -66,7 +66,6 @@ javadoc {
options.addStringOption('source', '8')
// setup the header
options.header javadocInfo
options.footer javadocInfo
// setup links
options.linksOffline('https://docs.oracle.com/javase/8/docs/api/', "${dotdotGradle}/javadoc/java8")
options.linksOffline('https://docs.gradle.org/2.14/javadoc/', "${dotdotGradle}/javadoc/gradle")
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 DiffPlug
* Copyright 2016-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,14 +48,26 @@ public enum GradleVersionSupport {
final String version;

GradleVersionSupport(String version) {
if (Jvm.version() >= 15) {
// the first version with support for Java 15+
switch (Jvm.version()) {
case 20:
case 19:
case 18:
// TODO: https://docs.gradle.org/current/userguide/compatibility.html
case 17:
this.version = "7.3";
break;
case 16:
this.version = "7.0";
break;
case 15:
this.version = "6.7";
} else if (Jvm.version() >= 14) {
// the first version with support for Java 14+
break;
case 14:
this.version = "6.3";
} else {
break;
default:
this.version = version;
break;
}
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2021 DiffPlug
* Copyright 2020-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,7 +53,7 @@ void withinBlocksTourDeForce() throws IOException {
" custom 'lowercase', { str -> str.toLowerCase() }",
" }",
" withinBlocks 'java only', '\\n```java\\n', '\\n```\\n', JavaExtension, {",
" googleJavaFormat()",
" googleJavaFormat('1.2')",
" }",
" }",
"}");
Expand Down
Expand Up @@ -41,6 +41,7 @@

import com.diffplug.common.base.Unhandled;
import com.diffplug.common.io.Resources;
import com.diffplug.spotless.Jvm;
import com.diffplug.spotless.ResourceHarness;

public class MavenIntegrationHarness extends ResourceHarness {
Expand Down Expand Up @@ -81,6 +82,17 @@ public class MavenIntegrationHarness extends ResourceHarness {
@BeforeEach
void gitAttributes() throws IOException {
setFile(".gitattributes").toContent("* text eol=lf");
if (Jvm.version() >= 16) {
// for GJF https://github.com/diffplug/spotless/issues/834
setFile(".mvn/jvm.config").toContent(
"--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" +
" --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED" +
" --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED" +
" --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED" +
" --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" +
// this last line is for Detekt
" --add-opens java.base/java.lang=ALL-UNNAMED");
}
// copy the mvnw resources
copy("mvnw").setExecutable(true);
copy("mvnw.cmd");
Expand Down
15 changes: 14 additions & 1 deletion testlib/build.gradle
Expand Up @@ -21,7 +21,20 @@ dependencies {
// we'll hold the testlib to a low standard (prize brevity)
spotbugs { reportLevel = 'high' } // low|medium|high (low = sensitive to even minor mistakes)

test { useJUnitPlatform() }
test {
useJUnitPlatform()
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_16)) {
// for GJF https://github.com/diffplug/spotless/issues/834
def args = [
'--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
]
jvmArgs args
}
}

apply from: rootProject.file('gradle/special-tests.gradle')

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 DiffPlug
* Copyright 2016-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@

import static org.junit.jupiter.api.condition.JRE.JAVA_11;
import static org.junit.jupiter.api.condition.JRE.JAVA_13;
import static org.junit.jupiter.api.condition.JRE.JAVA_15;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand All @@ -41,7 +42,7 @@ void jvm13Features() throws Exception {
}

@Test
@EnabledForJreRange(min = JAVA_11) // google-java-format requires JRE 11+
@EnabledForJreRange(min = JAVA_11, max = JAVA_15) // google-java-format requires JRE 11+
void behavior18() throws Exception {
FormatterStep step = GoogleJavaFormatStep.create("1.8", TestProvisioner.mavenCentral());
StepHarness.forStep(step)
Expand Down

0 comments on commit 32bdfc6

Please sign in to comment.