Skip to content

Commit 58694fb

Browse files
authored
Make build work with Gradle config-cache and project isolation (#891)
* Make test build configuration-cache compatible * Adopt NMCP and migrate to included build-logic * Misc config-cache compatibiltiy changes * Fix config-cache reuse issue * Make publishing config-cache safe * Remove Gradle wrapper jar from source tree * Add safeguard for config-cache in CI * Fix some Gradle deprecations * Prevent/fix `Calculating task graph as configuration cache cannot be reused because an input to unknown location has changed.`
1 parent caaf923 commit 58694fb

35 files changed

Lines changed: 757 additions & 484 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ build/
44
.gradle/
55
buildSrc/.kotlin/
66

7+
# Ignore Gradle wrapper jar file
8+
gradle/wrapper/gradle-wrapper.jar
9+
gradle/wrapper/gradle-wrapper-*.sha256
10+
711
# Maven
812
**/.mvn/wrapper/maven-wrapper.jar
913
target/
@@ -13,3 +17,5 @@ target/
1317
out/
1418

1519
conformance/conformance-server.pid
20+
21+
/.env

bom/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ plugins {
1818
`java-platform`
1919
`maven-publish`
2020
signing
21-
`cel-conventions`
21+
id("cel-conventions")
2222
}
2323

2424
dependencies {
File renamed without changes.
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ import org.jetbrains.gradle.ext.settings
3131
fun Project.nessieIde() {
3232
apply<EclipsePlugin>()
3333

34-
if (this == rootProject) {
34+
if (path == ":") {
3535

36-
val projectName = rootProject.file("ide-name.txt").readText().trim()
37-
val ideName =
38-
"$projectName ${rootProject.version.toString().replace(Regex("^([0-9.]+).*"), "$1")}"
36+
val projectName = layout.settingsDirectory.file("ide-name.txt").asFile.readText().trim()
37+
val ideName = "$projectName ${version.toString().replace(Regex("^([0-9.]+).*"), "$1")}"
3938

4039
apply<IdeaExtPlugin>()
4140
configure<IdeaModel> {
@@ -51,7 +50,11 @@ fun Project.nessieIde() {
5150
profiles.create("Nessie-ASF") {
5251
// strip trailing LF
5352
val copyrightText =
54-
rootProject.file("codestyle/copyright-header.txt").readLines().joinToString("\n")
53+
layout.settingsDirectory
54+
.file("codestyle/copyright-header.txt")
55+
.asFile
56+
.readLines()
57+
.joinToString("\n")
5558
notice = copyrightText
5659
}
5760
}
@@ -63,8 +66,9 @@ fun Project.nessieIde() {
6366
defaults = true
6467

6568
jvmArgs =
66-
rootProject.projectDir
67-
.resolve("gradle.properties")
69+
layout.settingsDirectory
70+
.file("gradle.properties")
71+
.asFile
6872
.reader()
6973
.use {
7074
val rules = java.util.Properties()
@@ -81,10 +85,13 @@ fun Project.nessieIde() {
8185

8286
// There's no proper way to set the name of the IDEA project (when "just importing" or syncing
8387
// the Gradle project)
84-
val ideaDir = projectDir.resolve(".idea")
88+
val ideaDir = layout.projectDirectory.dir(".idea").asFile
8589

86-
if (ideaDir.isDirectory) {
87-
ideaDir.resolve(".name").writeText(ideName)
90+
if (java.lang.Boolean.getBoolean("idea.sync.active") && ideaDir.isDirectory) {
91+
val ideaNameFile = ideaDir.resolve(".name")
92+
if (!ideaNameFile.isFile || ideaNameFile.readText() != ideName) {
93+
ideaNameFile.writeText(ideName)
94+
}
8895
}
8996

9097
configure<EclipseModel> { project { name = ideName } }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fun Project.nessieConfigureJava() {
6565
}
6666
}
6767

68-
if (project != rootProject) {
68+
if (path != ":") {
6969
tasks.withType<Jar>().configureEach { duplicatesStrategy = DuplicatesStrategy.WARN }
7070
}
7171
}
File renamed without changes.

buildSrc/src/main/kotlin/PublishingHelperExtension.kt renamed to build-logic/src/main/kotlin/PublishingHelperExtension.kt

File renamed without changes.

0 commit comments

Comments
 (0)