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

Gradle build cleanup #110

Merged
merged 16 commits into from
Nov 17, 2023
Merged
70 changes: 33 additions & 37 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,37 @@ configurations {
}

ext {
parentDir = file("${rootDir}/../").absolutePath

cfHome = "${parentDir}/checker-framework"
cfVersion = "3.21.5-SNAPSHOT"

jspecifyHome = "${parentDir}/jspecify"
checkerFramework = gradle.includedBuild("checker-framework")
jspecify = gradle.includedBuild("jspecify")
}

java {
sourceCompatibility = 1.9
}

dependencies {
implementation "org.checkerframework:checker:${cfVersion}"
implementation "org.checkerframework:checker-qual:${cfVersion}"
implementation "org.checkerframework:framework:${cfVersion}"
implementation "org.checkerframework:javacutil:${cfVersion}"

implementation "org.jspecify:jspecify:0.0.0-SNAPSHOT"

// Testing
testImplementation 'junit:junit:4.12'
// The jsr305 dep lets us use its annotations in some of the sample inputs we test against.
testImplementation 'com.google.code.findbugs:jsr305:3.0.2'
testImplementation 'com.google.guava:guava:31.1-jre'
testImplementation 'org.plumelib:plume-util:1.5.5'
testImplementation "org.checkerframework:framework-test:${cfVersion}"
testImplementation project(":conformance")

errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
errorprone "com.google.errorprone:error_prone_core:2.18.0"
implementation libs.checkerFramework.checker
implementation libs.checkerFramework.checker.qual
implementation libs.checkerFramework.framework
implementation libs.checkerFramework.javacutil

implementation libs.jspecify

testImplementation libs.checkerFramework.framework.test
testImplementation libs.guava
testImplementation libs.junit
testImplementation libs.jspecify.conformance
testRuntimeOnly libs.jsr305 // jsr305 annotations are in some of the samples

errorproneJavac libs.errorProne.javac
errorprone libs.errorProne.core
}

// Assemble checker-framework when assembling the reference checker.
assemble.dependsOn(gradle.includedBuild("checker-framework").task(":assemble"))
assemble.dependsOn(gradle.includedBuild("jspecify").task(":assemble"))
assemble.dependsOn(checkerFramework.task(":assemble"))
assemble.dependsOn(jspecify.task(":assemble"))

tasks.withType(JavaCompile).all {
tasks.withType(JavaCompile).configureEach {
options.compilerArgs.add("-Xlint:all")
// ErrorProne makes suppressing these easier
options.compilerArgs.add("-Xlint:-fallthrough")
Expand All @@ -75,10 +68,11 @@ tasks.withType(JavaCompile).all {
"resources",
"tree",
"util",
].collect { """--add-exports=jdk.compiler/com.sun.tools.javac.$it=ALL-UNNAMED""" })
]
.collect { "--add-exports=jdk.compiler/com.sun.tools.javac.$it=ALL-UNNAMED" })
}

tasks.withType(Test) {
tasks.withType(Test).configureEach {
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
}
Expand All @@ -91,7 +85,7 @@ tasks.withType(Test) {
"main",
"processing",
"tree",
"util"
"util",
]
.collect { "--add-opens=jdk.compiler/com.sun.tools.javac.$it=ALL-UNNAMED" })

Expand All @@ -109,13 +103,13 @@ test {
inputs.files("${rootDir}/tests/minimal")
}

task jspecifySamplesTest(type: Test) {
tasks.register('jspecifySamplesTest', Test) {
description = 'Run the checker against the JSpecify samples.'
group = 'verification'
include '**/NullSpecTest$Lenient.class'
include '**/NullSpecTest$Strict.class'

inputs.files("${jspecifyHome}/samples")
inputs.files("${jspecify.projectDir}/samples")
}

TaskProvider<Test> conformanceTest(String name, String testDirectory, String reportFile) {
Expand All @@ -128,9 +122,9 @@ TaskProvider<Test> conformanceTest(String name, String testDirectory, String rep
}
}

conformanceTest('conformanceTest', "${jspecifyHome}/conformance", 'tests/ConformanceTest-report.txt')
conformanceTest('conformanceTest', "${jspecify.projectDir}/conformance", 'tests/ConformanceTest-report.txt')

conformanceTest('conformanceTestOnSamples', "${jspecifyHome}/samples", 'tests/ConformanceTestOnSamples-report.txt')
conformanceTest('conformanceTestOnSamples', "${jspecify.projectDir}/samples", 'tests/ConformanceTestOnSamples-report.txt')

clean.doFirst {
delete "${rootDir}/tests/build/"
Expand All @@ -145,15 +139,17 @@ clean.doFirst {
See https://github.com/jspecify/jspecify-reference-checker/issues/81
*/

def cfQualJar = file("${cfHome}/checker-qual/build/libs/checker-qual-${cfVersion}.jar")
def cfQualJar =
checkerFramework.projectDir.toPath()
.resolve("checker-qual/build/libs/checker-qual-${libs.versions.checkerFramework.get()}.jar")

if (!cfQualJar.exists()) {
if (!cfQualJar.toFile().exists()) {
mkdir(cfQualJar.parent)
exec {
executable 'jar'
args = [
'cf',
cfQualJar.path,
cfQualJar,
buildFile.path // Use this build script file!
]
}
Expand Down
8 changes: 4 additions & 4 deletions conformance/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'org.jspecify'
version '0.1'
version '0.0.0-SNAPSHOT'

repositories {
mavenCentral()
Expand All @@ -14,9 +14,9 @@ java {
}

dependencies {
api 'com.google.guava:guava:31.1-jre'
implementation "com.google.truth:truth:1.1.3"
implementation "org.jspecify:jspecify:0.0.0-SNAPSHOT"
api libs.guava
implementation libs.jspecify
implementation libs.truth
}

test {
Expand Down
26 changes: 26 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
rootProject.name = "jspecify-reference-checker"
include 'conformance'

// Lets the main build depend on the conformance subproject as org.jspecify:conformance.
// See https://docs.gradle.org/current/userguide/composite_builds.html#included_build_declaring_substitutions
includeBuild(".")

def initializeProject() {
exec {
executable './initialize-project'
Expand All @@ -19,3 +23,25 @@ includeBuild("../jdk") {
includeBuild("../checker-framework") {
initializeProject()
}

dependencyResolutionManagement {
versionCatalogs {
libs {
version("checkerFramework", "3.21.5-SNAPSHOT")

library("checkerFramework-checker", "org.checkerframework", "checker").versionRef("checkerFramework")
netdpb marked this conversation as resolved.
Show resolved Hide resolved
library("checkerFramework-checker-qual", "org.checkerframework", "checker-qual").versionRef("checkerFramework")
library("checkerFramework-framework", "org.checkerframework", "framework").versionRef("checkerFramework")
library("checkerFramework-framework-test", "org.checkerframework", "framework-test").versionRef("checkerFramework")
library("checkerFramework-javacutil", "org.checkerframework", "javacutil").versionRef("checkerFramework")
library("errorProne-core", "com.google.errorprone:error_prone_core:2.18.0")
library("errorProne-javac", "com.google.errorprone:javac:9+181-r4173-1")
library("guava", "com.google.guava:guava:31.1-jre")
library("jspecify", "org.jspecify:jspecify:0.0.0-SNAPSHOT")
library("jspecify-conformance", "org.jspecify:conformance:0.0.0-SNAPSHOT")
library("jsr305", "com.google.code.findbugs:jsr305:3.0.2")
library("junit", "junit:junit:4.12")
library("truth", "com.google.truth:truth:1.1.3")
}
}
}