diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 77824e1..db3155b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,6 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - - run: | - ./gradlew spotlessCheck build - - run: | - ./gradlew jspecifySamplesTest -x ensureCheckerFrameworkBuilt + - run: ./initialize-project + - run: ./gradlew spotlessCheck build + - run: ./gradlew jspecifySamplesTest -x ensureCheckerFrameworkBuilt diff --git a/README.md b/README.md index 2bf5938..7517e51 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,15 @@ looking to try it out, here are some instructions, *which might fail* and need to be worked around as described later in this section: ``` -# Build the checker: +# Download the checker, its fork of Checker Framework, and the unreleased JSpecify code and samples: $ git clone https://github.com/jspecify/nullness-checker-for-checker-framework - $ cd nullness-checker-for-checker-framework +$ ./initialize-project -$ ./gradlew assemble +# Build it: +$ ./gradlew assemble # Use it: diff --git a/build.gradle b/build.gradle index c8c85db..f6ec2e3 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,6 @@ ext { parentDir = file("${rootDir}/../").absolutePath cfHome = "${parentDir}/checker-framework" jspecifyHome = "${parentDir}/jspecify" - plumeScripts = "${rootDir}/.plume-scripts" } sourceCompatibility = 1.9 @@ -101,64 +100,26 @@ spotless { } task ensureCheckerFrameworkBuilt() { - description 'Clone or update the Checker Framework and then build it and all dependencies' + description 'Build the Checker Framework and all dependencies' doLast { - if (!file(plumeScripts).exists()) { + /* Introduce an autoUpdateCF variable if we want to support that usage. + if (autoUpdateCF) { exec { - workingDir "${rootDir}" + workingDir cfHome executable 'git' - args = ['clone', '-q', '--depth', '1', 'https://github.com/plume-lib/plume-scripts.git', plumeScripts] + args = ['pull', '-q'] + ignoreExitValue = true } - } - def jspecifyExisted = file(jspecifyHome).exists() - - if (file(cfHome).exists()) { - /* Introduce an autoUpdateCF variable if we want to support that usage. - if (autoUpdateCF) { - exec { - workingDir cfHome - executable 'git' - args = ['pull', '-q'] - ignoreExitValue = true - } - } else { - println "Found existing ${cfHome}. Use -PautoUpdateCF=true if you want to git pull automatically." - } - */ } else { - exec { - workingDir rootDir - executable "${plumeScripts}/git-clone-related" - args = ['jspecify', 'checker-framework', '-q'] - } + println "Found existing ${cfHome}. Use -PautoUpdateCF=true if you want to git pull automatically." } + */ exec { workingDir cfHome executable './gradlew' // Skip Javadoc to save time. Perform a release build so that we repackage javaparser (not that that seems to matter here, but it's consistent with how the Checker Framework would be deployed). args = ['cloneAndBuildDependencies', '-x', 'javadoc', '-x', 'allJavadoc', '-Prelease=true'] } - - // We test using some modified samples in a different branch of the jspecify repo, so we want to change to that branch. - // However, if there was a JSpecify client to begin with, don't mess with it, as the developer may be running tests in a different branch. - if (!jspecifyExisted) { - // The CF build process uses --single-branch when it clones the jspecify repo, so the resulting clone doesn't have the branch we want. - exec { - workingDir jspecifyHome - executable 'git' - args = ['config', 'remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*'] - } - exec { - workingDir jspecifyHome - executable 'git' - args = ['fetch'] - } - exec { - workingDir jspecifyHome - executable 'git' - args = ['checkout', '-q', 'samples-google-prototype'] - } - } } } diff --git a/initialize-project b/initialize-project new file mode 100755 index 0000000..c5e6be9 --- /dev/null +++ b/initialize-project @@ -0,0 +1,22 @@ +#!/bin/bash + +set -eu + +readonly PLUME_SCRIPTS=.plume-scripts +readonly CHECKER_FRAMEWORK=../checker-framework +readonly JSPECIFY=../jspecify + +if [[ ! -d "${PLUME_SCRIPTS}" ]]; then + git clone -q --depth 1 https://github.com/plume-lib/plume-scripts.git \ + "${PLUME_SCRIPTS}" +fi + +if [[ ! -d "${CHECKER_FRAMEWORK}" ]]; then + "${PLUME_SCRIPTS}"/git-clone-related jspecify checker-framework -q +fi + +if [[ ! -d "${JSPECIFY}" ]]; then + # We test using some modified samples in a different branch of the jspecify + # repo, so we check out that branch. + "${PLUME_SCRIPTS}"/git-clone-related --upstream-branch samples-google-prototype jspecify jspecify -q +fi