Skip to content

Commit

Permalink
Bump Gradle to 8.10.2, require Java 11
Browse files Browse the repository at this point in the history
Also bump various plugins, especially error prone, which required some
changes to the code.
  • Loading branch information
Flowdalic committed Oct 20, 2024
1 parent 22489a4 commit fc592c9
Show file tree
Hide file tree
Showing 25 changed files with 194 additions and 121 deletions.
32 changes: 14 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ jobs:
build:
name: Build JXMPP

runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
matrix:
java:
- 11
- 15
- 17
- 21
env:
PRIMARY_JAVA_VERSION: 11
PRIMARY_JAVA_VERSION: 21

steps:
- name: Checkout
Expand Down Expand Up @@ -65,23 +65,19 @@ jobs:
# Javadoc
- name: Javadoc
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
run: ./gradlew aggregateJavadoc --stacktrace
run: ./gradlew javadocAll --stacktrace

# Test Coverage Report
- name: Jacoco Test Coverage
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
if: |
${{ matrix.java == env.PRIMARY_JAVA_VERSION }} &&
${{ env.COVERALLS_REPO_TOKEN != '' }}
run: |
if [[ -z ${COVERALLS_REPO_TOKEN} ]]; then
echo WARNING: COVERALLS_REPO_TOKEN is empty
else
echo COVERALLS_REPO_TOKEN is not empty
fi
./gradlew testCodeCoverageReport
./gradlew jxmpp-repl:coveralls
run: ./gradlew jxmpp-repl:testCodeCoverageReport

# Coveralls
- name: Report coverage stats to Coveralls
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
uses: coverallsapp/github-action@v2
with:
format: jacoco
file: jxmpp-repl/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml

# Upload build artifacts
- name: Upload build artifacts
Expand Down
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
GRADLE ?= ./gradlew

.PHONY: all
all: check codecov eclipse javadocAll

.PHONY: codecov
codecov:
$(GRADLE) jxmpp-repl:testCodeCoverageReport
echo "Code coverage report available at file://$(PWD)/jxmpp-repl/build/reports/jacoco/testCodeCoverageReport/html/index.html"

.PHONY: check
check:
$(GRADLE) $@

.PHONY: eclipse
eclipse:
$(GRADLE) $@

.PHONY: javadocAll
javadocAll:
$(GRADLE) $@
echo "javadoc available at file://$(PWD)/build/javadoc/index.html"
10 changes: 4 additions & 6 deletions build-logic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ repositories {
}

dependencies {
implementation "biz.aQute.bnd:biz.aQute.bnd.gradle:6.4.0"
implementation "io.freefair.gradle:maven-plugin:6.6.3" // for io.freefair.agregate-javadoc
implementation "me.champeau.jmh:jmh-gradle-plugin:0.6.8"
implementation "net.ltgt.gradle:gradle-errorprone-plugin:3.0.1"
implementation "gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0"
implementation "ru.vyarus:gradle-animalsniffer-plugin:1.7.0"
implementation "biz.aQute.bnd:biz.aQute.bnd.gradle:7.0.0"
implementation "me.champeau.jmh:jmh-gradle-plugin:0.7.2"
implementation "net.ltgt.gradle:gradle-errorprone-plugin:4.0.1"
implementation "ru.vyarus:gradle-animalsniffer-plugin:1.7.1"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
plugins {
id 'ru.vyarus.animalsniffer'
id 'org.jxmpp.common-conventions'
}
dependencies {
signature "net.sf.androidscents.signature:android-api-level-${jxmppMinAndroidSdk}:4.4.2_r4@signature"
signature "net.sf.androidscents.signature:android-api-level-${minAndroidSdk}:4.4.2_r4@signature"
}
animalsniffer {
sourceSets = [sourceSets.main]
Expand Down
36 changes: 36 additions & 0 deletions build-logic/src/main/groovy/org.jxmpp.common-conventions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ext {
javaVersion = JavaVersion.VERSION_11
javaMajor = javaVersion.getMajorVersion()
minAndroidSdk = 19

androidBootClasspath = getAndroidRuntimeJar(minAndroidSdk)

// Export the function by turning it into a closure.
// https://stackoverflow.com/a/23290820/194894
getAndroidRuntimeJar = this.&getAndroidRuntimeJar
}

repositories {
mavenLocal()
mavenCentral()
}

def getAndroidRuntimeJar(androidApiLevel) {
def androidHome = getAndroidHome()
def androidJar = new File("$androidHome/platforms/android-${androidApiLevel}/android.jar")
if (androidJar.isFile()) {
return androidJar
} else {
throw new Exception("Can't find android.jar for API level ${androidApiLevel}. Please install corresponding SDK platform package")
}
}

def getAndroidHome() {
def androidHomeEnv = System.getenv("ANDROID_HOME")
if (androidHomeEnv == null) {
throw new Exception("ANDROID_HOME environment variable is not set")
}
def androidHome = new File(androidHomeEnv)
if (!androidHome.isDirectory()) throw new Exception("Environment variable ANDROID_HOME is not pointing to a directory")
return androidHome
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id 'biz.aQute.bnd.builder'
id 'checkstyle'
id 'com.github.kt3k.coveralls'
id 'eclipse'
id 'idea'
id 'jacoco'
Expand All @@ -13,11 +12,9 @@ plugins {

id 'jacoco-report-aggregation'
id 'test-report-aggregation'
}

repositories {
mavenLocal()
mavenCentral()
id 'org.jxmpp.common-conventions'
id 'org.jxmpp.javadoc-conventions'
}

version readVersionFile()
Expand All @@ -37,14 +34,12 @@ ext {
builtDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
oneLineDesc = 'An Open Source XMPP (Jabber) library'
junitVersion = '5.9.2'
jxmppMinAndroidSdk = 19
}

group = 'org.jxmpp'

import org.jxmpp.BuildConstants
java {
sourceCompatibility = BuildConstants.JAVA_COMPATIBILITY
sourceCompatibility = javaVersion
targetCompatibility = sourceCompatibility
}

Expand Down Expand Up @@ -80,39 +75,11 @@ tasks.withType(JavaCompile) {
'-Xlint:-options',
'-Werror',
]
}
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
// The '-quiet' as second argument is actually a hack,
// since the one parameter addStringOption doesn't seem to
// work, we extra add '-quiet', which is added anyway by
// gradle.
// We disable 'missing' as we do most of javadoc checking via checkstyle.
options.addStringOption('Xdoclint:all,-missing', '-quiet')
// Abort on javadoc warnings.
// See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
// for information about the -Xwerror option.
options.addStringOption('Xwerror', '-quiet')
}
}

if (JavaVersion.current().isJava9Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('-release', BuildConstants.JAVA_MAJOR_COMPATIBILITY)
}
tasks.withType(JavaCompile) {
options.compilerArgs.addAll([
'--release', BuildConstants.JAVA_MAJOR_COMPATIBILITY,
])
}
}

tasks.withType(Javadoc) {
options.charSet = "UTF-8"
options.release = Integer.valueOf(javaMajor)
}

jacoco {
toolVersion = "0.8.8"
toolVersion = "0.8.12"
}

jacocoTestReport {
Expand All @@ -125,10 +92,15 @@ jacocoTestReport {
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"

errorprone 'com.google.errorprone:error_prone_core:2.32.0'
}

test {
useJUnitPlatform()

maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1

// Enable full stacktraces of failed tests. Especially handy
// for environments like Travis.
testLogging {
Expand All @@ -149,15 +121,15 @@ checkstyle {
toolVersion = '10.8.0'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
task testsJar(type: Jar) {
classifier = 'tests'
archiveClassifier = 'tests'
from sourceSets.test.output
}
artifacts {
Expand Down Expand Up @@ -257,22 +229,13 @@ tasks.withType(JavaCompile) {
}
}

dependencies {
errorprone 'com.google.errorprone:error_prone_core:2.9.0'
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
}

// TODO: Note sure what this does (did). Was there prior the build-logic conversion.
// dependencies {
// androidProjects.each { project ->
// api project
// }
// }

coveralls {
jacocoReportPath 'build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml'
}

def getGitCommit() {
def projectDirFile = new File("$projectDir")
def dotGit = new File(projectDirFile, ".git")
Expand All @@ -285,17 +248,6 @@ def getGitCommit() {
gitCommit
}

def getAndroidRuntimeJar() {
def androidHome = new File("$System.env.ANDROID_HOME")
if (!androidHome.isDirectory()) throw new Exception("ANDROID_HOME not found or set")
def androidJar = new File("$androidHome/platforms/android-$jxmppMinAndroidSdk/android.jar")
if (androidJar.isFile()) {
return androidJar
} else {
throw new Exception("Can't find android.jar for $jxmppMinAndroidSdk API. Please install corresponding SDK platform package")
}
}

def readVersionFile() {
def versionFile = new File(rootDir, 'version')
if (!versionFile.isFile()) {
Expand Down
24 changes: 24 additions & 0 deletions build-logic/src/main/groovy/org.jxmpp.javadoc-conventions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
plugins {
// Javadoc linking requires repositories to bet configured. And
// those are declared in common-conventions, hence we add it here.
id 'org.jxmpp.common-conventions'
}


tasks.withType(Javadoc) {
// The '-quiet' as second argument is actually a hack,
// since the one parameter addStringOption doesn't seem to
// work, we extra add '-quiet', which is added anyway by
// gradle.
// We disable 'missing' as we do most of javadoc checking via checkstyle.
options.addStringOption('Xdoclint:all,-missing', '-quiet')
// Abort on javadoc warnings.
// See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
// for information about the -Xwerror option.
options.addStringOption('Xwerror', '-quiet')
options.addStringOption('-release', javaMajor)
}

tasks.withType(Javadoc) {
options.charSet = "UTF-8"
}
3 changes: 0 additions & 3 deletions build-logic/src/main/groovy/org.jxmpp.root-conventions.gradle

This file was deleted.

8 changes: 0 additions & 8 deletions build-logic/src/main/groovy/org/jxmpp/BuildConstants.groovy

This file was deleted.

55 changes: 54 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
plugins {
id 'org.jxmpp.root-conventions'
// The scalastyle plugin of jxmpp-repl wants the root project to
// have a ideaProject task, so let's add one.
id 'idea'

id 'org.jxmpp.javadoc-conventions'
}

ext {
javadocAllDir = new File(buildDir, 'javadoc')
javadocAllProjects = subprojects
}

evaluationDependsOnChildren()
task javadocAll(type: Javadoc) {
source javadocAllProjects.collect {project ->
project.sourceSets.main.allJava.findAll {
// Filter out symbolic links to avoid
// "warning: a package-info.java file has already been seen for package"
// javadoc warnings.
!java.nio.file.Files.isSymbolicLink(it.toPath())
}
}
destinationDir = javadocAllDir
// Might need a classpath
classpath = files(subprojects.collect {project ->
project.sourceSets.main.compileClasspath})
classpath += files(androidBootClasspath)
options {
linkSource = true
use = true
links = [
"https://docs.oracle.com/en/java/javase/${javaMajor}/docs/api/",
] as String[]
overview = "$projectDir/resources/javadoc-overview.html"
}

// Finally copy the javadoc doc-files from the subprojects, which
// are potentially generated, to the javadocAll directory. Note
// that we use a copy *method* and not a *task* because the inputs
// of copy tasks is determined within the configuration phase. And
// since some of the inputs are generated, they will not get
// picked up if we used a copy method. See also
// https://stackoverflow.com/a/40518516/194894
doLast {
copy {
javadocAllProjects.each {
from ("${it.projectDir}/src/javadoc") {
include '**/doc-files/*.*'
}
}

into javadocAllDir
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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-7.6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit fc592c9

Please sign in to comment.