Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ and style in order to keep the code as readable as possible. Please also make
sure your code compiles by running `./gradlew clean build`. If you're using IntelliJ IDEA,
we use [Square's code style definitions][2].

Building
--------

You need **JDK 17 or newer** to run Gradle, and **JDK 21 installed** for the build to compile
against.

The build uses three separate JDK versions, configured in `gradle/libs.versions.toml`:

| Version | Purpose |
|---|---|
| `jdk-target` (11) | Bytecode version published to consumers |
| `jdk-toolchain` (21) | JDK the libraries are compiled with, via a Gradle toolchain |
| `jdk-buildLogic` (17) | JDK `build-logic` is compiled with — the floor for your Gradle daemon |

Gradle forks a JDK 21 toolchain for compilation, so your `JAVA_HOME` does not need to be 21 — but a
JDK 21 must be installed somewhere Gradle can [auto-detect][3] it. If you see
`Cannot find a Java installation ... matching languageVersion=21`, install a JDK 21.

[3]: https://docs.gradle.org/current/userguide/toolchains.html#sec:auto_detection

Before your code can be accepted into the project you must also sign the
[Individual Contributor License Agreement (CLA)][1].

Expand Down
4 changes: 3 additions & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ dependencies {
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(libs.versions.jdk.toolchain.get()))
// Deliberately not jdk-toolchain: build-logic is on the buildscript classpath, so the Gradle
// daemon loads these classes directly and can't read bytecode newer than its own JDK.
toolchain.languageVersion.set(JavaLanguageVersion.of(libs.versions.jdk.buildLogic.get()))
}
7 changes: 7 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ compileSdk = "36"
minSdk = "24"
targetSdk = "33"

# The bytecode version published to consumers.
jdk-target = "11"
# The JDK used to compile the libraries, via a Gradle toolchain. Matches android-register's compile
# JDK. Gradle forks this JDK for compilation, so it does not constrain the daemon's JDK.
jdk-toolchain = "21"
# The JDK used to compile build-logic. Unlike the above, this *does* constrain the daemon: build-logic
# is on the buildscript classpath, so the daemon must be able to load its bytecode. Keep it at the
# floor Gradle and AGP already require (17) so the build works on a stock JDK 17 environment.
jdk-buildLogic = "17"

androidx-activity = "1.11.0"
androidx-appcompat = "1.7.1"
Expand Down
Loading