Skip to content

Commit 2e372e4

Browse files
committed
Bump Gradle to 8.10.2
1 parent ad65b1d commit 2e372e4

30 files changed

+871
-263
lines changed

.github/workflows/ci.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
name: Build Java Pinning
8+
9+
runs-on: ubuntu-24.04
10+
strategy:
11+
matrix:
12+
java:
13+
- 17
14+
- 21
15+
env:
16+
PRIMARY_JAVA_VERSION: 21
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- name: Set up JDK ${{ matrix.java }}
22+
uses: actions/setup-java@v1
23+
with:
24+
java-version: ${{ matrix.java }}
25+
26+
# Caches
27+
- name: Cache Maven
28+
uses: actions/cache@v2
29+
with:
30+
path: ~/.m2/repository
31+
key: maven-${{ hashFiles('**/build.gradle') }}
32+
restore-keys: |
33+
maven-
34+
- name: Cache Gradle
35+
uses: actions/cache@v2
36+
with:
37+
path: ~/.gradle/caches
38+
key: gradle-caches-${{ hashFiles('**/build.gradle') }}
39+
restore-keys:
40+
gradle-caches
41+
- name: Cache Android SDK
42+
uses: actions/cache@v2
43+
with:
44+
path: |
45+
~/.android/sdk
46+
key: android-${{ hashFiles('build.gradle') }}
47+
restore-keys: |
48+
android-
49+
50+
# Pre-reqs
51+
- name: Install Android SDK Manager
52+
uses: android-actions/setup-android@v2
53+
- name: Install Android SDK
54+
run: |
55+
sdkmanager "platforms;android-15" "platforms;android-30"
56+
57+
# Testing
58+
- name: Gradle Check
59+
run: ./gradlew check --stacktrace
60+
61+
# Test local publish
62+
- name: Gradle publish
63+
run: ./gradlew publishToMavenLocal --stacktrace
64+
65+
# Javadoc
66+
- name: Javadoc
67+
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
68+
run: ./gradlew javadocAll --stacktrace
69+
70+
# Test Coverage Report
71+
- name: Jacoco Test Coverage
72+
run: ./gradlew java-pinning-java11:testCodeCoverageReport
73+
74+
# Coveralls
75+
- name: Report coverage stats to Coveralls
76+
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
77+
uses: coverallsapp/github-action@v2
78+
with:
79+
format: jacoco
80+
file: java-pinning-java11/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
81+
82+
# Upload build artifacts
83+
- name: Upload build artifacts
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: java-pinning-java-${{ matrix.java }}
87+
path: |
88+
java-pinning-*/build/libs/*.jar
89+
!**/*-test-fixtures.jar
90+
!**/*-tests.jar

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
GRADLE ?= ./gradlew
2+
3+
.PHONY: all
4+
all: check codecov eclipse javadocAll show-dependency-updates
5+
6+
.PHONY: codecov
7+
codecov:
8+
$(GRADLE) java-pinning-java11:testCodeCoverageReport
9+
echo "Code coverage report available at file://$(PWD)/java-pinnging-java11/build/reports/jacoco/testCodeCoverageReport/html/index.html"
10+
11+
.PHONY: check
12+
check:
13+
$(GRADLE) $@
14+
15+
.PHONY: eclipse
16+
eclipse:
17+
$(GRADLE) $@
18+
19+
.PHONY: javadocAll
20+
javadocAll:
21+
$(GRADLE) $@
22+
echo "javadoc available at file://$(PWD)/build/javadoc/index.html"
23+
24+
.PHONY: show-dependency-updates
25+
show-dependency-updates:
26+
$(GRADLE) dependencyUpdates

build-logic/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins {
2+
id 'groovy-gradle-plugin'
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
google()
8+
}
9+
10+
dependencies {
11+
implementation "biz.aQute.bnd:biz.aQute.bnd.gradle:7.0.0"
12+
implementation "net.ltgt.gradle:gradle-errorprone-plugin:4.0.1"
13+
implementation "ru.vyarus:gradle-animalsniffer-plugin:1.7.1"
14+
implementation "com.github.ben-manes:gradle-versions-plugin:0.51.0"
15+
implementation 'com.android.tools.build:gradle:8.7.0'
16+
}

build-logic/settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'javapinning-build-logic'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
plugins {
2+
id 'ru.vyarus.animalsniffer'
3+
id 'eu.geekplace.javapinning.common-conventions'
4+
}
5+
6+
dependencies {
7+
signature "net.sf.androidscents.signature:android-api-level-${minAndroidSdk}:4.0.3_r5@signature"
8+
}
9+
animalsniffer {
10+
sourceSets = [sourceSets.main]
11+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ext {
2+
javaVersion = JavaVersion.VERSION_11
3+
javaMajor = javaVersion.getMajorVersion()
4+
minAndroidSdk = 15
5+
6+
isSnapshot = version.endsWith('-SNAPSHOT')
7+
8+
androidBootClasspath = getAndroidRuntimeJar(minAndroidSdk)
9+
10+
// Export the function by turning it into a closure.
11+
// https://stackoverflow.com/a/23290820/194894
12+
getAndroidRuntimeJar = this.&getAndroidRuntimeJar
13+
}
14+
15+
repositories {
16+
mavenCentral()
17+
google()
18+
mavenLocal()
19+
}
20+
21+
def getAndroidRuntimeJar(androidApiLevel) {
22+
def androidHome = getAndroidHome()
23+
def androidJar = new File("$androidHome/platforms/android-${androidApiLevel}/android.jar")
24+
if (androidJar.isFile()) {
25+
return androidJar
26+
} else {
27+
throw new Exception("Can't find android.jar for API level ${androidApiLevel}. Please install corresponding SDK platform package")
28+
}
29+
}
30+
31+
def getAndroidHome() {
32+
def androidHomeEnv = System.getenv("ANDROID_HOME")
33+
if (androidHomeEnv == null) {
34+
throw new Exception("ANDROID_HOME environment variable is not set")
35+
}
36+
def androidHome = new File(androidHomeEnv)
37+
if (!androidHome.isDirectory()) throw new Exception("Environment variable ANDROID_HOME is not pointing to a directory")
38+
return androidHome
39+
}
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
plugins {
2+
id 'biz.aQute.bnd.builder'
3+
id 'checkstyle'
4+
id 'eclipse'
5+
id 'idea'
6+
id 'jacoco'
7+
id 'java'
8+
id 'java-library'
9+
id 'net.ltgt.errorprone'
10+
id 'com.github.ben-manes.versions'
11+
12+
id 'jacoco-report-aggregation'
13+
id 'test-report-aggregation'
14+
15+
id 'eu.geekplace.javapinning.common-conventions'
16+
id 'eu.geekplace.javapinning.javadoc-conventions'
17+
id 'eu.geekplace.javapinning.publish-conventions'
18+
}
19+
20+
version readVersionFile()
21+
22+
ext {
23+
gitCommit = getGitCommit()
24+
documentationDir = new File(projectDir, 'documentation')
25+
releasedocsDir = new File(buildDir, 'releasedocs')
26+
rootConfigDir = new File(rootDir, 'config')
27+
isReleaseVersion = !isSnapshot
28+
junitVersion = '5.11.3'
29+
}
30+
31+
group = 'eu.geekplace.javapinning'
32+
33+
java {
34+
sourceCompatibility = javaVersion
35+
targetCompatibility = sourceCompatibility
36+
}
37+
38+
ext.sharedManifest = manifest {
39+
attributes('Implementation-Version': version,
40+
'Implementation-GitRevision': ext.gitCommit,
41+
'Built-JDK': System.getProperty('java.version'),
42+
'Built-Gradle': gradle.gradleVersion,
43+
'Built-By': System.getProperty('user.name')
44+
)
45+
}
46+
47+
eclipse {
48+
classpath {
49+
downloadJavadoc = true
50+
}
51+
}
52+
53+
// Make all project's 'test' target depend on javadoc, so that
54+
// javadoc is also linted.
55+
test.dependsOn javadoc
56+
57+
tasks.withType(JavaCompile) {
58+
// Some systems may not have set their platform default
59+
// converter to 'utf8', but we use unicode in our source
60+
// files. Therefore ensure that javac uses unicode
61+
options.encoding = "utf8"
62+
options.compilerArgs = [
63+
'-Xlint:all',
64+
// Set '-options' because a non-java7 javac will emit a
65+
// warning if source/target is set to 1.7 and
66+
// bootclasspath is *not* set.
67+
'-Xlint:-options',
68+
'-Werror',
69+
]
70+
options.release = Integer.valueOf(javaMajor)
71+
}
72+
73+
jacoco {
74+
toolVersion = "0.8.12"
75+
}
76+
77+
jacocoTestReport {
78+
dependsOn test
79+
reports {
80+
xml.required = true
81+
}
82+
}
83+
84+
dependencies {
85+
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
86+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
87+
88+
// https://stackoverflow.com/a/77274251/194894
89+
testImplementation "org.junit.platform:junit-platform-launcher:1.11.3"
90+
91+
errorprone 'com.google.errorprone:error_prone_core:2.35.1'
92+
}
93+
94+
test {
95+
useJUnitPlatform()
96+
97+
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
98+
99+
// Enable full stacktraces of failed tests. Especially handy
100+
// for environments like Travis.
101+
testLogging {
102+
events "failed"
103+
exceptionFormat "full"
104+
}
105+
}
106+
107+
jar {
108+
bundle {
109+
bnd(
110+
'-removeheaders': 'Tool, Bnd-*',
111+
'-exportcontents': 'eu.geekplace.javapinning.*',
112+
)
113+
}
114+
}
115+
checkstyle {
116+
toolVersion = '10.18.2'
117+
}
118+
task sourcesJar(type: Jar, dependsOn: classes) {
119+
archiveClassifier = 'sources'
120+
from sourceSets.main.allSource
121+
}
122+
task javadocJar(type: Jar, dependsOn: javadoc) {
123+
archiveClassifier = 'javadoc'
124+
from javadoc.destinationDir
125+
}
126+
task testsJar(type: Jar) {
127+
archiveClassifier = 'tests'
128+
from sourceSets.test.output
129+
}
130+
configurations {
131+
testRuntime
132+
}
133+
artifacts {
134+
// Add a 'testRuntime' configuration including the tests so that
135+
// it can be consumed by other projects (smack-omemo-signal for
136+
// example). See http://stackoverflow.com/a/21946676/194894
137+
testRuntime testsJar
138+
}
139+
140+
publishing {
141+
publications {
142+
mavenJava(MavenPublication) {
143+
from components.java
144+
artifact sourcesJar
145+
artifact javadocJar
146+
artifact testsJar
147+
}
148+
}
149+
}
150+
151+
tasks.withType(JavaCompile) {
152+
options.errorprone {
153+
disableWarningsInGeneratedCode = true
154+
excludedPaths = ".*/jmh_generated/.*"
155+
error(
156+
"UnusedVariable",
157+
"UnusedMethod",
158+
"MethodCanBeStatic",
159+
)
160+
errorproneArgs = [
161+
// Disable MissingCasesInEnumSwitch error prone check
162+
// because this check is already done by javac as incomplete-switch.
163+
'-Xep:MissingCasesInEnumSwitch:OFF',
164+
'-Xep:StringSplitter:OFF',
165+
'-Xep:JavaTimeDefaultTimeZone:OFF',
166+
'-Xep:InlineMeSuggester:OFF',
167+
]
168+
}
169+
}
170+
171+
// TODO: Note sure what this does (did). Was there prior the build-logic conversion.
172+
// dependencies {
173+
// androidProjects.each { project ->
174+
// api project
175+
// }
176+
// }
177+
178+
def getGitCommit() {
179+
def projectDirFile = new File("$projectDir")
180+
def dotGit = new File(projectDirFile, ".git")
181+
if (!dotGit.isDirectory()) return 'non-git build'
182+
183+
def cmd = 'git describe --always --tags --dirty=+'
184+
def proc = cmd.execute(null, projectDirFile)
185+
def gitCommit = proc.text.trim()
186+
assert !gitCommit.isEmpty()
187+
gitCommit
188+
}
189+
190+
def readVersionFile() {
191+
def versionFile = new File(rootDir, 'version')
192+
if (!versionFile.isFile()) {
193+
throw new Exception("Could not find version file")
194+
}
195+
if (versionFile.text.isEmpty()) {
196+
throw new Exception("Version file does not contain a version")
197+
}
198+
versionFile.text.trim()
199+
}

0 commit comments

Comments
 (0)