Skip to content

Commit

Permalink
Update from upstream 2024-06-24 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdietl authored Jun 25, 2024
2 parents b854057 + 013db8b commit 0108f87
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 62 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ jobs:

strategy:
matrix:
java: [ '11', '17', '21' ]
java: [ '8', '11', '17', '21' ]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
show-progress: false
- name: Set up JDK
uses: actions/setup-java@v4
with:
Expand All @@ -27,4 +30,5 @@ jobs:
- name: ./gradlew requireJavadoc
run: ./gradlew requireJavadoc
- name: ./gradlew spotlessCheck
if: ${{ matrix.java != '8' }}
run: ./gradlew spotlessCheck
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
build
.gradle
build

# Compiled class file
*.class

# Log file
Expand All @@ -14,14 +13,19 @@ build
.mtj.tmp/

# Package Files #
*.jar
*.jar # Need to commit gradle-wrapper.jar file
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# .jar file not to ignore
!gradle/wrapper/gradle-wrapper.jar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# IDE files
.idea
.vscode
4 changes: 2 additions & 2 deletions .setup-CF.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export SHELLOPTS

export JAVA_HOME=${JAVA_HOME:-$(dirname $(dirname $(readlink -f $(which javac))))}

git -C /tmp clone --depth 1 -q https://github.com/plume-lib/plume-scripts.git
git -C /tmp clone --depth 1 -q https://github.com/eisop-plume-lib/git-scripts.git

export CHECKERFRAMEWORK="${CHECKERFRAMEWORK:-$(pwd -P)/../checker-framework}"

## Build Checker Framework
/tmp/plume-scripts/git-clone-related eisop checker-framework ${CHECKERFRAMEWORK}
/tmp/git-scripts/git-clone-related eisop checker-framework ${CHECKERFRAMEWORK}

(cd $CHECKERFRAMEWORK && ./gradlew assembleForJavac)

Expand Down
137 changes: 88 additions & 49 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
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.25.0'
}
}
}

plugins {
id 'java'
id 'application'

// To create a fat jar build/libs/...-all.jar, run: ./gradlew shadowJar
id 'com.github.johnrengelman.shadow' version '8.1.1'

// Code formatting; defines targets "spotlessApply" and "spotlessCheck"
// Requires JDK 11 or higher; the plugin crashes under JDK 8.
id 'com.diffplug.spotless' version '6.25.0'

// Error Prone linter
id('net.ltgt.errorprone') version '3.1.0'
id('net.ltgt.errorprone') version '4.0.1'

// Checker Framework pluggable type-checking
id 'org.checkerframework' version '0.6.38'
id 'org.checkerframework' version '0.6.40'
}

repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}

ext.errorproneVersion = '2.28.0'

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

dependencies {
implementation 'com.google.guava:guava:33.1.0-jre'
implementation 'com.google.guava:guava:33.2.1-jre'
implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
implementation 'xom:xom:1.3.9'

compileOnly "com.google.errorprone:error_prone_annotations:${errorproneVersion}"
errorprone("com.google.errorprone:error_prone_core:${errorproneVersion}")

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}
Expand All @@ -33,8 +50,10 @@ application {
mainClass = 'org.plumelib.htmlprettyprint.HtmlPrettyPrint'
}

sourceCompatibility = 11
targetCompatibility = 11
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

test {
useJUnitPlatform {
Expand All @@ -43,39 +62,42 @@ test {
}
}

spotless {
format 'misc', {
// define the files to apply `misc` to
target '*.md', '.gitignore'
if (isJava11orHigher) {
apply plugin: 'com.diffplug.spotless'
spotless {
format 'misc', {
// define the files to apply `misc` to
target '*.md', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
java {
targetExclude('**/WeakIdentityHashMap.java')
googleJavaFormat()
formatAnnotations()
}
groovyGradle {
target '**/*.gradle'
greclipse() // which formatter Spotless should use to format .gradle files.
indentWithSpaces(2)
trimTrailingWhitespace()
// endWithNewline() // Don't want to end empty files with a newline
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
java {
targetExclude('**/WeakIdentityHashMap.java')
googleJavaFormat()
formatAnnotations()
}
groovyGradle {
target '**/*.gradle'
greclipse() // which formatter Spotless should use to format .gradle files.
indentWithSpaces(2)
trimTrailingWhitespace()
// endWithNewline() // Don't want to end empty files with a newline
}
}
}

/// Error Prone linter

dependencies {
errorprone('com.google.errorprone:error_prone_core:2.26.1')
}
tasks.withType(JavaCompile).configureEach {
// "-processing" avoids javac warning "No processor claimed any of these annotations".
options.compilerArgs << '-Xlint:all,-processing' << '-Werror'
// "-Xlint:-options" is because of JDK 21 warning "source value 8 is obsolete..."
options.compilerArgs << '-Xlint:all,-processing,-options' << '-Werror'
options.errorprone.enabled = isJava11orHigher
options.errorprone {
disable('ExtendsObject') // Incorrect when using the Checker Framework
disable('ReferenceEquality') // Use Interning Checker instead.
}
}
Expand All @@ -84,10 +106,32 @@ tasks.withType(JavaCompile).configureEach {

apply plugin: 'org.checkerframework'

if (true) {
// Use the released version of the EISOP Checker Framework.
ext.checkerFrameworkVersion = '3.42.0-eisop3'
} else {
// To use a snapshot version of the EISOP Checker Framework.
// TODO: Change the above test to false to use a snapshot.
ext.checkerFrameworkVersion = '3.42.0-eisop4-SNAPSHOT'
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'minutes'
}
}

dependencies {
compileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1'
testCompileOnly 'io.github.eisop:checker-qual:3.34.0-eisop1'
checkerFramework 'io.github.eisop:checker:3.34.0-eisop1'
compileOnly "io.github.eisop:checker-qual:${checkerFrameworkVersion}"
testCompileOnly "io.github.eisop:checker-qual:${checkerFrameworkVersion}"
checkerFramework "io.github.eisop:checker:${checkerFrameworkVersion}"
}

// To use a locally-built Checker Framework, run gradle with "-PcfLocal".
if (project.hasProperty('cfLocal')) {
def cfHome = String.valueOf(System.getenv('CHECKERFRAMEWORK'))
dependencies {
compileOnly files(cfHome + '/checker/dist/checker-qual.jar')
testCompileOnly files(cfHome + '/checker/dist/checker-qual.jar')
checkerFramework files(cfHome + '/checker/dist/checker.jar')
}
}

checkerFramework {
Expand All @@ -106,32 +150,26 @@ checkerFramework {
'org.checkerframework.common.initializedfields.InitializedFieldsChecker',
]
extraJavacArgs = [
'-Werror',
// No "'-Werror'" because of JDK 21 warning "source value 8 is obsolete..."
// '-Werror',
'-AcheckPurityAnnotations',
'-ArequirePrefixInWarningSuppressions',
'-AwarnRedundantAnnotations',
'-AwarnUnneededSuppressions',
'-AnoJreVersionCheck',
'-Aversion',
]
}

// To use a locally-built Checker Framework, run gradle with "-PcfLocal".
if (project.hasProperty('cfLocal')) {
def cfHome = String.valueOf(System.getenv('CHECKERFRAMEWORK'))
dependencies {
compileOnly files(cfHome + '/checker/dist/checker-qual.jar')
testCompileOnly files(cfHome + '/checker/dist/checker-qual.jar')
checkerFramework files(cfHome + '/checker/dist/checker.jar')
}
}

/// Javadoc

// Turn Javadoc warnings into errors.
javadoc {
options.addStringOption('Xwerror', '-Xdoclint:all')
// No "'-Werror'" because of JDK 21 warning "source value 8 is obsolete..."
// options.addStringOption('Xwerror', '-Xdoclint:all')
options.addStringOption('Xdoclint:all', '-quiet')
options.addStringOption('private', '-quiet')
options.addStringOption('source', '11')
options.addStringOption('source', '8')
doLast {
ant.replaceregexp(match:"@import url\\('resources/fonts/dejavu.css'\\);\\s*", replace:'',
flags:'g', byline:true) {
Expand All @@ -148,6 +186,7 @@ dependencies {
requireJavadoc 'org.plumelib:require-javadoc:1.0.9'
}
task requireJavadoc(type: JavaExec) {
group = 'Documentation'
description = 'Ensures that Javadoc documentation exists.'
mainClass = 'org.plumelib.javadoc.RequireJavadoc'
classpath = configurations.requireJavadoc
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/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 Down
10 changes: 5 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
throw new Error("Use Java 11 or later.")
}
}
// buildscript {
// if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
// throw new Error("Use Java 11 or later.")
// }
// }

// Project name is read-only in build scripts, and defaults to directory name.
rootProject.name = 'html-pretty-print'

0 comments on commit 0108f87

Please sign in to comment.