Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update versions and fix style #16

Merged
merged 14 commits into from
Jan 17, 2025
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
jdk: [ 8, 11, 17 ]
jdk: [ 8, 11, 17, 21, 23 ]
runs-on: ubuntu-latest
steps:
- name: Pull Request Checkout
Expand Down
159 changes: 101 additions & 58 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
buildscript {
dependencies {
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
// Code formatting; defines targets "spotlessApply" and "spotlessCheck".
// https://github.com/diffplug/spotless/tags ; see tags starting "gradle/"
// Only works on JDK 11+.
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.22.0'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:7.0.2'
}
}
}

plugins {
id "java"
id "maven-publish"
// https://github.com/tbroyer/gradle-errorprone-plugin
id 'net.ltgt.errorprone' version '4.1.0'
}

repositories {
mavenCentral()
mavenLocal()
}

configurations {
Expand All @@ -26,60 +26,73 @@ configurations {
}

ext {
isJava8 = JavaVersion.current() == JavaVersion.VERSION_1_8
isJava11plus = JavaVersion.current() >= JavaVersion.VERSION_11

versions = [
checkerFramework: "3.32.0-eisop1",
checkerFramework: "3.42.0-eisop5",
errorproneJavacVersion: "9+181-r4173-1",
errorproneCoreVersion: "2.36.0",
]

// Keep in sync with the same variable in checker-framework/build.gradle
compilerArgsForRunningCF = [
"--add-exports",
"jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens",
"jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
'--add-exports',
'jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
'--add-exports',
'jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-exports',
'jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-exports',
'jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
'--add-exports',
'jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
'--add-exports',
'jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
'--add-exports',
'jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-exports',
'jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
'--add-opens',
'jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
]
}

sourceCompatibility = 1.8
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}

def checkerframework_local = false // Set this variable to [true] while using local version of checker framework.
def CHECKERFRAMEWORK = System.getenv("CHECKERFRAMEWORK")

ext {
isJava11plus = JavaVersion.current() >= JavaVersion.VERSION_11
}


dependencies {
// This dependency is found on compile classpath of this component and consumers.
// TODO: clean up implementation/localDeps duplication.
if (checkerframework_local) {
if (CHECKERFRAMEWORK == null) {
CHECKERFRAMEWORK = "../checker-framework/"
}
implementation files("${CHECKERFRAMEWORK}/checker/dist/checker-qual.jar")
implementation files("${CHECKERFRAMEWORK}/checker/dist/checker.jar")
localDeps files("${CHECKERFRAMEWORK}/checker/dist/checker.jar")
} else {
implementation "io.github.eisop:checker:${versions.checkerFramework}"
localDeps "io.github.eisop:checker:${versions.checkerFramework}"
implementation "io.github.eisop:checker-qual:${versions.checkerFramework}"
localDeps "io.github.eisop:checker-qual:${versions.checkerFramework}"
implementation "io.github.eisop:checker-util:${versions.checkerFramework}"
localDeps "io.github.eisop:checker-util:${versions.checkerFramework}"
}
implementation configurations.localDeps

compileOnly "com.google.errorprone:javac:9+181-r4173-1"
errorprone "com.google.errorprone:error_prone_core:${versions.errorproneCoreVersion}"
errorproneJavac "com.google.errorprone:javac:${versions.errorproneJavacVersion}"

// Testing
testImplementation "junit:junit:4.13.2"
testImplementation "io.github.eisop:framework-test:${versions.checkerFramework}"

errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
// https://mvnrepository.com/artifact/org.yaml/snakeyaml
implementation 'org.yaml:snakeyaml:2.2'
}
Expand All @@ -106,10 +119,6 @@ sourceSets {
}
}

tasks.withType(JavaCompile).all {
options.compilerArgs.add("-Xlint:all")
}

if (isJava11plus) {
apply plugin: 'com.diffplug.spotless'
assemble.dependsOn(":spotlessApply")
Expand All @@ -121,35 +130,36 @@ if (isJava11plus) {
importOrder('com', 'jdk', 'lib', 'lombok', 'org', 'java', 'javax')
formatAnnotations().addTypeAnnotation("Unique").addTypeAnnotation("Shared").addTypeAnnotation("Disappear").addTypeAnnotation("Bottom")
}
format "misc", {
target '**/*.md', "**/.gitignore"
trimTrailingWhitespace()
leadingSpacesToTabs()
endWithNewline()
}
groovyGradle {
target '**/*.gradle'
greclipse() // which formatter Spotless should use to format .gradle files.
indentWithSpaces(4)
leadingTabsToSpaces(4)
trimTrailingWhitespace()
// endWithNewline() // Don't want to end empty files with a newline
}
format "misc", {
target '**/*.md', "**/.gitignore"
trimTrailingWhitespace()
indentWithTabs()
endWithNewline()
}
}
}


// Run `./gradlew publishToMavenLocal` to publish your checker to your local Maven repository.
publishing {
publications {
maven(MavenPublication) {
groupId = "org.checkerframework"
groupId = "io.github.eisop"
artifactId = "linear-checker"
version = "0.1-SNAPSHOT"
from components.java
if (checkerframework_local) {
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode("groupId", "org.checkerframework")
dependencyNode.appendNode("groupId", "io.github.eisop")
dependencyNode.appendNode("artifactId", "checker")
dependencyNode.appendNode("version", "${versions.checkerFramework}")
dependencyNode.appendNode("systemPath", projectDir.toString() + "$buildDir/libs/checker.jar")
Expand All @@ -159,32 +169,28 @@ publishing {
}
}

test {
if (!isJava8) {
jvmArgs += compilerArgsForRunningCF
}

if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
}
}

test.dependsOn(":assemble")

afterEvaluate {
// Configure JUnit tests
tasks.withType(Test) {
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
jvmArgs += compilerArgsForRunningCF
}

testLogging {
// Always run the tests
outputs.upToDateWhen { false }
// The following prints out each time a test is passed.
events "passed", "skipped", "failed", "standardOut", "standardError"
// Show the found unexpected diagnostics and expected diagnostics not found.
exceptionFormat "full"
showExceptions true
showCauses true
showStackTraces true
showStandardStreams true
exceptionFormat = "full"
showExceptions = true
showCauses = true
showStackTraces = true
showStandardStreams = true
}
// After each test, print a summary.
afterSuite { desc, result ->
Expand All @@ -200,6 +206,43 @@ afterEvaluate {
}
}
}

// Code adapted from checker-framework:
// https://github.com/eisop/checker-framework/blob/567084f11278273b33289d138d9d2a1b513d3c35/build.gradle#L226
tasks.withType(JavaCompile) { compilationTask ->
sourceCompatibility = 8
targetCompatibility = 8
options.failOnError = true
options.deprecation = true
options.compilerArgs += [
'-g',
'-Werror',
// -options because source 8 is obsolete on newer JDKs
"-Xlint:all,-options",
]
options.encoding = 'UTF-8'
options.fork = true
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
options.forkOptions.jvmArgs += [
"-Xbootclasspath/p:${configurations.errorproneJavac.asPath}".toString()
]
options.errorprone.enabled = false
} else {
options.errorprone.enabled = (JavaVersion.current() >= JavaVersion.VERSION_17)
options.forkOptions.jvmArgs += [
'--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.main=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
]
}
}
}

clean.doFirst {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
43 changes: 30 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +82,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +133,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,18 +200,28 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
Loading
Loading