Skip to content

Commit

Permalink
Update versions and fix style (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdietl authored Jan 17, 2025
1 parent f6ed135 commit e82e58e
Show file tree
Hide file tree
Showing 13 changed files with 320 additions and 174 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
version: 2
updates:
- package-ecosystem: "gradle"
directories:
- "/"
- "/linear-checker-qual-android/"
- "/linear-checker-qual/"
schedule:
interval: "daily"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
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
Loading

0 comments on commit e82e58e

Please sign in to comment.