From d3598a397dffbfe20679817ec1ea66e1e6deb192 Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Tue, 25 Nov 2025 11:08:26 -0800 Subject: [PATCH] Enable project isolation Fixes https://github.com/android/nowinandroid/issues/1842 --- .github/workflows/Build.yaml | 3 --- build-logic/convention/src/main/kotlin/RootPlugin.kt | 10 ++++++++-- gradle.properties | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index e31ac333af..4465324122 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -47,9 +47,6 @@ jobs: - name: Check build-logic run: ./gradlew :build-logic:convention:check - - name: Check spotless - run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache - - name: Check Dependency Guard id: dependencyguard_verify continue-on-error: true diff --git a/build-logic/convention/src/main/kotlin/RootPlugin.kt b/build-logic/convention/src/main/kotlin/RootPlugin.kt index b704adf764..c6ec115278 100644 --- a/build-logic/convention/src/main/kotlin/RootPlugin.kt +++ b/build-logic/convention/src/main/kotlin/RootPlugin.kt @@ -17,10 +17,16 @@ import com.google.samples.apps.nowinandroid.configureGraphTasks import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.configuration.BuildFeatures +import javax.inject.Inject + +abstract class RootPlugin : Plugin { + @get:Inject abstract val buildFeatures: BuildFeatures -class RootPlugin : Plugin { override fun apply(target: Project) { require(target.path == ":") - target.subprojects { configureGraphTasks() } + if (!buildFeatures.isolatedProjects.active.orElse(false).get()) { + target.subprojects { configureGraphTasks() } + } } } diff --git a/gradle.properties b/gradle.properties index 2e9d9fc306..d7d21ad6ef 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ # - CodeCache normally defaults to a very small size. Increasing it from platform defaults of 32-48m # because of how many classes can be loaded into memory and then cached as native compiled code # for a small speed boost. -org.gradle.jvmargs=-Dfile.encoding=UTF-8 -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=1 -XX:ReservedCodeCacheSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx4g -Xms4g +org.gradle.jvmargs=-Dfile.encoding=UTF-8 -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=1 -XX:ReservedCodeCacheSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx4g -Xms4g -Dorg.gradle.internal.isolated-projects.parallel=false # For more information about how Kotlin Daemon memory options were chosen: # - Kotlin JVM args only inherit Xmx, ReservedCodeCache, and MaxMetaspace. Since we are specifying @@ -44,6 +44,8 @@ org.gradle.configuration-cache.parallel=true # to generate the Configuration Cache regardless of incompatible tasks. # See https://github.com/android/nowinandroid/issues/1022 before using it. org.gradle.configuration-cache.problems=warn +org.gradle.unsafe.isolated-projects=true +ksp.project.isolation.enabled=true # AndroidX package structure to make it clearer which packages are bundled with the # Android operating system, and which are packaged with your app"s APK