Format kts files
Change-Id: I37eab3e3d1bc2a4a4d78444140aadd688d43fa14
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 6e873c7..78bc36d 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -66,9 +66,9 @@
results = []
for f in input_api.AffectedFiles():
path = f.LocalPath()
- if not path.endswith('.java') and not path.endswith('.kt'):
+ if not path.endswith('.java') and not path.endswith('.kt') and not path.endswith('.kts'):
continue
- if path.endswith('.kt'):
+ if path.endswith('.kt') or path.endswith('.kts'):
if path in KOTLIN_FMT_IGNORE:
continue
pending_kotlin_files.append(path)
@@ -119,13 +119,13 @@
def KotlinFormatPresubmitMessage():
return """Please fix the Kotlin formatting by running:
- git diff $(git cl upstream) --name-only "*.kt" | grep -v "^src/keepanno/" | xargs {java} -jar {fmt_jar} --google-style
- git diff $(git cl upstream) --name-only "*.kt" | grep "^src/keepanno/" | xargs {java} -jar {fmt_jar} --kotlinlang-style
+ git diff $(git cl upstream) --name-only "*.kt" "*.kts" | grep -v "^src/keepanno/" | xargs {java} -jar {fmt_jar} --google-style
+ git diff $(git cl upstream) --name-only "*.kt" "*.kts" | grep "^src/keepanno/" | xargs {java} -jar {fmt_jar} --kotlinlang-style
or fix formatting, commit and upload:
- git diff $(git cl upstream) --name-only "*.kt" | grep -v "^src/keepanno/" | xargs {java} -jar {fmt_jar} --google-style && git commit -a --amend --no-edit && git cl upload
- git diff $(git cl upstream) --name-only "*.kt" | grep "^src/keepanno/" | xargs {java} -jar {fmt_jar} --kotlinlang-style && git commit -a --amend --no-edit && git cl upload
+ git diff $(git cl upstream) --name-only "*.kt" "*.kts" | grep -v "^src/keepanno/" | xargs {java} -jar {fmt_jar} --google-style && git commit -a --amend --no-edit && git cl upload
+ git diff $(git cl upstream) --name-only "*.kt" "*.kts" | grep "^src/keepanno/" | xargs {java} -jar {fmt_jar} --kotlinlang-style && git commit -a --amend --no-edit && git cl upload
or bypass the checks with:
diff --git a/build.gradle.kts b/build.gradle.kts
index ebcb12a..d35193f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -34,11 +34,10 @@
dependsOn(gradle.includedBuild("test").task(":clean"))
}
- val r8 by registering() {
- dependsOn(gradle.includedBuild("main").task(":r8WithRelocatedDeps"))
- }
+ val r8 by registering() { dependsOn(gradle.includedBuild("main").task(":r8WithRelocatedDeps")) }
- val r8lib by registering() {
- dependsOn(gradle.includedBuild("test").task(":assembleR8LibWithRelocatedDeps"))
- }
+ val r8lib by
+ registering() {
+ dependsOn(gradle.includedBuild("test").task(":assembleR8LibWithRelocatedDeps"))
+ }
}
diff --git a/d8_r8/assistant/build.gradle.kts b/d8_r8/assistant/build.gradle.kts
index fe296fc..90dcfc8 100644
--- a/d8_r8/assistant/build.gradle.kts
+++ b/d8_r8/assistant/build.gradle.kts
@@ -7,19 +7,13 @@
id("dependencies-plugin")
}
-dependencies {
- compileOnly(":keepanno")
-}
+dependencies { compileOnly(":keepanno") }
java {
- sourceSets.main.configure {
- java.srcDir(getRoot().resolveAll("src", "assistant", "java"))
- }
+ sourceSets.main.configure { java.srcDir(getRoot().resolveAll("src", "assistant", "java")) }
sourceCompatibility = JvmCompatibility.sourceCompatibility
targetCompatibility = JvmCompatibility.targetCompatibility
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
withSourcesJar()
}
@@ -28,6 +22,4 @@
archiveFileName.set("assistant.jar")
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
diff --git a/d8_r8/assistant/settings.gradle.kts b/d8_r8/assistant/settings.gradle.kts
index 2b1446b..0ba371d 100644
--- a/d8_r8/assistant/settings.gradle.kts
+++ b/d8_r8/assistant/settings.gradle.kts
@@ -4,24 +4,19 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../third_party/dependencies")
- }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../third_party/dependencies") } }
}
rootProject.name = "assistant"
+
val root = rootProject.projectDir.parentFile
+
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("keepanno"))
diff --git a/d8_r8/blastradius/build.gradle.kts b/d8_r8/blastradius/build.gradle.kts
index 941e1d5..a45efd3 100644
--- a/d8_r8/blastradius/build.gradle.kts
+++ b/d8_r8/blastradius/build.gradle.kts
@@ -2,8 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import com.google.protobuf.gradle.proto
import com.google.protobuf.gradle.ProtobufExtension
+import com.google.protobuf.gradle.proto
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
plugins {
@@ -14,21 +14,20 @@
// It seems like the use of a local maven repo does not allow adding the plugin with the id+version
// syntax. Also, for some reason the 'protobuf' extension object cannot be directly referenced.
// This configures the plugin "old style" and pulls out the extension object manually.
-buildscript {
- dependencies {
- classpath("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
- }
-}
+buildscript { dependencies { classpath("com.google.protobuf:protobuf-gradle-plugin:0.9.4") } }
+
apply(plugin = "com.google.protobuf")
+
var os = DefaultNativePlatform.getCurrentOperatingSystem()
var protobuf = project.extensions.getByName("protobuf") as ProtobufExtension
+
protobuf.protoc {
if (os.isLinux) {
path = getRoot().resolveAll("third_party", "protoc", "linux-x86_64", "bin", "protoc").path
} else if (os.isMacOsX) {
path = getRoot().resolveAll("third_party", "protoc", "osx-x86_64", "bin", "protoc").path
} else {
- assert(os.isWindows);
+ assert(os.isWindows)
path = getRoot().resolveAll("third_party", "protoc", "win64", "bin", "protoc.exe").path
}
}
@@ -36,22 +35,14 @@
java {
sourceSets.main.configure {
java.srcDir(getRoot().resolveAll("src", "blastradius", "java"))
- proto {
- srcDir(getRoot().resolveAll("src", "blastradius", "proto"))
- }
+ proto { srcDir(getRoot().resolveAll("src", "blastradius", "proto")) }
}
sourceCompatibility = JvmCompatibility.sourceCompatibility
targetCompatibility = JvmCompatibility.targetCompatibility
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
withSourcesJar()
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
-dependencies {
- compileOnly(Deps.protobuf)
-}
+dependencies { compileOnly(Deps.protobuf) }
diff --git a/d8_r8/blastradius/settings.gradle.kts b/d8_r8/blastradius/settings.gradle.kts
index cdb00b0..a86da06 100644
--- a/d8_r8/blastradius/settings.gradle.kts
+++ b/d8_r8/blastradius/settings.gradle.kts
@@ -4,21 +4,13 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../third_party/dependencies")
- }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../third_party/dependencies") } }
}
rootProject.name = "blastradius"
diff --git a/d8_r8/commonBuildSrc/build.gradle.kts b/d8_r8/commonBuildSrc/build.gradle.kts
index 580d325..5f32acf 100644
--- a/d8_r8/commonBuildSrc/build.gradle.kts
+++ b/d8_r8/commonBuildSrc/build.gradle.kts
@@ -7,9 +7,7 @@
`java-gradle-plugin`
}
-dependencies {
- implementation("net.ltgt.gradle:gradle-errorprone-plugin:3.0.1")
-}
+dependencies { implementation("net.ltgt.gradle:gradle-errorprone-plugin:3.0.1") }
gradlePlugin {
plugins.register("dependencies-plugin") {
@@ -18,6 +16,4 @@
}
}
-kotlin {
- explicitApi()
-}
\ No newline at end of file
+kotlin { explicitApi() }
diff --git a/d8_r8/commonBuildSrc/settings.gradle.kts b/d8_r8/commonBuildSrc/settings.gradle.kts
index 619af58..9fd816f 100644
--- a/d8_r8/commonBuildSrc/settings.gradle.kts
+++ b/d8_r8/commonBuildSrc/settings.gradle.kts
@@ -4,23 +4,15 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
+ maven { url = uri("file:../../third_party/dependencies") }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
}
}
dependencyResolutionManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
+ maven { url = uri("file:../../third_party/dependencies") }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
}
}
diff --git a/d8_r8/keepanno/build.gradle.kts b/d8_r8/keepanno/build.gradle.kts
index 503272a..1df7af2 100644
--- a/d8_r8/keepanno/build.gradle.kts
+++ b/d8_r8/keepanno/build.gradle.kts
@@ -2,8 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import com.google.protobuf.gradle.proto
import com.google.protobuf.gradle.ProtobufExtension
+import com.google.protobuf.gradle.proto
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
plugins {
@@ -14,21 +14,20 @@
// It seems like the use of a local maven repo does not allow adding the plugin with the id+version
// syntax. Also, for some reason the 'protobuf' extension object cannot be directly referenced.
// This configures the plugin "old style" and pulls out the extension object manually.
-buildscript {
- dependencies {
- classpath("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
- }
-}
+buildscript { dependencies { classpath("com.google.protobuf:protobuf-gradle-plugin:0.9.4") } }
+
apply(plugin = "com.google.protobuf")
+
var os = DefaultNativePlatform.getCurrentOperatingSystem()
var protobuf = project.extensions.getByName("protobuf") as ProtobufExtension
+
protobuf.protoc {
if (os.isLinux) {
path = getRoot().resolveAll("third_party", "protoc", "linux-x86_64", "bin", "protoc").path
} else if (os.isMacOsX) {
path = getRoot().resolveAll("third_party", "protoc", "osx-x86_64", "bin", "protoc").path
} else {
- assert(os.isWindows);
+ assert(os.isWindows)
path = getRoot().resolveAll("third_party", "protoc", "win64", "bin", "protoc.exe").path
}
}
@@ -36,21 +35,15 @@
java {
sourceSets.main.configure {
java.srcDir(getRoot().resolveAll("src", "keepanno", "java"))
- proto {
- srcDir(getRoot().resolveAll("src", "keepanno", "proto"))
- }
+ proto { srcDir(getRoot().resolveAll("src", "keepanno", "proto")) }
}
sourceCompatibility = JvmCompatibility.sourceCompatibility
targetCompatibility = JvmCompatibility.targetCompatibility
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
withSourcesJar()
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
dependencies {
compileOnly(Deps.asm)
@@ -59,108 +52,116 @@
}
tasks {
- val keepAnnoAnnotationsJar by registering(Jar::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- from(sourceSets.main.get().output)
- include("com/android/tools/r8/keepanno/annotations/*")
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- archiveFileName.set("keepanno-annotations.jar")
- }
+ val keepAnnoAnnotationsJar by
+ registering(Jar::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ from(sourceSets.main.get().output)
+ include("com/android/tools/r8/keepanno/annotations/*")
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ archiveFileName.set("keepanno-annotations.jar")
+ }
- val keepAnnoLegacyAnnotationsJar by registering(Jar::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- from(sourceSets.main.get().output)
- include("com/android/tools/r8/keepanno/annotations/*")
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- archiveFileName.set("keepanno-annotations-legacy.jar")
- }
+ val keepAnnoLegacyAnnotationsJar by
+ registering(Jar::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ from(sourceSets.main.get().output)
+ include("com/android/tools/r8/keepanno/annotations/*")
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ archiveFileName.set("keepanno-annotations-legacy.jar")
+ }
- val keepAnnoAndroidXAnnotationsJar by registering(Jar::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- from(sourceSets.main.get().output)
- include("androidx/annotation/keep/*")
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- archiveFileName.set("keepanno-annotations-androidx.jar")
- }
+ val keepAnnoAndroidXAnnotationsJar by
+ registering(Jar::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ from(sourceSets.main.get().output)
+ include("androidx/annotation/keep/*")
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ archiveFileName.set("keepanno-annotations-androidx.jar")
+ }
- val keepAnnoJar by registering(Jar::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- from(sourceSets.main.get().output)
- }
+ val keepAnnoJar by
+ registering(Jar::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ from(sourceSets.main.get().output)
+ }
- val keepAnnoAnnotationsDoc by registering(Javadoc::class) {
- source = sourceSets.main.get().allJava
- include("com/android/tools/r8/keepanno/annotations/*")
- }
+ val keepAnnoAnnotationsDoc by
+ registering(Javadoc::class) {
+ source = sourceSets.main.get().allJava
+ include("com/android/tools/r8/keepanno/annotations/*")
+ }
- fun dependenciesExceptAsm() : FileCollection {
- return sourceSets
- .main
+ fun dependenciesExceptAsm(): FileCollection {
+ return sourceSets.main
.get()
.compileClasspath
- .filter({ "$it".contains("third_party")
- && "$it".contains("dependencies")
- && !("$it".contains("errorprone") || "$it".contains("ow2"))
+ .filter({
+ "$it".contains("third_party") &&
+ "$it".contains("dependencies") &&
+ !("$it".contains("errorprone") || "$it".contains("ow2"))
})
}
- fun dependenciesOnlyAsm() : FileCollection {
- return sourceSets
- .main
+ fun dependenciesOnlyAsm(): FileCollection {
+ return sourceSets.main
.get()
.compileClasspath
- .filter({ "$it".contains("third_party")
- && "$it".contains("dependencies")
- && ("$it".contains("errorprone") || "$it".contains("ow2"))
+ .filter({
+ "$it".contains("third_party") &&
+ "$it".contains("dependencies") &&
+ ("$it".contains("errorprone") || "$it".contains("ow2"))
})
}
- val depsJarExceptAsm by registering(Jar::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- from(dependenciesExceptAsm().map(::zipTree))
- // TODO(b/428166503): Add license information.
- exclude("META-INF/*.kotlin_module")
- exclude("META-INF/com.android.tools/**")
- exclude("META-INF/LICENSE*")
- exclude("META-INF/MANIFEST.MF")
- exclude("META-INF/maven/**")
- exclude("META-INF/proguard/**")
- exclude("META-INF/versions/**")
- exclude("META-INF/services/kotlin.reflect.**")
- exclude("javax/annotation/**")
- exclude("google/protobuf/**")
- duplicatesStrategy = DuplicatesStrategy.FAIL
- archiveFileName.set("keepanno-deps-except-asm.jar")
- }
+ val depsJarExceptAsm by
+ registering(Jar::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ from(dependenciesExceptAsm().map(::zipTree))
+ // TODO(b/428166503): Add license information.
+ exclude("META-INF/*.kotlin_module")
+ exclude("META-INF/com.android.tools/**")
+ exclude("META-INF/LICENSE*")
+ exclude("META-INF/MANIFEST.MF")
+ exclude("META-INF/maven/**")
+ exclude("META-INF/proguard/**")
+ exclude("META-INF/versions/**")
+ exclude("META-INF/services/kotlin.reflect.**")
+ exclude("javax/annotation/**")
+ exclude("google/protobuf/**")
+ duplicatesStrategy = DuplicatesStrategy.FAIL
+ archiveFileName.set("keepanno-deps-except-asm.jar")
+ }
- val depsJarOnlyAsm by registering(Jar::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- from(dependenciesOnlyAsm().map(::zipTree))
- // TODO(b/428166503): Add license information if needed.
- exclude("META-INF/*.kotlin_module")
- exclude("META-INF/com.android.tools/**")
- exclude("META-INF/LICENSE*")
- exclude("META-INF/MANIFEST.MF")
- exclude("META-INF/maven/**")
- exclude("META-INF/proguard/**")
- exclude("META-INF/versions/**")
- exclude("META-INF/services/kotlin.reflect.**")
- exclude("javax/annotation/**")
- exclude("google/protobuf/**")
- duplicatesStrategy = DuplicatesStrategy.FAIL
- archiveFileName.set("keepanno-deps-only-asm.jar")
- }
+ val depsJarOnlyAsm by
+ registering(Jar::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ from(dependenciesOnlyAsm().map(::zipTree))
+ // TODO(b/428166503): Add license information if needed.
+ exclude("META-INF/*.kotlin_module")
+ exclude("META-INF/com.android.tools/**")
+ exclude("META-INF/LICENSE*")
+ exclude("META-INF/MANIFEST.MF")
+ exclude("META-INF/maven/**")
+ exclude("META-INF/proguard/**")
+ exclude("META-INF/versions/**")
+ exclude("META-INF/services/kotlin.reflect.**")
+ exclude("javax/annotation/**")
+ exclude("google/protobuf/**")
+ duplicatesStrategy = DuplicatesStrategy.FAIL
+ archiveFileName.set("keepanno-deps-only-asm.jar")
+ }
- val toolsJar by registering(Jar::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- from(sourceSets.main.get().output)
- // TODO(b/428166503): Add license information.
- entryCompression = ZipEntryCompression.STORED
- exclude("META-INF/*.kotlin_module")
- exclude("**/*.kotlin_metadata")
- exclude("keepspec.proto")
- exclude("com/android/tools/r8/keepanno/annotations/**")
- exclude("androidx/**")
- archiveFileName.set("keepanno-tools.jar")
- }
+ val toolsJar by
+ registering(Jar::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ from(sourceSets.main.get().output)
+ // TODO(b/428166503): Add license information.
+ entryCompression = ZipEntryCompression.STORED
+ exclude("META-INF/*.kotlin_module")
+ exclude("**/*.kotlin_metadata")
+ exclude("keepspec.proto")
+ exclude("com/android/tools/r8/keepanno/annotations/**")
+ exclude("androidx/**")
+ archiveFileName.set("keepanno-tools.jar")
+ }
}
diff --git a/d8_r8/keepanno/settings.gradle.kts b/d8_r8/keepanno/settings.gradle.kts
index 4b9b240..a05e5ed 100644
--- a/d8_r8/keepanno/settings.gradle.kts
+++ b/d8_r8/keepanno/settings.gradle.kts
@@ -4,23 +4,17 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../third_party/dependencies")
- }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../third_party/dependencies") } }
}
rootProject.name = "keepanno"
+
val root = rootProject.projectDir.parentFile
+
includeBuild(root.resolve("shared"))
diff --git a/d8_r8/libanalyzer/build.gradle.kts b/d8_r8/libanalyzer/build.gradle.kts
index ce8be43..1e51b7a 100644
--- a/d8_r8/libanalyzer/build.gradle.kts
+++ b/d8_r8/libanalyzer/build.gradle.kts
@@ -2,11 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import com.google.protobuf.gradle.proto
import com.google.protobuf.gradle.ProtobufExtension
+import com.google.protobuf.gradle.proto
import net.ltgt.gradle.errorprone.errorprone
import org.gradle.api.tasks.bundling.Jar
-import org.gradle.api.tasks.bundling.ZipEntryCompression
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
plugins {
@@ -18,14 +17,13 @@
// It seems like the use of a local maven repo does not allow adding the plugin with the id+version
// syntax. Also, for some reason the 'protobuf' extension object cannot be directly referenced.
// This configures the plugin "old style" and pulls out the extension object manually.
-buildscript {
- dependencies {
- classpath("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
- }
-}
+buildscript { dependencies { classpath("com.google.protobuf:protobuf-gradle-plugin:0.9.4") } }
+
apply(plugin = "com.google.protobuf")
+
var os = DefaultNativePlatform.getCurrentOperatingSystem()
var protobuf = project.extensions.getByName("protobuf") as ProtobufExtension
+
protobuf.protoc {
if (os.isLinux) {
path = getRoot().resolveAll("third_party", "protoc", "linux-x86_64", "bin", "protoc").path
@@ -40,21 +38,15 @@
java {
sourceSets.main.configure {
java.srcDir(getRoot().resolveAll("src", "libanalyzer", "java"))
- proto {
- srcDir(getRoot().resolveAll("src", "libanalyzer", "proto"))
- }
+ proto { srcDir(getRoot().resolveAll("src", "libanalyzer", "proto")) }
}
sourceCompatibility = JvmCompatibility.sourceCompatibility
targetCompatibility = JvmCompatibility.targetCompatibility
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
withSourcesJar()
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
dependencies {
compileOnly(Deps.guava)
diff --git a/d8_r8/libanalyzer/settings.gradle.kts b/d8_r8/libanalyzer/settings.gradle.kts
index 6ef1f6e..09dc124 100644
--- a/d8_r8/libanalyzer/settings.gradle.kts
+++ b/d8_r8/libanalyzer/settings.gradle.kts
@@ -4,25 +4,19 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../third_party/dependencies")
- }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../third_party/dependencies") } }
}
rootProject.name = "libanalyzer"
val root = rootProject.projectDir.parentFile
+
includeBuild(root.resolve("main"))
+
includeBuild(root.resolve("shared"))
diff --git a/d8_r8/library_desugar/build.gradle.kts b/d8_r8/library_desugar/build.gradle.kts
index 8d560f0..853978f 100644
--- a/d8_r8/library_desugar/build.gradle.kts
+++ b/d8_r8/library_desugar/build.gradle.kts
@@ -14,14 +14,9 @@
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
-dependencies {
-}
+dependencies {}
diff --git a/d8_r8/library_desugar/settings.gradle.kts b/d8_r8/library_desugar/settings.gradle.kts
index 02ff676..bcc6932 100644
--- a/d8_r8/library_desugar/settings.gradle.kts
+++ b/d8_r8/library_desugar/settings.gradle.kts
@@ -4,21 +4,13 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../third_party/dependencies")
- }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../third_party/dependencies") } }
}
rootProject.name = "library_desugar"
diff --git a/d8_r8/main/build.gradle.kts b/d8_r8/main/build.gradle.kts
index a2dfde3..796f585 100644
--- a/d8_r8/main/build.gradle.kts
+++ b/d8_r8/main/build.gradle.kts
@@ -213,15 +213,11 @@
sourceCompatibility = JvmCompatibility.sourceCompatibility
targetCompatibility = JvmCompatibility.targetCompatibility
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
withSourcesJar()
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
dependencies {
implementation(":assistant")
@@ -305,11 +301,11 @@
// (git hash) and artifact name.
if (project.hasProperty("spdxRevision")) {
namespace.set(
- "https://spdx.google/"
- + uuid5(
- UUID.fromString("df17ea25-709b-4edc-8dc1-d3ca82c74e8e"),
- project.property("spdxRevision").toString() + "-r8"
- )
+ "https://spdx.google/" +
+ uuid5(
+ UUID.fromString("df17ea25-709b-4edc-8dc1-d3ca82c74e8e"),
+ project.property("spdxRevision").toString() + "-r8",
+ )
)
}
creator.set("Organization: Google LLC")
@@ -328,14 +324,14 @@
val resourceShrinkerJarTask = projectTask("resourceshrinker", "jar")
val resourceShrinkerDepsTask = projectTask("resourceshrinker", "depsJar")
-fun mainJarDependencies() : FileCollection {
- return sourceSets
- .main
+fun mainJarDependencies(): FileCollection {
+ return sourceSets.main
.get()
.compileClasspath
- .filter({ "$it".contains("third_party")
- && "$it".contains("dependencies")
- && !"$it".contains("errorprone")
+ .filter({
+ "$it".contains("third_party") &&
+ "$it".contains("dependencies") &&
+ !"$it".contains("errorprone")
})
}
@@ -343,60 +339,54 @@
jar {
from(sourceSets["turbo"].output)
doLast {
- enforceUncompressedEntries(
- archiveFile.get().asFile,
- setOf("resources/new_api_database.ser"))
+ enforceUncompressedEntries(archiveFile.get().asFile, setOf("resources/new_api_database.ser"))
}
}
- withType<Exec> {
- doFirst {
- println("Executing command: ${commandLine.joinToString(" ")}")
- }
- }
+ withType<Exec> { doFirst { println("Executing command: ${commandLine.joinToString(" ")}") } }
- withType<ProcessResources> {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- }
+ withType<ProcessResources> { dependsOn(gradle.includedBuild("shared").task(":downloadDeps")) }
withType<SpdxSbomTask> {
- taskExtension.set(object : DefaultSpdxSbomTaskExtension() {
- override fun mapRepoUri(input: URI?, moduleId: ModuleVersionIdentifier): URI? {
+ taskExtension.set(
+ object : DefaultSpdxSbomTaskExtension() {
+ override fun mapRepoUri(input: URI?, moduleId: ModuleVersionIdentifier): URI? {
- // Locate the file origin.json with URL for download location.
- fun getOriginJson() : java.nio.file.Path {
- var repositoryDir =
+ // Locate the file origin.json with URL for download location.
+ fun getOriginJson(): java.nio.file.Path {
+ var repositoryDir =
moduleId.group.replace('.', '/') + "/" + moduleId.name + "/" + moduleId.version
- return Paths.get("third_party", "dependencies", repositoryDir, "origin.json");
+ return Paths.get("third_party", "dependencies", repositoryDir, "origin.json")
+ }
+
+ // Simple data model of the content of origin.json generated by the tool to download
+ // and create a local repository. E.g.:
+ /*
+ {
+ "artifacts": [
+ {
+ "file": "org/ow2/asm/asm/9.5/asm-9.5.pom",
+ "repo": "https://repo1.maven.org/maven2/",
+ "artifact": "org.ow2.asm:asm:pom:9.5"
+ },
+ {
+ "file": "org/ow2/asm/asm/9.5/asm-9.5.jar",
+ "repo": "https://repo1.maven.org/maven2/",
+ "artifact": "org.ow2.asm:asm:jar:9.5"
+ }
+ ]
+ }
+ */
+ data class Artifact(val file: String, val repo: String, val artifact: String)
+ data class Artifacts(val artifacts: List<Artifact>)
+
+ // Read origin.json.
+ val json = readString(getOriginJson())
+ val artifacts = Gson().fromJson(json, Artifacts::class.java)
+ return URI.create(artifacts.artifacts.get(0).repo)
}
-
- // Simple data model of the content of origin.json generated by the tool to download
- // and create a local repository. E.g.:
- /*
- {
- "artifacts": [
- {
- "file": "org/ow2/asm/asm/9.5/asm-9.5.pom",
- "repo": "https://repo1.maven.org/maven2/",
- "artifact": "org.ow2.asm:asm:pom:9.5"
- },
- {
- "file": "org/ow2/asm/asm/9.5/asm-9.5.jar",
- "repo": "https://repo1.maven.org/maven2/",
- "artifact": "org.ow2.asm:asm:jar:9.5"
- }
- ]
- }
- */
- data class Artifact(val file: String, val repo: String, val artifact: String)
- data class Artifacts(val artifacts: List<Artifact>)
-
- // Read origin.json.
- val json = readString(getOriginJson());
- val artifacts = Gson().fromJson(json, Artifacts::class.java);
- return URI.create(artifacts.artifacts.get(0).repo)
}
- })
+ )
}
val consolidatedLicense by registering {
@@ -409,7 +399,8 @@
inputs.files(
listOf(r8License, libraryLicense),
libraryLicenseFiles,
- mainJarDependencies().map(::zipTree))
+ mainJarDependencies().map(::zipTree),
+ )
val license = getRoot().resolveAll("build", "generatedLicense", "LICENSE")
outputs.files(license)
@@ -434,256 +425,276 @@
}
license.getParentFile().mkdirs()
license.createNewFile()
- license.writeText(buildString {
- append("This file lists all licenses for code distributed.\n")
- .append("All non-library code has the following 3-Clause BSD license.\n")
- .append("\n")
- .append("\n")
- .append(r8License.readText())
- .append("\n")
- .append("\n")
- .append("Summary of distributed libraries:\n")
- .append("\n")
- .append(libraryLicenses)
- .append("\n")
- .append("\n")
- .append("Licenses details:\n")
- libraryLicenseFiles.sorted().forEach { file ->
- append("\n").append("\n").append(file.readText())
+ license.writeText(
+ buildString {
+ append("This file lists all licenses for code distributed.\n")
+ .append("All non-library code has the following 3-Clause BSD license.\n")
+ .append("\n")
+ .append("\n")
+ .append(r8License.readText())
+ .append("\n")
+ .append("\n")
+ .append("Summary of distributed libraries:\n")
+ .append("\n")
+ .append(libraryLicenses)
+ .append("\n")
+ .append("\n")
+ .append("Licenses details:\n")
+ libraryLicenseFiles.sorted().forEach { file ->
+ append("\n").append("\n").append(file.readText())
+ }
}
- })
+ )
}
}
- val swissArmyKnife by registering(Jar::class) {
- dependsOn(assistantJarTask, blastRadiusJarTask, keepAnnoJarTask, libraryAnalyzerJarTask, resourceShrinkerJarTask)
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- from(sourceSets.main.get().output)
- from(sourceSets["turbo"].output)
- exclude("com/android/tools/r8/threading/providers/**")
- from(assistantJarTask.outputs.files.map(::zipTree))
- from(blastRadiusJarTask.outputs.files.map(::zipTree))
- from(keepAnnoJarTask.outputs.files.map(::zipTree))
- from(libraryAnalyzerJarTask.outputs.files.map(::zipTree))
- from(resourceShrinkerJarTask.outputs.files.map(::zipTree))
- from(getRoot().resolve("LICENSE"))
- entryCompression = ZipEntryCompression.STORED
- manifest {
- attributes["Main-Class"] = "com.android.tools.r8.SwissArmyKnife"
+ val swissArmyKnife by
+ registering(Jar::class) {
+ dependsOn(
+ assistantJarTask,
+ blastRadiusJarTask,
+ keepAnnoJarTask,
+ libraryAnalyzerJarTask,
+ resourceShrinkerJarTask,
+ )
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ from(sourceSets.main.get().output)
+ from(sourceSets["turbo"].output)
+ exclude("com/android/tools/r8/threading/providers/**")
+ from(assistantJarTask.outputs.files.map(::zipTree))
+ from(blastRadiusJarTask.outputs.files.map(::zipTree))
+ from(keepAnnoJarTask.outputs.files.map(::zipTree))
+ from(libraryAnalyzerJarTask.outputs.files.map(::zipTree))
+ from(resourceShrinkerJarTask.outputs.files.map(::zipTree))
+ from(getRoot().resolve("LICENSE"))
+ entryCompression = ZipEntryCompression.STORED
+ manifest { attributes["Main-Class"] = "com.android.tools.r8.SwissArmyKnife" }
+ exclude("META-INF/*.kotlin_module")
+ exclude("**/*.kotlin_metadata")
+ exclude("blastradius.proto")
+ exclude("keepspec.proto")
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ archiveFileName.set("r8-full-exclude-deps.jar")
}
- exclude("META-INF/*.kotlin_module")
- exclude("**/*.kotlin_metadata")
- exclude("blastradius.proto")
- exclude("keepspec.proto")
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- archiveFileName.set("r8-full-exclude-deps.jar")
+
+ val threadingModuleBlockingJar by
+ registering(Zip::class) {
+ from(sourceSets.main.get().output)
+ from(sourceSets["turbo"].output)
+ include("com/android/tools/r8/threading/providers/blocking/**")
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ archiveFileName.set("threading-module-blocking.jar")
+ }
+
+ val threadingModuleSingleThreadedJar by
+ registering(Zip::class) {
+ from(sourceSets.main.get().output)
+ from(sourceSets["turbo"].output)
+ include("com/android/tools/r8/threading/providers/singlethreaded/**")
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ archiveFileName.set("threading-module-single-threaded.jar")
+ }
+
+ val depsJar by
+ registering(Zip::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ dependsOn(resourceShrinkerDepsTask)
+ dependsOn(threadingModuleBlockingJar)
+ dependsOn(threadingModuleSingleThreadedJar)
+ from(threadingModuleBlockingJar.get().outputs.getFiles().map(::zipTree))
+ from(threadingModuleSingleThreadedJar.get().outputs.getFiles().map(::zipTree))
+ from(mainJarDependencies().map(::zipTree))
+ from(resourceShrinkerDepsTask.outputs.files.map(::zipTree))
+ from(consolidatedLicense)
+ exclude("**/module-info.class")
+ exclude("**/*.kotlin_metadata")
+ exclude("META-INF/*.kotlin_module")
+ exclude("META-INF/com.android.tools/**")
+ exclude("META-INF/LICENSE*")
+ exclude("META-INF/MANIFEST.MF")
+ exclude("META-INF/kotlinx_coroutines_core.version")
+ exclude("META-INF/androidx/**/LICENSE.txt")
+ exclude("META-INF/maven/**")
+ exclude("META-INF/proguard/**")
+ exclude("META-INF/versions/**")
+ exclude("META-INF/services/kotlin.reflect.**")
+ exclude("**/*.xml")
+ exclude("com/android/version.properties")
+ exclude("NOTICE")
+ exclude("README.md")
+ exclude("javax/annotation/**")
+ exclude("wireless/**")
+ exclude("google/protobuf/**")
+ exclude("DebugProbesKt.bin")
+
+ // Disabling compression makes this step go from 4s -> 2s as of Nov 2025,
+ // as measured by "gradle --profile".
+ entryCompression = ZipEntryCompression.STORED
+
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ archiveFileName.set("deps.jar")
+ }
+
+ val swissArmyKnifeWithoutLicense by
+ registering(Zip::class) {
+ dependsOn(swissArmyKnife)
+ from(swissArmyKnife.get().outputs.files.map(::zipTree))
+ exclude("LICENSE")
+ exclude("androidx/")
+ exclude("androidx/annotation/")
+ exclude("androidx/annotation/keep/**")
+ archiveFileName.set("swiss-army-no-license.jar")
+ }
+
+ fun relocateDepsExceptAsm(pkg: String): List<String> {
+ return listOf(
+ "--map",
+ "android.aapt.**->${pkg}.android.aapt",
+ "--map",
+ "androidx.annotation.**->${pkg}.androidx.annotation",
+ "--map",
+ "androidx.collection.**->${pkg}.androidx.collection",
+ "--map",
+ "androidx.tracing.**->${pkg}.androidx.tracing",
+ "--map",
+ "com.android.**->${pkg}.com.android",
+ "--map",
+ "com.android.build.shrinker.**->${pkg}.resourceshrinker",
+ "--map",
+ "com.google.common.**->${pkg}.com.google.common",
+ "--map",
+ "com.google.gson.**->${pkg}.com.google.gson",
+ "--map",
+ "com.google.thirdparty.**->${pkg}.com.google.thirdparty",
+ "--map",
+ "com.squareup.wire.**->${pkg}.com.squareup.wire",
+ "--map",
+ "it.unimi.dsi.fastutil.**->${pkg}.it.unimi.dsi.fastutil",
+ "--map",
+ "kotlin.**->${pkg}.jetbrains.kotlin",
+ "--map",
+ "kotlinx.**->${pkg}.jetbrains.kotlinx",
+ "--map",
+ "okio.**->${pkg}.okio",
+ "--map",
+ "org.jetbrains.**->${pkg}.org.jetbrains",
+ "--map",
+ "org.intellij.**->${pkg}.org.intellij",
+ "--map",
+ "org.checkerframework.**->${pkg}.org.checkerframework",
+ "--map",
+ "com.google.j2objc.**->${pkg}.com.google.j2objc",
+ "--map",
+ "com.google.protobuf.**->${pkg}.com.google.protobuf",
+ "--map",
+ "perfetto.protos.**->${pkg}.perfetto.protos",
+ "--map",
+ "org.jspecify.annotations.**->${pkg}.org.jspecify.annotations",
+ "--map",
+ "_COROUTINE.**->${pkg}._COROUTINE",
+ )
}
- val threadingModuleBlockingJar by registering(Zip::class) {
- from(sourceSets.main.get().output)
- from(sourceSets["turbo"].output)
- include("com/android/tools/r8/threading/providers/blocking/**")
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- archiveFileName.set("threading-module-blocking.jar")
- }
+ val r8WithRelocatedDeps by
+ registering(Exec::class) {
+ dependsOn(depsJar)
+ dependsOn(swissArmyKnifeWithoutLicense)
+ val swissArmy = swissArmyKnifeWithoutLicense.get().outputs.files.singleFile
+ val deps = depsJar.get().outputs.files.singleFile
+ inputs.files(listOf(swissArmy, deps))
+ val output = getRoot().resolveAll("build", "libs", "r8.jar")
+ outputs.file(output)
+ val pkg = "com.android.tools.r8"
+ commandLine =
+ baseCompilerCommandLine(
+ swissArmy,
+ deps,
+ "relocator",
+ listOf(
+ "--input",
+ "$swissArmy",
+ "--input",
+ "$deps",
+ "--output",
+ "$output",
+ // Add identity mapping to enforce no relocation of things already in package
+ // com.android.tools.r8.
+ "--map",
+ "com.android.tools.r8.**->${pkg}",
+ // Add identity for the public annotation surface of keepanno
+ "--map",
+ "com.android.tools.r8.keepanno.annotations.**->${pkg}.keepanno.annotations",
+ // Explicitly move all other keepanno utilities.
+ "--map",
+ "com.android.tools.r8.keepanno.**->${pkg}.relocated.keepanno",
+ "--map",
+ "org.objectweb.asm.**->${pkg}.org.objectweb.asm",
+ ) + relocateDepsExceptAsm(pkg),
+ )
+ }
- val threadingModuleSingleThreadedJar by registering(Zip::class) {
- from(sourceSets.main.get().output)
- from(sourceSets["turbo"].output)
- include("com/android/tools/r8/threading/providers/singlethreaded/**")
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- archiveFileName.set("threading-module-single-threaded.jar")
- }
+ val keepAnnoToolsWithRelocatedDeps by
+ registering(Exec::class) {
+ dependsOn(depsJar)
+ dependsOn(swissArmyKnifeWithoutLicense)
+ dependsOn(keepAnnoDepsJarExceptAsm)
+ dependsOn(keepAnnoToolsJar)
+ val swissArmy = swissArmyKnifeWithoutLicense.get().outputs.files.singleFile
+ val deps = depsJar.get().outputs.files.singleFile
+ val keepAnnoDeps = keepAnnoDepsJarExceptAsm.outputs.files.singleFile
+ val tools = keepAnnoToolsJar.outputs.files.singleFile
+ inputs.files(listOf(tools, keepAnnoDeps))
+ val output = getRoot().resolveAll("build", "libs", "keepanno-tools.jar")
+ outputs.file(output)
+ val pkg = "com.android.tools.r8.keepanno"
+ commandLine =
+ baseCompilerCommandLine(
+ swissArmy,
+ deps,
+ "relocator",
+ listOf(
+ "--input",
+ "$tools",
+ "--input",
+ "$keepAnnoDeps",
+ "--output",
+ "$output",
+ // Add identity mapping to enforce no relocation of things already in package
+ // com.android.tools.r8.keepanno
+ "--map",
+ "com.android.tools.r8.keepanno.**->${pkg}",
+ ) + relocateDepsExceptAsm(pkg),
+ )
+ }
- val depsJar by registering(Zip::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- dependsOn(resourceShrinkerDepsTask)
- dependsOn(threadingModuleBlockingJar)
- dependsOn(threadingModuleSingleThreadedJar)
- from(threadingModuleBlockingJar.get().outputs.getFiles().map(::zipTree))
- from(threadingModuleSingleThreadedJar.get().outputs.getFiles().map(::zipTree))
- from(mainJarDependencies().map(::zipTree))
- from(resourceShrinkerDepsTask.outputs.files.map(::zipTree))
- from(consolidatedLicense)
- exclude("**/module-info.class")
- exclude("**/*.kotlin_metadata")
- exclude("META-INF/*.kotlin_module")
- exclude("META-INF/com.android.tools/**")
- exclude("META-INF/LICENSE*")
- exclude("META-INF/MANIFEST.MF")
- exclude("META-INF/kotlinx_coroutines_core.version")
- exclude("META-INF/androidx/**/LICENSE.txt")
- exclude("META-INF/maven/**")
- exclude("META-INF/proguard/**")
- exclude("META-INF/versions/**")
- exclude("META-INF/services/kotlin.reflect.**")
- exclude("**/*.xml")
- exclude("com/android/version.properties")
- exclude("NOTICE")
- exclude("README.md")
- exclude("javax/annotation/**")
- exclude("wireless/**")
- exclude("google/protobuf/**")
- exclude("DebugProbesKt.bin")
-
- // Disabling compression makes this step go from 4s -> 2s as of Nov 2025,
- // as measured by "gradle --profile".
- entryCompression = ZipEntryCompression.STORED
-
- duplicatesStrategy = DuplicatesStrategy.EXCLUDE
- archiveFileName.set("deps.jar")
- }
-
-val swissArmyKnifeWithoutLicense by registering(Zip::class) {
- dependsOn(swissArmyKnife)
- from(swissArmyKnife.get().outputs.files.map(::zipTree))
- exclude("LICENSE")
- exclude("androidx/")
- exclude("androidx/annotation/")
- exclude("androidx/annotation/keep/**")
- archiveFileName.set("swiss-army-no-license.jar")
+ val processKeepRulesLibWithRelocatedDeps by
+ registering(Exec::class) {
+ dependsOn(r8WithRelocatedDeps)
+ val createR8LibFile = getRoot().resolveAll("tools", "create_r8lib.py")
+ val keepRulesFile = getRoot().resolveAll("src", "main", "keep_processkeeprules.txt")
+ val r8WithRelocatedDepsJar = r8WithRelocatedDeps.get().outputs.files.singleFile
+ inputs.files(listOf(createR8LibFile, keepRulesFile, r8WithRelocatedDepsJar))
+ val outputJar = getRoot().resolveAll("build", "libs", "processkeepruleslib.jar")
+ outputs.file(outputJar)
+ commandLine =
+ createR8LibCommandLine(
+ r8WithRelocatedDepsJar,
+ r8WithRelocatedDepsJar,
+ outputJar,
+ listOf(keepRulesFile),
+ excludingDepsVariant = false,
+ debugVariant = false,
+ classpath = listOf(),
+ enableKeepAnnotations = false,
+ )
+ }
}
-fun relocateDepsExceptAsm(pkg: String): List<String> {
- return listOf("--map",
- "android.aapt.**->${pkg}.android.aapt",
- "--map",
- "androidx.annotation.**->${pkg}.androidx.annotation",
- "--map",
- "androidx.collection.**->${pkg}.androidx.collection",
- "--map",
- "androidx.tracing.**->${pkg}.androidx.tracing",
- "--map",
- "com.android.**->${pkg}.com.android",
- "--map",
- "com.android.build.shrinker.**->${pkg}.resourceshrinker",
- "--map",
- "com.google.common.**->${pkg}.com.google.common",
- "--map",
- "com.google.gson.**->${pkg}.com.google.gson",
- "--map",
- "com.google.thirdparty.**->${pkg}.com.google.thirdparty",
- "--map",
- "com.squareup.wire.**->${pkg}.com.squareup.wire",
- "--map",
- "it.unimi.dsi.fastutil.**->${pkg}.it.unimi.dsi.fastutil",
- "--map",
- "kotlin.**->${pkg}.jetbrains.kotlin",
- "--map",
- "kotlinx.**->${pkg}.jetbrains.kotlinx",
- "--map",
- "okio.**->${pkg}.okio",
- "--map",
- "org.jetbrains.**->${pkg}.org.jetbrains",
- "--map",
- "org.intellij.**->${pkg}.org.intellij",
- "--map",
- "org.checkerframework.**->${pkg}.org.checkerframework",
- "--map",
- "com.google.j2objc.**->${pkg}.com.google.j2objc",
- "--map",
- "com.google.protobuf.**->${pkg}.com.google.protobuf",
- "--map",
- "perfetto.protos.**->${pkg}.perfetto.protos",
- "--map",
- "org.jspecify.annotations.**->${pkg}.org.jspecify.annotations",
- "--map",
- "_COROUTINE.**->${pkg}._COROUTINE")
-}
-
-val r8WithRelocatedDeps by registering(Exec::class) {
- dependsOn(depsJar)
- dependsOn(swissArmyKnifeWithoutLicense)
- val swissArmy = swissArmyKnifeWithoutLicense.get().outputs.files.singleFile
- val deps = depsJar.get().outputs.files.singleFile
- inputs.files(listOf(swissArmy, deps))
- val output = getRoot().resolveAll("build", "libs", "r8.jar")
- outputs.file(output)
- val pkg = "com.android.tools.r8"
- commandLine = baseCompilerCommandLine(
- swissArmy,
- deps,
- "relocator",
- listOf("--input",
- "$swissArmy",
- "--input",
- "$deps",
- "--output",
- "$output",
- // Add identity mapping to enforce no relocation of things already in package
- // com.android.tools.r8.
- "--map",
- "com.android.tools.r8.**->${pkg}",
- // Add identity for the public annotation surface of keepanno
- "--map",
- "com.android.tools.r8.keepanno.annotations.**->${pkg}.keepanno.annotations",
- // Explicitly move all other keepanno utilities.
- "--map",
- "com.android.tools.r8.keepanno.**->${pkg}.relocated.keepanno",
- "--map",
- "org.objectweb.asm.**->${pkg}.org.objectweb.asm")
- + relocateDepsExceptAsm(pkg)
- )
- }
-
-
-val keepAnnoToolsWithRelocatedDeps by registering(Exec::class) {
- dependsOn(depsJar)
- dependsOn(swissArmyKnifeWithoutLicense)
- dependsOn(keepAnnoDepsJarExceptAsm)
- dependsOn(keepAnnoToolsJar)
- val swissArmy = swissArmyKnifeWithoutLicense.get().outputs.files.singleFile
- val deps = depsJar.get().outputs.files.singleFile
- val keepAnnoDeps = keepAnnoDepsJarExceptAsm.outputs.files.singleFile
- val tools = keepAnnoToolsJar.outputs.files.singleFile
- inputs.files(listOf(tools, keepAnnoDeps))
- val output = getRoot().resolveAll("build", "libs", "keepanno-tools.jar")
- outputs.file(output)
- val pkg = "com.android.tools.r8.keepanno"
- commandLine = baseCompilerCommandLine(
- swissArmy,
- deps,
- "relocator",
- listOf("--input",
- "$tools",
- "--input",
- "$keepAnnoDeps",
- "--output",
- "$output",
- // Add identity mapping to enforce no relocation of things already in package
- // com.android.tools.r8.keepanno
- "--map",
- "com.android.tools.r8.keepanno.**->${pkg}")
- + relocateDepsExceptAsm(pkg)
- )
- }
-
- val processKeepRulesLibWithRelocatedDeps by registering(Exec::class) {
- dependsOn(r8WithRelocatedDeps)
- val createR8LibFile = getRoot().resolveAll("tools", "create_r8lib.py")
- val keepRulesFile = getRoot().resolveAll("src", "main", "keep_processkeeprules.txt")
- val r8WithRelocatedDepsJar = r8WithRelocatedDeps.get().outputs.files.singleFile
- inputs.files(listOf(createR8LibFile, keepRulesFile, r8WithRelocatedDepsJar))
- val outputJar = getRoot().resolveAll("build", "libs", "processkeepruleslib.jar")
- outputs.file(outputJar)
- commandLine = createR8LibCommandLine(
- r8WithRelocatedDepsJar,
- r8WithRelocatedDepsJar,
- outputJar,
- listOf(keepRulesFile),
- excludingDepsVariant = false,
- debugVariant = false,
- classpath = listOf(),
- enableKeepAnnotations = false)
- }
-}
-
-tasks.withType<KotlinCompile> {
- enabled = false
-}
+tasks.withType<KotlinCompile> { enabled = false }
/**
* Re-packages a JAR file to ensure specific entries are stored uncompressed (STORED).
+ *
* @param jarFile The target JAR file to modify in-place.
* @param uncompressedEntries A set of file paths to store uncompressed.
*/
@@ -723,15 +734,12 @@
}
// Overwrite the original jar.
- Files.move(
- tempJarFile.toPath(),
- jarFile.toPath(),
- StandardCopyOption.REPLACE_EXISTING
- )
+ Files.move(tempJarFile.toPath(), jarFile.toPath(), StandardCopyOption.REPLACE_EXISTING)
}
tasks.withType<JavaCompile> {
dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
println("NOTE: Running with JDK: " + org.gradle.internal.jvm.Jvm.current().javaHome)
}
+
configureErrorProneForJavaCompile()
diff --git a/d8_r8/main/settings.gradle.kts b/d8_r8/main/settings.gradle.kts
index 872fcce..74ae963 100644
--- a/d8_r8/main/settings.gradle.kts
+++ b/d8_r8/main/settings.gradle.kts
@@ -4,29 +4,27 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../third_party/dependencies")
- }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../third_party/dependencies") } }
}
rootProject.name = "r8"
val root = rootProject.projectDir.parentFile
+
includeBuild(root.resolve("blastradius"))
+
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("assistant"))
+
includeBuild(root.resolve("keepanno"))
+
includeBuild(root.resolve("libanalyzer"))
+
includeBuild(root.resolve("resourceshrinker"))
diff --git a/d8_r8/resourceshrinker/build.gradle.kts b/d8_r8/resourceshrinker/build.gradle.kts
index 8a67e3b..2e6618b 100644
--- a/d8_r8/resourceshrinker/build.gradle.kts
+++ b/d8_r8/resourceshrinker/build.gradle.kts
@@ -16,24 +16,20 @@
}
sourceCompatibility = JvmCompatibility.sourceCompatibility
targetCompatibility = JvmCompatibility.targetCompatibility
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
withSourcesJar()
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
-fun jarDependencies() : FileCollection {
- return sourceSets
- .main
+fun jarDependencies(): FileCollection {
+ return sourceSets.main
.get()
.compileClasspath
- .filter({ "$it".contains("third_party")
- && "$it".contains("dependencies")
- && !"$it".contains("errorprone")
+ .filter({
+ "$it".contains("third_party") &&
+ "$it".contains("dependencies") &&
+ !"$it".contains("errorprone")
})
}
@@ -59,11 +55,12 @@
}
}
- val depsJar by registering(Jar::class) {
- from(jarDependencies().map(::zipTree))
- exclude("**/*.proto")
- exclude("versions-offline/**")
- duplicatesStrategy = DuplicatesStrategy.EXCLUDE
- archiveFileName.set("resourceshrinker_deps.jar")
- }
+ val depsJar by
+ registering(Jar::class) {
+ from(jarDependencies().map(::zipTree))
+ exclude("**/*.proto")
+ exclude("versions-offline/**")
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ archiveFileName.set("resourceshrinker_deps.jar")
+ }
}
diff --git a/d8_r8/resourceshrinker/settings.gradle.kts b/d8_r8/resourceshrinker/settings.gradle.kts
index 31a3ce7..a79c533 100644
--- a/d8_r8/resourceshrinker/settings.gradle.kts
+++ b/d8_r8/resourceshrinker/settings.gradle.kts
@@ -4,24 +4,17 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../third_party/dependencies")
- }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../third_party/dependencies") } }
}
rootProject.name = "resourceshrinker"
val root = rootProject.projectDir.parentFile
+
includeBuild(root.resolve("shared"))
diff --git a/d8_r8/shared/build.gradle.kts b/d8_r8/shared/build.gradle.kts
index 83c944c..516d5b0 100644
--- a/d8_r8/shared/build.gradle.kts
+++ b/d8_r8/shared/build.gradle.kts
@@ -7,25 +7,26 @@
id("dependencies-plugin")
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
tasks {
+ val downloadDeps by
+ registering(DownloadAllDependenciesTask::class) {
+ this.setDependencies(getRoot(), allPublicDependencies())
+ }
- val downloadDeps by registering(DownloadAllDependenciesTask::class) {
- this.setDependencies(getRoot(), allPublicDependencies())
- }
+ val downloadTestDeps by
+ registering(DownloadAllDependenciesTask::class) {
+ this.setDependencies(getRoot(), allPublicTestDependencies())
+ }
- val downloadTestDeps by registering(DownloadAllDependenciesTask::class) {
- this.setDependencies(getRoot(), allPublicTestDependencies())
- }
+ val downloadDepsInternal by
+ registering(DownloadAllDependenciesTask::class) {
+ this.setDependencies(getRoot(), allInternalDependencies())
+ }
- val downloadDepsInternal by registering(DownloadAllDependenciesTask::class) {
- this.setDependencies(getRoot(), allInternalDependencies())
- }
-
- val downloadTestDepsInternal by registering(DownloadAllDependenciesTask::class) {
- this.setDependencies(getRoot(), allInternalTestDependencies())
- }
+ val downloadTestDepsInternal by
+ registering(DownloadAllDependenciesTask::class) {
+ this.setDependencies(getRoot(), allInternalTestDependencies())
+ }
}
diff --git a/d8_r8/shared/settings.gradle.kts b/d8_r8/shared/settings.gradle.kts
index 35918f8..b5b665f 100644
--- a/d8_r8/shared/settings.gradle.kts
+++ b/d8_r8/shared/settings.gradle.kts
@@ -4,21 +4,13 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../third_party/dependencies")
- }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../third_party/dependencies") } }
}
rootProject.name = "shared"
diff --git a/d8_r8/test/build.gradle.kts b/d8_r8/test/build.gradle.kts
index 4da185b..dcf0552 100644
--- a/d8_r8/test/build.gradle.kts
+++ b/d8_r8/test/build.gradle.kts
@@ -5,7 +5,6 @@
import java.nio.file.Paths
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
plugins {
`kotlin-dsl`
id("dependencies-plugin")
@@ -14,16 +13,12 @@
java {
sourceCompatibility = JvmCompatibility.sourceCompatibility
targetCompatibility = JvmCompatibility.targetCompatibility
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
-dependencies { }
+dependencies {}
val blastRadiusSourcesTask = projectTask("blastradius", "sourcesJar")
val keepAnnoCompileTask = projectTask("keepanno", "compileJava")
@@ -32,7 +27,8 @@
val assistantJarTask = projectTask("assistant", "jar")
val mainDepsJarTask = projectTask("main", "depsJar")
val swissArmyKnifeTask = projectTask("main", "swissArmyKnife")
-val processKeepRulesLibWithRelocatedDepsTask = projectTask("main", "processKeepRulesLibWithRelocatedDeps")
+val processKeepRulesLibWithRelocatedDepsTask =
+ projectTask("main", "processKeepRulesLibWithRelocatedDeps")
val r8WithRelocatedDepsTask = projectTask("main", "r8WithRelocatedDeps")
val mainSourcesTask = projectTask("main", "sourcesJar")
val resourceShrinkerSourcesTask = projectTask("resourceshrinker", "sourcesJar")
@@ -51,17 +47,9 @@
val depsJarOnlyAsmTask = projectTask("keepanno", "depsJarOnlyAsm")
tasks {
- withType<Exec> {
- doFirst {
- println("Executing command: ${commandLine.joinToString(" ")}")
- }
- }
+ withType<Exec> { doFirst { println("Executing command: ${commandLine.joinToString(" ")}") } }
- withType<KotlinCompile> {
- kotlinOptions {
- jvmTarget = "17"
- }
- }
+ withType<KotlinCompile> { kotlinOptions { jvmTarget = "17" } }
"clean" {
dependsOn(gradle.includedBuild("tests_bootstrap").task(":clean"))
@@ -73,55 +61,54 @@
dependsOn(gradle.includedBuild("tests_java_25").task(":clean"))
}
- val packageTests by registering(Jar::class) {
- dependsOn(java8TestJarTask)
- dependsOn(java9TestJarTask)
- dependsOn(java11TestJarTask)
- dependsOn(java17TestJarTask)
- dependsOn(java21TestJarTask)
- dependsOn(bootstrapTestJarTask)
- from(java8TestJarTask.outputs.files.map(::zipTree))
- from(java9TestJarTask.outputs.files.map(::zipTree))
- from(java11TestJarTask.outputs.files.map(::zipTree))
- from(java17TestJarTask.outputs.files.map(::zipTree))
- from(java21TestJarTask.outputs.files.map(::zipTree))
- from(bootstrapTestJarTask.outputs.files.map(::zipTree))
- exclude("META-INF/*.kotlin_module", "**/*.kotlin_metadata")
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- archiveFileName.set("r8tests.jar")
- }
+ val packageTests by
+ registering(Jar::class) {
+ dependsOn(java8TestJarTask)
+ dependsOn(java9TestJarTask)
+ dependsOn(java11TestJarTask)
+ dependsOn(java17TestJarTask)
+ dependsOn(java21TestJarTask)
+ dependsOn(bootstrapTestJarTask)
+ from(java8TestJarTask.outputs.files.map(::zipTree))
+ from(java9TestJarTask.outputs.files.map(::zipTree))
+ from(java11TestJarTask.outputs.files.map(::zipTree))
+ from(java17TestJarTask.outputs.files.map(::zipTree))
+ from(java21TestJarTask.outputs.files.map(::zipTree))
+ from(bootstrapTestJarTask.outputs.files.map(::zipTree))
+ exclude("META-INF/*.kotlin_module", "**/*.kotlin_metadata")
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ archiveFileName.set("r8tests.jar")
+ }
- val packageTestDeps by registering(Jar::class) {
- dependsOn(bootstrapTestsDepsJarTask, javaTestBaseDepsJar, keepAnnoAndroidXAnnotationsJar)
- from(bootstrapTestsDepsJarTask.outputs.getFiles().map(::zipTree))
- from(javaTestBaseDepsJar.outputs.getFiles().map(::zipTree))
- from(keepAnnoAndroidXAnnotationsJar.outputs.getFiles().map(::zipTree))
- exclude(
- "META-INF/*.kotlin_module",
- "**/*.kotlin_metadata",
- "org/jspecify/**",
- "org/jspecify")
- duplicatesStrategy = DuplicatesStrategy.EXCLUDE
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- archiveFileName.set("test_deps_all.jar")
- }
+ val packageTestDeps by
+ registering(Jar::class) {
+ dependsOn(bootstrapTestsDepsJarTask, javaTestBaseDepsJar, keepAnnoAndroidXAnnotationsJar)
+ from(bootstrapTestsDepsJarTask.outputs.getFiles().map(::zipTree))
+ from(javaTestBaseDepsJar.outputs.getFiles().map(::zipTree))
+ from(keepAnnoAndroidXAnnotationsJar.outputs.getFiles().map(::zipTree))
+ exclude("META-INF/*.kotlin_module", "**/*.kotlin_metadata", "org/jspecify/**", "org/jspecify")
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ archiveFileName.set("test_deps_all.jar")
+ }
- val packageTestBase by registering(Jar::class) {
- dependsOn(javaTestBaseJarTask)
- from(javaTestBaseJarTask.outputs.files.map(::zipTree))
- exclude("META-INF/*.kotlin_module", "**/*.kotlin_metadata")
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- archiveFileName.set("r8test_base.jar")
- }
+ val packageTestBase by
+ registering(Jar::class) {
+ dependsOn(javaTestBaseJarTask)
+ from(javaTestBaseJarTask.outputs.files.map(::zipTree))
+ exclude("META-INF/*.kotlin_module", "**/*.kotlin_metadata")
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ archiveFileName.set("r8test_base.jar")
+ }
- val packageTestBaseExcludeKeep by registering(Jar::class) {
- dependsOn(packageTestBase)
- from(zipTree(packageTestBase.getSingleOutputFile()))
- // TODO(b/328353718): we have com.android.tools.r8.Keep in both test_base and main
- exclude("com/android/tools/r8/Keep.class")
- archiveFileName.set("r8test_base_no_keep.jar")
- }
-
+ val packageTestBaseExcludeKeep by
+ registering(Jar::class) {
+ dependsOn(packageTestBase)
+ from(zipTree(packageTestBase.getSingleOutputFile()))
+ // TODO(b/328353718): we have com.android.tools.r8.Keep in both test_base and main
+ exclude("com/android/tools/r8/Keep.class")
+ archiveFileName.set("r8test_base_no_keep.jar")
+ }
fun Exec.executeRelocator(jarProvider: TaskProvider<*>, artifactName: String) {
dependsOn(r8WithRelocatedDepsTask, jarProvider)
@@ -130,15 +117,19 @@
val r8WithRelocatedDepsJar = r8WithRelocatedDepsTask.getSingleOutputFile()
val testJar = jarProvider.getSingleOutputFile()
inputs.files(r8WithRelocatedDepsJar, testJar)
- commandLine = baseCompilerCommandLine(
- r8WithRelocatedDepsJar,
- "relocator",
- listOf("--input",
- "$testJar",
- "--output",
- "$outputJar",
- "--map",
- "kotlin.metadata.**->com.android.tools.r8.jetbrains.kotlin.metadata"))
+ commandLine =
+ baseCompilerCommandLine(
+ r8WithRelocatedDepsJar,
+ "relocator",
+ listOf(
+ "--input",
+ "$testJar",
+ "--output",
+ "$outputJar",
+ "--map",
+ "kotlin.metadata.**->com.android.tools.r8.jetbrains.kotlin.metadata",
+ ),
+ )
}
// When testing R8 lib with relocated deps we must relocate kotlin.metadata in the tests, since
@@ -146,143 +137,169 @@
//
// This is not needed when testing R8 lib excluding deps since we simply include the deps on the
// classpath at runtime.
- val relocateTestsForR8LibWithRelocatedDeps by registering(Exec::class) {
- executeRelocator(packageTests, "r8tests-relocated.jar")
- }
+ val relocateTestsForR8LibWithRelocatedDeps by
+ registering(Exec::class) { executeRelocator(packageTests, "r8tests-relocated.jar") }
- val relocateTestBaseForR8LibWithRelocatedDeps by registering(Exec::class) {
- executeRelocator(packageTestBase, "r8testbase-relocated.jar")
- }
+ val relocateTestBaseForR8LibWithRelocatedDeps by
+ registering(Exec::class) { executeRelocator(packageTestBase, "r8testbase-relocated.jar") }
fun Exec.generateKeepRulesForR8Lib(
- targetJarProvider: Task, testJarProviders: List<TaskProvider<*>>, artifactName: String) {
- dependsOn(
- mainDepsJarTask,
- packageTestDeps,
- r8WithRelocatedDepsTask,
- targetJarProvider)
+ targetJarProvider: Task,
+ testJarProviders: List<TaskProvider<*>>,
+ artifactName: String,
+ ) {
+ dependsOn(mainDepsJarTask, packageTestDeps, r8WithRelocatedDepsTask, targetJarProvider)
testJarProviders.forEach(::dependsOn)
val mainDepsJar = mainDepsJarTask.getSingleOutputFile()
val r8WithRelocatedDepsJar = r8WithRelocatedDepsTask.getSingleOutputFile()
val targetJar = targetJarProvider.getSingleOutputFile()
val testDepsJar = packageTestDeps.getSingleOutputFile()
inputs.files(mainDepsJar, r8WithRelocatedDepsJar, targetJar, testDepsJar)
- inputs.files(testJarProviders.map{it.getSingleOutputFile()})
+ inputs.files(testJarProviders.map { it.getSingleOutputFile() })
val output = file(Paths.get("build", "libs", artifactName))
outputs.file(output)
- val argList = mutableListOf("--keep-rules",
- "--allowobfuscation",
- "--lib",
- "${getJavaHome(Jdk.JDK_25)}",
- "--lib",
- "$mainDepsJar",
- "--lib",
- "$testDepsJar",
- "--target",
- "$targetJar",
- "--output",
- "$output")
- testJarProviders.forEach{
+ val argList =
+ mutableListOf(
+ "--keep-rules",
+ "--allowobfuscation",
+ "--lib",
+ "${getJavaHome(Jdk.JDK_25)}",
+ "--lib",
+ "$mainDepsJar",
+ "--lib",
+ "$testDepsJar",
+ "--target",
+ "$targetJar",
+ "--output",
+ "$output",
+ )
+ testJarProviders.forEach {
argList.add("--source")
argList.add("${it.getSingleOutputFile()}")
}
- commandLine = baseCompilerCommandLine(
- listOf("-Dcom.android.tools.r8.tracereferences.obfuscateAllEnums"),
- r8WithRelocatedDepsJar,
- "tracereferences",
- argList
- )
+ commandLine =
+ baseCompilerCommandLine(
+ listOf("-Dcom.android.tools.r8.tracereferences.obfuscateAllEnums"),
+ r8WithRelocatedDepsJar,
+ "tracereferences",
+ argList,
+ )
}
- val generateKeepRulesForR8LibWithRelocatedDeps by registering(Exec::class) {
- generateKeepRulesForR8Lib(
- r8WithRelocatedDepsTask,
- listOf(relocateTestsForR8LibWithRelocatedDeps, relocateTestBaseForR8LibWithRelocatedDeps),
- "generated-keep-rules-r8lib.txt")
- }
+ val generateKeepRulesForR8LibWithRelocatedDeps by
+ registering(Exec::class) {
+ generateKeepRulesForR8Lib(
+ r8WithRelocatedDepsTask,
+ listOf(relocateTestsForR8LibWithRelocatedDeps, relocateTestBaseForR8LibWithRelocatedDeps),
+ "generated-keep-rules-r8lib.txt",
+ )
+ }
- val generateKeepRulesForR8LibNoDeps by registering(Exec::class) {
- generateKeepRulesForR8Lib(
- swissArmyKnifeTask,
- listOf(packageTests, packageTestBase),
- "generated-keep-rules-r8lib-exclude-deps.txt")
- }
+ val generateKeepRulesForR8LibNoDeps by
+ registering(Exec::class) {
+ generateKeepRulesForR8Lib(
+ swissArmyKnifeTask,
+ listOf(packageTests, packageTestBase),
+ "generated-keep-rules-r8lib-exclude-deps.txt",
+ )
+ }
fun Exec.assembleR8Lib(
inputJarProvider: Task,
generatedKeepRulesProvider: TaskProvider<Exec>,
classpath: List<File>,
- artifactName: String) {
- dependsOn(generatedKeepRulesProvider, inputJarProvider, r8WithRelocatedDepsTask,
- assistantJarTask)
+ artifactName: String,
+ ) {
+ dependsOn(
+ generatedKeepRulesProvider,
+ inputJarProvider,
+ r8WithRelocatedDepsTask,
+ assistantJarTask,
+ )
val inputJar = inputJarProvider.getSingleOutputFile()
val r8WithRelocatedDepsJar = r8WithRelocatedDepsTask.getSingleOutputFile()
val assistantJar = assistantJarTask.getSingleOutputFile()
- val keepRuleFiles = listOf(
- getRoot().resolveAll("src", "main", "keep.txt"),
- getRoot().resolveAll("src", "main", "discard.txt"),
- generatedKeepRulesProvider.getSingleOutputFile(),
- // TODO(b/294351878): Remove once enum issue is fixed
- getRoot().resolveAll("src", "main", "keep_r8resourceshrinker.txt"))
- inputs.files(listOf(r8WithRelocatedDepsJar, inputJar,
- getRoot().resolveAll("tools", "create_r8lib.py"))
- .union(keepRuleFiles).union(classpath))
+ val keepRuleFiles =
+ listOf(
+ getRoot().resolveAll("src", "main", "keep.txt"),
+ getRoot().resolveAll("src", "main", "discard.txt"),
+ generatedKeepRulesProvider.getSingleOutputFile(),
+ // TODO(b/294351878): Remove once enum issue is fixed
+ getRoot().resolveAll("src", "main", "keep_r8resourceshrinker.txt"),
+ )
+ inputs.files(
+ listOf(r8WithRelocatedDepsJar, inputJar, getRoot().resolveAll("tools", "create_r8lib.py"))
+ .union(keepRuleFiles)
+ .union(classpath)
+ )
val outputJar = getRoot().resolveAll("build", "libs", artifactName)
outputs.file(outputJar)
- commandLine = createR8LibCommandLine(
- r8WithRelocatedDepsJar,
- inputJar,
- outputJar,
- keepRuleFiles,
- excludingDepsVariant = classpath.isNotEmpty(),
- debugVariant = false,
- classpath = classpath,
- replaceFromJar = assistantJar)
+ commandLine =
+ createR8LibCommandLine(
+ r8WithRelocatedDepsJar,
+ inputJar,
+ outputJar,
+ keepRuleFiles,
+ excludingDepsVariant = classpath.isNotEmpty(),
+ debugVariant = false,
+ classpath = classpath,
+ replaceFromJar = assistantJar,
+ )
}
- val assembleR8LibNoDeps by registering(Exec::class) {
- dependsOn(mainDepsJarTask)
- val mainDepsJar = mainDepsJarTask.getSingleOutputFile()
- assembleR8Lib(
- swissArmyKnifeTask,
- generateKeepRulesForR8LibNoDeps,
- listOf(mainDepsJar),
- "r8lib-exclude-deps.jar")
- }
+ val assembleR8LibNoDeps by
+ registering(Exec::class) {
+ dependsOn(mainDepsJarTask)
+ val mainDepsJar = mainDepsJarTask.getSingleOutputFile()
+ assembleR8Lib(
+ swissArmyKnifeTask,
+ generateKeepRulesForR8LibNoDeps,
+ listOf(mainDepsJar),
+ "r8lib-exclude-deps.jar",
+ )
+ }
- val assembleR8LibWithRelocatedDeps by registering(Exec::class) {
- assembleR8Lib(
- r8WithRelocatedDepsTask,
- generateKeepRulesForR8LibWithRelocatedDeps,
- listOf(),
- "r8lib.jar")
- }
+ val assembleR8LibWithRelocatedDeps by
+ registering(Exec::class) {
+ assembleR8Lib(
+ r8WithRelocatedDepsTask,
+ generateKeepRulesForR8LibWithRelocatedDeps,
+ listOf(),
+ "r8lib.jar",
+ )
+ }
- val keepAnnoToolsLib by registering(Exec::class) {
- dependsOn(r8WithRelocatedDepsTask)
- dependsOn(keepAnnoToolsWithRelocatedDepsTask)
- dependsOn(depsJarOnlyAsmTask)
- val inputJar = keepAnnoToolsWithRelocatedDepsTask.getSingleOutputFile()
- val r8WithRelocatedDepsJar = r8WithRelocatedDepsTask.getSingleOutputFile()
- val keepRuleFiles = listOf(getRoot().resolveAll("src", "keepanno", "keep.txt"))
- inputs.files(listOf(r8WithRelocatedDepsJar, inputJar,
- getRoot().resolveAll("tools", "create_r8lib.py"))
- .union(keepRuleFiles))
- val outputJar = getRoot().resolveAll("build", "libs", "keepanno-toolslib.jar")
- outputs.file(outputJar)
- commandLine = createR8LibCommandLine(
- r8WithRelocatedDepsJar,
- inputJar,
- outputJar,
- keepRuleFiles,
- excludingDepsVariant = false,
- debugVariant = false,
- classpath = listOf(depsJarOnlyAsmTask.getSingleOutputFile()),
- versionJar = r8WithRelocatedDepsJar)
- }
+ val keepAnnoToolsLib by
+ registering(Exec::class) {
+ dependsOn(r8WithRelocatedDepsTask)
+ dependsOn(keepAnnoToolsWithRelocatedDepsTask)
+ dependsOn(depsJarOnlyAsmTask)
+ val inputJar = keepAnnoToolsWithRelocatedDepsTask.getSingleOutputFile()
+ val r8WithRelocatedDepsJar = r8WithRelocatedDepsTask.getSingleOutputFile()
+ val keepRuleFiles = listOf(getRoot().resolveAll("src", "keepanno", "keep.txt"))
+ inputs.files(
+ listOf(r8WithRelocatedDepsJar, inputJar, getRoot().resolveAll("tools", "create_r8lib.py"))
+ .union(keepRuleFiles)
+ )
+ val outputJar = getRoot().resolveAll("build", "libs", "keepanno-toolslib.jar")
+ outputs.file(outputJar)
+ commandLine =
+ createR8LibCommandLine(
+ r8WithRelocatedDepsJar,
+ inputJar,
+ outputJar,
+ keepRuleFiles,
+ excludingDepsVariant = false,
+ debugVariant = false,
+ classpath = listOf(depsJarOnlyAsmTask.getSingleOutputFile()),
+ versionJar = r8WithRelocatedDepsJar,
+ )
+ }
fun Task.generateTestKeepRulesForR8Lib(
- r8LibJarProvider: TaskProvider<Exec>, artifactName: String) {
+ r8LibJarProvider: TaskProvider<Exec>,
+ artifactName: String,
+ ) {
dependsOn(r8LibJarProvider)
val r8LibJar = r8LibJarProvider.getSingleOutputFile()
inputs.files(r8LibJar)
@@ -291,12 +308,13 @@
doLast {
// TODO(b/299065371): We should be able to take in the partition map output.
output.writeText(
- """-keep class ** { *; }
+ """-keep class ** { *; }
-dontshrink
-dontoptimize
-keepattributes *
-applymapping $r8LibJar.map
-""")
+"""
+ )
}
}
@@ -309,19 +327,21 @@
}
fun Exec.rewriteTestsForR8Lib(
- keepRulesFileProvider: TaskProvider<Task>,
- r8JarProvider: Task,
- testJarProvider: TaskProvider<*>,
- artifactName: String,
- addTestBaseClasspath: Boolean) {
+ keepRulesFileProvider: TaskProvider<Task>,
+ r8JarProvider: Task,
+ testJarProvider: TaskProvider<*>,
+ artifactName: String,
+ addTestBaseClasspath: Boolean,
+ ) {
dependsOn(
- keepRulesFileProvider,
- packageTestDeps,
- relocateTestsForR8LibWithRelocatedDeps,
- r8JarProvider,
- r8WithRelocatedDepsTask,
- testJarProvider,
- packageTestBaseExcludeKeep)
+ keepRulesFileProvider,
+ packageTestDeps,
+ relocateTestsForR8LibWithRelocatedDeps,
+ r8JarProvider,
+ r8WithRelocatedDepsTask,
+ testJarProvider,
+ packageTestBaseExcludeKeep,
+ )
val keepRulesFile = keepRulesFileProvider.getSingleOutputFile()
val r8Jar = r8JarProvider.getSingleOutputFile()
val r8WithRelocatedDepsJar = r8WithRelocatedDepsTask.getSingleOutputFile()
@@ -331,80 +351,95 @@
inputs.files(keepRulesFile, r8Jar, r8WithRelocatedDepsJar, testDepsJar, testJar)
val outputJar = getRoot().resolveAll("build", "libs", artifactName)
outputs.file(outputJar)
- val args = mutableListOf(
- "--classfile",
- "--debug",
- "--lib",
- "${getJavaHome(Jdk.JDK_21)}",
- "--classpath",
- "$r8Jar",
- "--classpath",
- "$testDepsJar",
- "--output",
- "$outputJar",
- "--pg-conf",
- "$keepRulesFile",
- "$testJar")
+ val args =
+ mutableListOf(
+ "--classfile",
+ "--debug",
+ "--lib",
+ "${getJavaHome(Jdk.JDK_21)}",
+ "--classpath",
+ "$r8Jar",
+ "--classpath",
+ "$testDepsJar",
+ "--output",
+ "$outputJar",
+ "--pg-conf",
+ "$keepRulesFile",
+ "$testJar",
+ )
if (addTestBaseClasspath) {
args.add("--classpath")
args.add("$testBaseJar")
}
- commandLine = baseCompilerCommandLine(
- listOf("-Dcom.android.tools.r8.tracereferences.obfuscateAllEnums"),
- r8WithRelocatedDepsJar,
- "r8",
- args)
+ commandLine =
+ baseCompilerCommandLine(
+ listOf("-Dcom.android.tools.r8.tracereferences.obfuscateAllEnums"),
+ r8WithRelocatedDepsJar,
+ "r8",
+ args,
+ )
}
- val rewriteTestsForR8LibWithRelocatedDeps by registering(Exec::class) {
- rewriteTestsForR8Lib(
- generateTestKeepRulesR8LibWithRelocatedDeps,
- r8WithRelocatedDepsTask,
- relocateTestsForR8LibWithRelocatedDeps,
- "r8libtestdeps-cf.jar",
- true)
- }
+ val rewriteTestsForR8LibWithRelocatedDeps by
+ registering(Exec::class) {
+ rewriteTestsForR8Lib(
+ generateTestKeepRulesR8LibWithRelocatedDeps,
+ r8WithRelocatedDepsTask,
+ relocateTestsForR8LibWithRelocatedDeps,
+ "r8libtestdeps-cf.jar",
+ true,
+ )
+ }
- val rewriteTestBaseForR8LibWithRelocatedDeps by registering(Exec::class) {
- rewriteTestsForR8Lib(
- generateTestKeepRulesR8LibWithRelocatedDeps,
- r8WithRelocatedDepsTask,
- relocateTestBaseForR8LibWithRelocatedDeps,
- "r8libtestbase-cf.jar",
- false)
- }
+ val rewriteTestBaseForR8LibWithRelocatedDeps by
+ registering(Exec::class) {
+ rewriteTestsForR8Lib(
+ generateTestKeepRulesR8LibWithRelocatedDeps,
+ r8WithRelocatedDepsTask,
+ relocateTestBaseForR8LibWithRelocatedDeps,
+ "r8libtestbase-cf.jar",
+ false,
+ )
+ }
- val rewriteTestsForR8LibNoDeps by registering(Exec::class) {
- rewriteTestsForR8Lib(
- generateTestKeepRulesR8LibNoDeps,
- swissArmyKnifeTask,
- packageTests,
- "r8lib-exclude-deps-testdeps-cf.jar",
- true)
- }
+ val rewriteTestsForR8LibNoDeps by
+ registering(Exec::class) {
+ rewriteTestsForR8Lib(
+ generateTestKeepRulesR8LibNoDeps,
+ swissArmyKnifeTask,
+ packageTests,
+ "r8lib-exclude-deps-testdeps-cf.jar",
+ true,
+ )
+ }
- val cleanUnzipTests by registering(Delete::class) {
- dependsOn(packageTests)
- val outputDir = file("${buildDir}/unpacked/test")
- setDelete(outputDir)
- }
+ val cleanUnzipTests by
+ registering(Delete::class) {
+ dependsOn(packageTests)
+ val outputDir = file("${buildDir}/unpacked/test")
+ setDelete(outputDir)
+ }
- val unzipTests by registering(Copy::class) {
- dependsOn(cleanUnzipTests, packageTests)
- val outputDir = file("${buildDir}/unpacked/test")
- from(zipTree(packageTests.getSingleOutputFile()))
- into(outputDir)
- }
+ val unzipTests by
+ registering(Copy::class) {
+ dependsOn(cleanUnzipTests, packageTests)
+ val outputDir = file("${buildDir}/unpacked/test")
+ from(zipTree(packageTests.getSingleOutputFile()))
+ into(outputDir)
+ }
- val unzipTestBase by registering(Copy::class) {
- dependsOn(cleanUnzipTests, packageTestBase)
- val outputDir = file("${buildDir}/unpacked/testbase")
- from(zipTree(packageTestBase.getSingleOutputFile()))
- into(outputDir)
- }
+ val unzipTestBase by
+ registering(Copy::class) {
+ dependsOn(cleanUnzipTests, packageTestBase)
+ val outputDir = file("${buildDir}/unpacked/testbase")
+ from(zipTree(packageTestBase.getSingleOutputFile()))
+ into(outputDir)
+ }
fun Copy.unzipRewrittenTestsForR8Lib(
- rewrittenTestJarProvider: TaskProvider<Exec>, outDirName: String) {
+ rewrittenTestJarProvider: TaskProvider<Exec>,
+ outDirName: String,
+ ) {
dependsOn(rewrittenTestJarProvider)
val outputDir = file("$buildDir/unpacked/$outDirName")
val rewrittenTestJar = rewrittenTestJarProvider.getSingleOutputFile()
@@ -412,41 +447,45 @@
into(outputDir)
}
- val cleanUnzipRewrittenTestsForR8LibWithRelocatedDeps by registering(Delete::class) {
- val outputDir = file("${buildDir}/unpacked/rewrittentests-r8lib")
- setDelete(outputDir)
- }
+ val cleanUnzipRewrittenTestsForR8LibWithRelocatedDeps by
+ registering(Delete::class) {
+ val outputDir = file("${buildDir}/unpacked/rewrittentests-r8lib")
+ setDelete(outputDir)
+ }
- val unzipRewrittenTestsForR8LibWithRelocatedDeps by registering(Copy::class) {
- dependsOn(cleanUnzipRewrittenTestsForR8LibWithRelocatedDeps)
- unzipRewrittenTestsForR8Lib(rewriteTestsForR8LibWithRelocatedDeps, "rewrittentests-r8lib")
- }
+ val unzipRewrittenTestsForR8LibWithRelocatedDeps by
+ registering(Copy::class) {
+ dependsOn(cleanUnzipRewrittenTestsForR8LibWithRelocatedDeps)
+ unzipRewrittenTestsForR8Lib(rewriteTestsForR8LibWithRelocatedDeps, "rewrittentests-r8lib")
+ }
- val cleanUnzipRewrittenTestsForR8LibNoDeps by registering(Delete::class) {
- val outputDir = file("${buildDir}/unpacked/rewrittentests-r8lib-exclude-deps")
- setDelete(outputDir)
- }
+ val cleanUnzipRewrittenTestsForR8LibNoDeps by
+ registering(Delete::class) {
+ val outputDir = file("${buildDir}/unpacked/rewrittentests-r8lib-exclude-deps")
+ setDelete(outputDir)
+ }
- val unzipRewrittenTestsForR8LibNoDeps by registering(Copy::class) {
- dependsOn(cleanUnzipRewrittenTestsForR8LibNoDeps)
- unzipRewrittenTestsForR8Lib(
- rewriteTestsForR8LibNoDeps, "rewrittentests-r8lib-exclude-deps")
- }
+ val unzipRewrittenTestsForR8LibNoDeps by
+ registering(Copy::class) {
+ dependsOn(cleanUnzipRewrittenTestsForR8LibNoDeps)
+ unzipRewrittenTestsForR8Lib(rewriteTestsForR8LibNoDeps, "rewrittentests-r8lib-exclude-deps")
+ }
fun Test.testR8Lib(r8Lib: TaskProvider<Exec>, unzipRewrittenTests: TaskProvider<Copy>) {
println("NOTE: Number of processors " + Runtime.getRuntime().availableProcessors())
println("NOTE: Max parallel forks " + maxParallelForks)
dependsOn(
- packageTestDeps,
- processKeepRulesLibWithRelocatedDepsTask,
- r8Lib,
- r8WithRelocatedDepsTask,
- assembleR8LibNoDeps,
- testsJava8SourceSetDependenciesTask,
- rewriteTestBaseForR8LibWithRelocatedDeps,
- unzipRewrittenTests,
- unzipTests,
- unzipTestBase)
+ packageTestDeps,
+ processKeepRulesLibWithRelocatedDepsTask,
+ r8Lib,
+ r8WithRelocatedDepsTask,
+ assembleR8LibNoDeps,
+ testsJava8SourceSetDependenciesTask,
+ rewriteTestBaseForR8LibWithRelocatedDeps,
+ unzipRewrittenTests,
+ unzipTests,
+ unzipTestBase,
+ )
val processKeepRulesLibJar = processKeepRulesLibWithRelocatedDepsTask.getSingleOutputFile()
val r8LibJar = r8Lib.getSingleOutputFile()
val r8LibMappingFile = file(r8LibJar.toString() + ".map")
@@ -455,11 +494,13 @@
// R8lib should be used instead of the main output and all the tests in r8 should be mapped and
// exists in r8LibTestPath.
- classpath = files(
- packageTestDeps.get().getOutputs().getFiles(),
- r8LibJar,
- unzipRewrittenTests.get().getOutputs().getFiles(),
- rewriteTestBaseForR8LibWithRelocatedDeps.getSingleOutputFile())
+ classpath =
+ files(
+ packageTestDeps.get().getOutputs().getFiles(),
+ r8LibJar,
+ unzipRewrittenTests.get().getOutputs().getFiles(),
+ rewriteTestBaseForR8LibWithRelocatedDeps.getSingleOutputFile(),
+ )
testClassesDirs = unzipRewrittenTests.get().getOutputs().getFiles()
systemProperty("TEST_DATA_LOCATION", unzipTests.getSingleOutputFile())
systemProperty("TESTBASE_DATA_LOCATION", unzipTestBase.getSingleOutputFile())
@@ -469,7 +510,9 @@
extractClassesPaths(
"keepanno" + File.separator,
keepAnnoCompileTask.outputs.files.asPath,
- keepAnnoCompileKotlinTask.outputs.files.asPath))
+ keepAnnoCompileKotlinTask.outputs.files.asPath,
+ ),
+ )
systemProperty("BUILD_PROP_PROCESS_KEEP_RULES_RUNTIME_PATH", processKeepRulesLibJar)
systemProperty("BUILD_PROP_R8_RUNTIME_PATH", r8LibJar)
systemProperty("R8_DEPS", mainDepsJarTask.getSingleOutputFile())
@@ -482,27 +525,28 @@
reports.html.outputLocation.set(getRoot().resolveAll("build", "reports", "tests", "test"))
}
- val testR8LibWithRelocatedDeps by registering(Test::class) {
- testR8Lib(assembleR8LibWithRelocatedDeps, unzipRewrittenTestsForR8LibWithRelocatedDeps)
- }
+ val testR8LibWithRelocatedDeps by
+ registering(Test::class) {
+ testR8Lib(assembleR8LibWithRelocatedDeps, unzipRewrittenTestsForR8LibWithRelocatedDeps)
+ }
- val testR8LibNoDeps by registering(Test::class) {
- testR8Lib(assembleR8LibNoDeps, unzipRewrittenTestsForR8LibNoDeps)
- }
+ val testR8LibNoDeps by
+ registering(Test::class) { testR8Lib(assembleR8LibNoDeps, unzipRewrittenTestsForR8LibNoDeps) }
- val packageSources by registering(Jar::class) {
- dependsOn(mainSourcesTask)
- dependsOn(resourceShrinkerSourcesTask)
- dependsOn(keepAnnoSourcesTask)
- dependsOn(blastRadiusSourcesTask)
- from(mainSourcesTask.outputs.files.map(::zipTree))
- from(resourceShrinkerSourcesTask.outputs.files.map(::zipTree))
- from(keepAnnoSourcesTask.outputs.files.map(::zipTree))
- from(blastRadiusSourcesTask.outputs.files.map(::zipTree))
- archiveClassifier.set("sources")
- archiveFileName.set("r8-src.jar")
- destinationDirectory.set(getRoot().resolveAll("build", "libs"))
- }
+ val packageSources by
+ registering(Jar::class) {
+ dependsOn(mainSourcesTask)
+ dependsOn(resourceShrinkerSourcesTask)
+ dependsOn(keepAnnoSourcesTask)
+ dependsOn(blastRadiusSourcesTask)
+ from(mainSourcesTask.outputs.files.map(::zipTree))
+ from(resourceShrinkerSourcesTask.outputs.files.map(::zipTree))
+ from(keepAnnoSourcesTask.outputs.files.map(::zipTree))
+ from(blastRadiusSourcesTask.outputs.files.map(::zipTree))
+ archiveClassifier.set("sources")
+ archiveFileName.set("r8-src.jar")
+ destinationDirectory.set(getRoot().resolveAll("build", "libs"))
+ }
test {
dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
diff --git a/d8_r8/test/settings.gradle.kts b/d8_r8/test/settings.gradle.kts
index 01a33c6..2c8a641 100644
--- a/d8_r8/test/settings.gradle.kts
+++ b/d8_r8/test/settings.gradle.kts
@@ -4,37 +4,43 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../third_party/dependencies")
- }
+ maven { url = uri("file:../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../third_party/dependencies") } }
}
rootProject.name = "r8-tests"
val root = rootProject.projectDir.parentFile
+
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("assistant"))
+
includeBuild(root.resolve("blastradius"))
+
includeBuild(root.resolve("keepanno"))
+
includeBuild(root.resolve("main"))
+
includeBuild(root.resolve("resourceshrinker"))
+
includeBuild(root.resolve("test_modules").resolve("testbase"))
+
includeBuild(root.resolve("test_modules").resolve("tests_bootstrap"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_8"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_9"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_11"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_17"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_21"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_25"))
diff --git a/d8_r8/test_modules/testbase/build.gradle.kts b/d8_r8/test_modules/testbase/build.gradle.kts
index d50f44b..5476422 100644
--- a/d8_r8/test_modules/testbase/build.gradle.kts
+++ b/d8_r8/test_modules/testbase/build.gradle.kts
@@ -14,24 +14,16 @@
val root = getRoot()
java {
- sourceSets.main.configure {
- java {
- srcDir(root.resolveAll("src", "test", "testbase", "java"))
- }
- }
+ sourceSets.main.configure { java { srcDir(root.resolveAll("src", "test", "testbase", "java")) } }
// We are using a new JDK to compile to an older language version, which is not directly
// compatible with java toolchains.
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
// If we depend on keepanno by referencing the project source outputs we get an error regarding
// incompatible java class file version. By depending on the jar we circumvent that.
@@ -65,25 +57,20 @@
implementation(Deps.kotlinStdLib)
implementation(Deps.kotlinReflect)
implementation(Deps.kotlinMetadata)
- implementation(resolve(ThirdPartyDeps.ddmLib,"ddmlib.jar"))
- implementation(resolve(ThirdPartyDeps.jasmin,"jasmin-2.4.jar"))
- implementation(resolve(ThirdPartyDeps.jdwpTests,"apache-harmony-jdwp-tests-host.jar"))
+ implementation(resolve(ThirdPartyDeps.ddmLib, "ddmlib.jar"))
+ implementation(resolve(ThirdPartyDeps.jasmin, "jasmin-2.4.jar"))
+ implementation(resolve(ThirdPartyDeps.jdwpTests, "apache-harmony-jdwp-tests-host.jar"))
implementation(Deps.fastUtil)
implementation(Deps.smali)
implementation(Deps.smaliUtil)
}
-
-fun testDependencies() : FileCollection {
- return sourceSets
- .test
- .get()
- .compileClasspath
- .filter {
- "$it".contains("third_party")
- && !"$it".contains("errorprone")
- && !"$it".contains("third_party/gradle")
- }
+fun testDependencies(): FileCollection {
+ return sourceSets.test.get().compileClasspath.filter {
+ "$it".contains("third_party") &&
+ !"$it".contains("errorprone") &&
+ !"$it".contains("third_party/gradle")
+ }
}
tasks {
@@ -104,30 +91,31 @@
}
}
- withType<KotlinCompile> {
- enabled = false
- }
+ withType<KotlinCompile> { enabled = false }
- val testJar by registering(Jar::class) {
- from(sourceSets.main.get().output)
- // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets. Renaming
- // this from the default name (testbase.jar) will allow IntelliJ to find the resources in
- // the jar and not show red underlines. However, navigation to base classes will not work.
- archiveFileName.set("not_named_testbase.jar")
- }
+ val testJar by
+ registering(Jar::class) {
+ from(sourceSets.main.get().output)
+ // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets.
+ // Renaming
+ // this from the default name (testbase.jar) will allow IntelliJ to find the resources in
+ // the jar and not show red underlines. However, navigation to base classes will not work.
+ archiveFileName.set("not_named_testbase.jar")
+ }
- val depsJar by registering(Jar::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- dependsOn(gradle.includedBuild("shared").task(":downloadTestDeps"))
- dependsOn(gradle.includedBuild("keepanno").task(":jar"))
- dependsOn(gradle.includedBuild("resourceshrinker").task(":jar"))
- dependsOn(gradle.includedBuild("resourceshrinker").task(":depsJar"))
- from(testDependencies().map(::zipTree))
- from(resourceShrinkerDepsJarTask.outputs.getFiles().map(::zipTree))
- from(keepAnnoJarTask.outputs.getFiles().map(::zipTree))
- exclude("com/android/tools/r8/keepanno/annotations/**")
- exclude("androidx/annotation/keep/**")
- duplicatesStrategy = DuplicatesStrategy.EXCLUDE
- archiveFileName.set("deps.jar")
- }
+ val depsJar by
+ registering(Jar::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ dependsOn(gradle.includedBuild("shared").task(":downloadTestDeps"))
+ dependsOn(gradle.includedBuild("keepanno").task(":jar"))
+ dependsOn(gradle.includedBuild("resourceshrinker").task(":jar"))
+ dependsOn(gradle.includedBuild("resourceshrinker").task(":depsJar"))
+ from(testDependencies().map(::zipTree))
+ from(resourceShrinkerDepsJarTask.outputs.getFiles().map(::zipTree))
+ from(keepAnnoJarTask.outputs.getFiles().map(::zipTree))
+ exclude("com/android/tools/r8/keepanno/annotations/**")
+ exclude("androidx/annotation/keep/**")
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ archiveFileName.set("deps.jar")
+ }
}
diff --git a/d8_r8/test_modules/testbase/settings.gradle.kts b/d8_r8/test_modules/testbase/settings.gradle.kts
index 97fe72b..f09f790 100644
--- a/d8_r8/test_modules/testbase/settings.gradle.kts
+++ b/d8_r8/test_modules/testbase/settings.gradle.kts
@@ -4,28 +4,23 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
+ maven { url = uri("file:../../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../../third_party/dependencies") } }
}
rootProject.name = "testbase"
val root = rootProject.projectDir.parentFile.parentFile
+
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("keepanno"))
+
includeBuild(root.resolve("resourceshrinker"))
// We need to include src/main as a composite-build otherwise our test-modules
diff --git a/d8_r8/test_modules/tests_bootstrap/build.gradle.kts b/d8_r8/test_modules/tests_bootstrap/build.gradle.kts
index 182f888..5eab4f4 100644
--- a/d8_r8/test_modules/tests_bootstrap/build.gradle.kts
+++ b/d8_r8/test_modules/tests_bootstrap/build.gradle.kts
@@ -14,23 +14,15 @@
val root = getRoot()
java {
- sourceSets.test.configure {
- java {
- srcDir(root.resolveAll("src", "test", "bootstrap"))
- }
- }
+ sourceSets.test.configure { java { srcDir(root.resolveAll("src", "test", "bootstrap")) } }
// We are using a new JDK to compile to an older language version, which is not directly
// compatible with java toolchains.
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
val testbaseDepsJarTask = projectTask("testbase", "depsJar")
@@ -53,60 +45,58 @@
implementation(testbaseJavaCompileTask.outputs.files)
}
-fun testDependencies() : FileCollection {
- return sourceSets
- .test
- .get()
- .compileClasspath
- .filter {
- "$it".contains("third_party")
- && !"$it".contains("errorprone")
- && !"$it".contains("third_party/gradle")
- }
+fun testDependencies(): FileCollection {
+ return sourceSets.test.get().compileClasspath.filter {
+ "$it".contains("third_party") &&
+ !"$it".contains("errorprone") &&
+ !"$it".contains("third_party/gradle")
+ }
}
tasks {
- withType<JavaCompile> {
- dependsOn(gradle.includedBuild("main").task(":jar"))
- }
+ withType<JavaCompile> { dependsOn(gradle.includedBuild("main").task(":jar")) }
- withType<KotlinCompile> {
- kotlinOptions {
- enabled = false
- }
- }
+ withType<KotlinCompile> { kotlinOptions { enabled = false } }
withType<Test> {
TestingState.setUpTestingState(this)
dependsOn(mainR8RelocatedTask)
- systemProperty("TEST_DATA_LOCATION",
- layout.buildDirectory.dir("classes/java/test").get().toString())
- systemProperty("TESTBASE_DATA_LOCATION",
- testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0])
+ systemProperty(
+ "TEST_DATA_LOCATION",
+ layout.buildDirectory.dir("classes/java/test").get().toString(),
+ )
+ systemProperty(
+ "TESTBASE_DATA_LOCATION",
+ testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0],
+ )
systemProperty(
"BUILD_PROP_KEEPANNO_RUNTIME_PATH",
extractClassesPaths(
"keepanno" + File.separator,
keepAnnoCompileTask.outputs.files.asPath,
- keepAnnoCompileKotlinTask.outputs.files.asPath))
+ keepAnnoCompileKotlinTask.outputs.files.asPath,
+ ),
+ )
systemProperty("R8_WITH_RELOCATED_DEPS", mainR8RelocatedTask.outputs.files.singleFile)
systemProperty("BUILD_PROP_R8_RUNTIME_PATH", mainR8RelocatedTask.outputs.files.singleFile)
}
- val testJar by registering(Jar::class) {
- from(sourceSets.test.get().output)
- // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets.
- archiveFileName.set("not_named_tests_bootstrap.jar")
- }
-
- val depsJar by registering(Jar::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- dependsOn(gradle.includedBuild("keepanno").task(":jar"))
- if (!project.hasProperty("no_internal")) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDepsInternal"))
+ val testJar by
+ registering(Jar::class) {
+ from(sourceSets.test.get().output)
+ // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets.
+ archiveFileName.set("not_named_tests_bootstrap.jar")
}
- from(testDependencies().map(::zipTree))
- duplicatesStrategy = DuplicatesStrategy.EXCLUDE
- archiveFileName.set("deps.jar")
- }
+
+ val depsJar by
+ registering(Jar::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ dependsOn(gradle.includedBuild("keepanno").task(":jar"))
+ if (!project.hasProperty("no_internal")) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDepsInternal"))
+ }
+ from(testDependencies().map(::zipTree))
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ archiveFileName.set("deps.jar")
+ }
}
diff --git a/d8_r8/test_modules/tests_bootstrap/settings.gradle.kts b/d8_r8/test_modules/tests_bootstrap/settings.gradle.kts
index 5f5d322..afae5eb 100644
--- a/d8_r8/test_modules/tests_bootstrap/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_bootstrap/settings.gradle.kts
@@ -4,21 +4,13 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
+ maven { url = uri("file:../../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../../third_party/dependencies") } }
}
rootProject.name = "tests_bootstrap"
@@ -28,8 +20,13 @@
// We need to include src/main as a composite-build otherwise our test-modules
// will compete with the test to compile the source files.
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("main"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_8"))
+
includeBuild(root.resolve("keepanno"))
+
includeBuild(root.resolve("resourceshrinker"))
+
includeBuild(root.resolve("test_modules").resolve("testbase"))
diff --git a/d8_r8/test_modules/tests_java_11/build.gradle.kts b/d8_r8/test_modules/tests_java_11/build.gradle.kts
index 68ab593..20ebe51 100644
--- a/d8_r8/test_modules/tests_java_11/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_11/build.gradle.kts
@@ -13,16 +13,12 @@
val root = getRoot()
java {
- sourceSets.test.configure {
- java.srcDir(root.resolveAll("src", "test", "java11"))
- }
+ sourceSets.test.configure { java.srcDir(root.resolveAll("src", "test", "java11")) }
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
val testbaseDepsJarTask = projectTask("testbase", "depsJar")
@@ -47,21 +43,27 @@
withType<Test> {
notCompatibleWithConfigurationCache(
- "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache")
+ "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache"
+ )
TestingState.setUpTestingState(this)
javaLauncher = getJavaLauncher(Jdk.JDK_11)
- systemProperty("TEST_DATA_LOCATION",
- layout.buildDirectory.dir("classes/java/test").get().toString())
- systemProperty("TESTBASE_DATA_LOCATION",
- testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0])
+ systemProperty(
+ "TEST_DATA_LOCATION",
+ layout.buildDirectory.dir("classes/java/test").get().toString(),
+ )
+ systemProperty(
+ "TESTBASE_DATA_LOCATION",
+ testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0],
+ )
}
- val testJar by registering(Jar::class) {
- from(sourceSets.test.get().output)
- // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets. Renaming
- // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
- // the jar and not show red underlines. However, navigation to base classes will not work.
- archiveFileName.set("not_named_tests_java_11.jar")
- }
+ val testJar by
+ registering(Jar::class) {
+ from(sourceSets.test.get().output)
+ // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets.
+ // Renaming
+ // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
+ // the jar and not show red underlines. However, navigation to base classes will not work.
+ archiveFileName.set("not_named_tests_java_11.jar")
+ }
}
-
diff --git a/d8_r8/test_modules/tests_java_11/settings.gradle.kts b/d8_r8/test_modules/tests_java_11/settings.gradle.kts
index e0c1ff3..ea7ec00 100644
--- a/d8_r8/test_modules/tests_java_11/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_java_11/settings.gradle.kts
@@ -4,26 +4,21 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
+ maven { url = uri("file:../../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../../third_party/dependencies") } }
}
rootProject.name = "tests_java_11"
+
val root = rootProject.projectDir.parentFile.parentFile
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("main"))
+
includeBuild(root.resolve("test_modules").resolve("testbase"))
diff --git a/d8_r8/test_modules/tests_java_17/build.gradle.kts b/d8_r8/test_modules/tests_java_17/build.gradle.kts
index c4a99f0..a695d93 100644
--- a/d8_r8/test_modules/tests_java_17/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_17/build.gradle.kts
@@ -16,23 +16,18 @@
// Can be moved into src/test/java17 when all examples have been converted
// to tests. Currently both the Test target below and buildExampleJars depend
// on this.
- sourceSets.test.configure {
- java.srcDir(root.resolveAll("src", "test", "java17"))
- }
+ sourceSets.test.configure { java.srcDir(root.resolveAll("src", "test", "java17")) }
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
val testbaseDepsJarTask = projectTask("testbase", "depsJar")
val mainTurboCompileTask = projectTask("main", "compileTurboJava")
val mainCompileTask = projectTask("main", "compileJava")
-
dependencies {
implementation(files(testbaseDepsJarTask.outputs.files.getSingleFile()))
implementation(testbaseJavaCompileTask.outputs.files)
@@ -51,21 +46,27 @@
withType<Test> {
notCompatibleWithConfigurationCache(
- "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache")
+ "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache"
+ )
TestingState.setUpTestingState(this)
javaLauncher = getJavaLauncher(Jdk.JDK_17)
- systemProperty("TEST_DATA_LOCATION",
- layout.buildDirectory.dir("classes/java/test").get().toString())
- systemProperty("TESTBASE_DATA_LOCATION",
- testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0])
+ systemProperty(
+ "TEST_DATA_LOCATION",
+ layout.buildDirectory.dir("classes/java/test").get().toString(),
+ )
+ systemProperty(
+ "TESTBASE_DATA_LOCATION",
+ testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0],
+ )
}
- val testJar by registering(Jar::class) {
- from(sourceSets.test.get().output)
- // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets. Renaming
- // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
- // the jar and not show red underlines. However, navigation to base classes will not work.
- archiveFileName.set("not_named_tests_java_17.jar")
- }
+ val testJar by
+ registering(Jar::class) {
+ from(sourceSets.test.get().output)
+ // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets.
+ // Renaming
+ // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
+ // the jar and not show red underlines. However, navigation to base classes will not work.
+ archiveFileName.set("not_named_tests_java_17.jar")
+ }
}
-
diff --git a/d8_r8/test_modules/tests_java_17/settings.gradle.kts b/d8_r8/test_modules/tests_java_17/settings.gradle.kts
index ce5980a..bce39cc4 100644
--- a/d8_r8/test_modules/tests_java_17/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_java_17/settings.gradle.kts
@@ -4,26 +4,21 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
+ maven { url = uri("file:../../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../../third_party/dependencies") } }
}
rootProject.name = "tests_java_17"
+
val root = rootProject.projectDir.parentFile.parentFile
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("main"))
+
includeBuild(root.resolve("test_modules").resolve("testbase"))
diff --git a/d8_r8/test_modules/tests_java_21/build.gradle.kts b/d8_r8/test_modules/tests_java_21/build.gradle.kts
index 739675f..1260d2d 100644
--- a/d8_r8/test_modules/tests_java_21/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_21/build.gradle.kts
@@ -13,16 +13,12 @@
val root = getRoot()
java {
- sourceSets.test.configure {
- java.srcDir(root.resolveAll("src", "test", "java21"))
- }
+ sourceSets.test.configure { java.srcDir(root.resolveAll("src", "test", "java21")) }
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
val testbaseDepsJarTask = projectTask("testbase", "depsJar")
@@ -49,27 +45,37 @@
withType<Test> {
notCompatibleWithConfigurationCache(
- "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache")
+ "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache"
+ )
TestingState.setUpTestingState(this)
javaLauncher = getJavaLauncher(Jdk.JDK_21)
- systemProperty("TEST_DATA_LOCATION",
- layout.buildDirectory.dir("classes/java/test").get().toString())
- systemProperty("TESTBASE_DATA_LOCATION",
- testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0])
+ systemProperty(
+ "TEST_DATA_LOCATION",
+ layout.buildDirectory.dir("classes/java/test").get().toString(),
+ )
+ systemProperty(
+ "TESTBASE_DATA_LOCATION",
+ testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0],
+ )
systemProperty(
"BUILD_PROP_R8_RUNTIME_PATH",
mainCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
- File.pathSeparator + mainTurboCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
- File.pathSeparator + getRoot().resolveAll("src", "main", "resources") +
- File.pathSeparator + assistantCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0])
+ File.pathSeparator +
+ mainTurboCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
+ File.pathSeparator +
+ getRoot().resolveAll("src", "main", "resources") +
+ File.pathSeparator +
+ assistantCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0],
+ )
}
- val testJar by registering(Jar::class) {
- from(sourceSets.test.get().output)
- // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets. Renaming
- // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
- // the jar and not show red underlines. However, navigation to base classes will not work.
- archiveFileName.set("not_named_tests_java_21.jar")
- }
+ val testJar by
+ registering(Jar::class) {
+ from(sourceSets.test.get().output)
+ // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets.
+ // Renaming
+ // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
+ // the jar and not show red underlines. However, navigation to base classes will not work.
+ archiveFileName.set("not_named_tests_java_21.jar")
+ }
}
-
diff --git a/d8_r8/test_modules/tests_java_21/settings.gradle.kts b/d8_r8/test_modules/tests_java_21/settings.gradle.kts
index bac16df..eee33aa 100644
--- a/d8_r8/test_modules/tests_java_21/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_java_21/settings.gradle.kts
@@ -4,27 +4,23 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
+ maven { url = uri("file:../../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../../third_party/dependencies") } }
}
rootProject.name = "tests_java_21"
+
val root = rootProject.projectDir.parentFile.parentFile
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("assistant"))
+
includeBuild(root.resolve("main"))
-includeBuild(root.resolve("test_modules").resolve("testbase"))
\ No newline at end of file
+
+includeBuild(root.resolve("test_modules").resolve("testbase"))
diff --git a/d8_r8/test_modules/tests_java_25/build.gradle.kts b/d8_r8/test_modules/tests_java_25/build.gradle.kts
index 5a84897..3ba31b8 100644
--- a/d8_r8/test_modules/tests_java_25/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_25/build.gradle.kts
@@ -13,16 +13,12 @@
val root = getRoot()
java {
- sourceSets.test.configure {
- java.srcDir(root.resolveAll("src", "test", "java25"))
- }
+ sourceSets.test.configure { java.srcDir(root.resolveAll("src", "test", "java25")) }
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
val testbaseDepsJarTask = projectTask("testbase", "depsJar")
@@ -47,13 +43,17 @@
withType<Test> {
notCompatibleWithConfigurationCache(
- "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache")
+ "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache"
+ )
TestingState.setUpTestingState(this)
javaLauncher = getJavaLauncher(Jdk.JDK_25)
- systemProperty("TEST_DATA_LOCATION",
- layout.buildDirectory.dir("classes/java/test").get().toString())
- systemProperty("TESTBASE_DATA_LOCATION",
- testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0])
+ systemProperty(
+ "TEST_DATA_LOCATION",
+ layout.buildDirectory.dir("classes/java/test").get().toString(),
+ )
+ systemProperty(
+ "TESTBASE_DATA_LOCATION",
+ testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0],
+ )
}
}
-
diff --git a/d8_r8/test_modules/tests_java_25/settings.gradle.kts b/d8_r8/test_modules/tests_java_25/settings.gradle.kts
index 0f47405..fc410b1 100644
--- a/d8_r8/test_modules/tests_java_25/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_java_25/settings.gradle.kts
@@ -4,26 +4,21 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
+ maven { url = uri("file:../../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../../third_party/dependencies") } }
}
rootProject.name = "tests_java_25"
+
val root = rootProject.projectDir.parentFile.parentFile
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("main"))
+
includeBuild(root.resolve("test_modules").resolve("testbase"))
diff --git a/d8_r8/test_modules/tests_java_8/build.gradle.kts b/d8_r8/test_modules/tests_java_8/build.gradle.kts
index a67742f..ddaa1b7 100644
--- a/d8_r8/test_modules/tests_java_8/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_8/build.gradle.kts
@@ -25,14 +25,10 @@
// compatible with java toolchains.
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
val testbaseDepsJarTask = projectTask("testbase", "depsJar")
@@ -63,40 +59,40 @@
implementation(testbaseJavaCompileTask.outputs.files)
}
-val sourceSetDependenciesTasks = arrayOf(
- projectTask("tests_java_9", getExampleJarsTaskName("examplesJava9")),
-)
+val sourceSetDependenciesTasks =
+ arrayOf(projectTask("tests_java_9", getExampleJarsTaskName("examplesJava9")))
-fun testDependencies() : FileCollection {
- return sourceSets
- .test
- .get()
- .compileClasspath
- .filter {
- "$it".contains("third_party")
- && !"$it".contains("errorprone")
- && !"$it".contains("third_party/gradle")
- }
+fun testDependencies(): FileCollection {
+ return sourceSets.test.get().compileClasspath.filter {
+ "$it".contains("third_party") &&
+ !"$it".contains("errorprone") &&
+ !"$it".contains("third_party/gradle")
+ }
}
tasks {
-
getByName<Delete>("clean") {
// TODO(b/327315907): Don't generating into the root build dir.
- delete.add(getRoot().resolveAll("build", "generated", "test", "java", "com", "android", "tools", "r8", "art"))
+ delete.add(
+ getRoot()
+ .resolveAll("build", "generated", "test", "java", "com", "android", "tools", "r8", "art")
+ )
}
- val createArtTests by registering(Exec::class) {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- // TODO(b/327315907): Don't generating into the root build dir.
- val outputDir = getRoot().resolveAll("build", "generated", "test", "java", "com", "android", "tools", "r8", "art")
- val createArtTestsScript = getRoot().resolveAll("tools", "create_art_tests.py")
- inputs.file(createArtTestsScript)
- inputs.dir(getRoot().resolveAll("tests", "2017-10-04"))
- outputs.dir(outputDir)
- workingDir(getRoot())
- commandLine("python3", createArtTestsScript)
- }
+ val createArtTests by
+ registering(Exec::class) {
+ dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
+ // TODO(b/327315907): Don't generating into the root build dir.
+ val outputDir =
+ getRoot()
+ .resolveAll("build", "generated", "test", "java", "com", "android", "tools", "r8", "art")
+ val createArtTestsScript = getRoot().resolveAll("tools", "create_art_tests.py")
+ inputs.file(createArtTestsScript)
+ inputs.dir(getRoot().resolveAll("tests", "2017-10-04"))
+ outputs.dir(outputDir)
+ workingDir(getRoot())
+ commandLine("python3", createArtTestsScript)
+ }
"compileTestJava" {
dependsOn(testbaseJavaCompileTask)
dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
@@ -119,13 +115,9 @@
}
}
- withType<KotlinCompile> {
- enabled = false
- }
+ withType<KotlinCompile> { enabled = false }
- val sourceSetDependencyTask by registering {
- dependsOn(*sourceSetDependenciesTasks)
- }
+ val sourceSetDependencyTask by registering { dependsOn(*sourceSetDependenciesTasks) }
withType<Test> {
TestingState.setUpTestingState(this)
@@ -135,37 +127,52 @@
dependsOn(gradle.includedBuild("shared").task(":downloadDepsInternal"))
}
dependsOn(sourceSetDependencyTask)
- systemProperty("TEST_DATA_LOCATION",
- layout.buildDirectory.dir("classes/java/test").get().toString())
- systemProperty("TESTBASE_DATA_LOCATION",
- testbaseJavaCompileTask.outputs.files.asPath.split(File.pathSeparator)[0])
+ systemProperty(
+ "TEST_DATA_LOCATION",
+ layout.buildDirectory.dir("classes/java/test").get().toString(),
+ )
+ systemProperty(
+ "TESTBASE_DATA_LOCATION",
+ testbaseJavaCompileTask.outputs.files.asPath.split(File.pathSeparator)[0],
+ )
systemProperty(
"BUILD_PROP_KEEPANNO_RUNTIME_PATH",
extractClassesPaths(
"keepanno" + File.separator,
keepAnnoCompileTask.outputs.files.asPath,
- keepAnnoCompileKotlinTask.outputs.files.asPath))
+ keepAnnoCompileKotlinTask.outputs.files.asPath,
+ ),
+ )
// This path is set when compiling examples jar task in DependenciesPlugin.
val r8RuntimePath =
- mainCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
- File.pathSeparator + mainTurboCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
- File.pathSeparator + mainDepsJarTask.outputs.files.singleFile +
- File.pathSeparator + getRoot().resolveAll("src", "main", "resources") +
- File.pathSeparator + keepAnnoCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
- File.pathSeparator + assistantCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
- File.pathSeparator + resourceShrinkerJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
- File.pathSeparator + resourceShrinkerKotlinCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[1]
+ mainCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
+ File.pathSeparator +
+ mainTurboCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
+ File.pathSeparator +
+ mainDepsJarTask.outputs.files.singleFile +
+ File.pathSeparator +
+ getRoot().resolveAll("src", "main", "resources") +
+ File.pathSeparator +
+ keepAnnoCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
+ File.pathSeparator +
+ assistantCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
+ File.pathSeparator +
+ resourceShrinkerJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
+ File.pathSeparator +
+ resourceShrinkerKotlinCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[1]
systemProperty("BUILD_PROP_PROCESS_KEEP_RULES_RUNTIME_PATH", r8RuntimePath)
systemProperty("BUILD_PROP_R8_RUNTIME_PATH", r8RuntimePath)
systemProperty("R8_DEPS", mainDepsJarTask.outputs.files.singleFile)
systemProperty("com.android.tools.r8.artprofilerewritingcompletenesscheck", "true")
}
- val testJar by registering(Jar::class) {
- from(sourceSets.test.get().output)
- // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets. Renaming
- // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
- // the jar and not show red underlines. However, navigation to base classes will not work.
- archiveFileName.set("not_named_tests_java_8.jar")
- }
+ val testJar by
+ registering(Jar::class) {
+ from(sourceSets.test.get().output)
+ // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets.
+ // Renaming
+ // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
+ // the jar and not show red underlines. However, navigation to base classes will not work.
+ archiveFileName.set("not_named_tests_java_8.jar")
+ }
}
diff --git a/d8_r8/test_modules/tests_java_8/settings.gradle.kts b/d8_r8/test_modules/tests_java_8/settings.gradle.kts
index e079b20..ed1895d 100644
--- a/d8_r8/test_modules/tests_java_8/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_java_8/settings.gradle.kts
@@ -4,36 +4,37 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
+ maven { url = uri("file:../../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../../third_party/dependencies") } }
}
rootProject.name = "tests_java_8"
val root = rootProject.projectDir.parentFile.parentFile
+
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("assistant"))
+
includeBuild(root.resolve("keepanno"))
+
includeBuild(root.resolve("resourceshrinker"))
// We need to include src/main as a composite-build otherwise our test-modules
// will compete with the test to compile the source files.
includeBuild(root.resolve("main"))
+
includeBuild(root.resolve("test_modules").resolve("testbase"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_9"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_11"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_17"))
+
includeBuild(root.resolve("test_modules").resolve("tests_java_21"))
diff --git a/d8_r8/test_modules/tests_java_9/build.gradle.kts b/d8_r8/test_modules/tests_java_9/build.gradle.kts
index 7cf0684..e70460d 100644
--- a/d8_r8/test_modules/tests_java_9/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_9/build.gradle.kts
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import org.gradle.api.JavaVersion
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`kotlin-dsl`
@@ -14,19 +13,13 @@
val root = getRoot()
java {
- sourceSets.test.configure {
- java.srcDir(root.resolveAll("src", "test", "examplesJava9"))
- }
+ sourceSets.test.configure { java.srcDir(root.resolveAll("src", "test", "examplesJava9")) }
sourceCompatibility = JavaVersion.VERSION_1_9
targetCompatibility = JavaVersion.VERSION_1_9
- toolchain {
- languageVersion = JavaLanguageVersion.of(JvmCompatibility.release)
- }
+ toolchain { languageVersion = JavaLanguageVersion.of(JvmCompatibility.release) }
}
-kotlin {
- explicitApi()
-}
+kotlin { explicitApi() }
val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
val testbaseDepsJarTask = projectTask("testbase", "depsJar")
@@ -45,29 +38,33 @@
val buildExampleJars = buildExampleJars("examplesJava9")
tasks {
- withType<JavaCompile> {
- dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- }
+ withType<JavaCompile> { dependsOn(gradle.includedBuild("shared").task(":downloadDeps")) }
withType<Test> {
notCompatibleWithConfigurationCache(
- "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache")
+ "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache"
+ )
TestingState.setUpTestingState(this)
- systemProperty("TEST_DATA_LOCATION",
+ systemProperty(
+ "TEST_DATA_LOCATION",
// This should be
// layout.buildDirectory.dir("classes/java/test").get().toString()
// once the use of 'buildExampleJars' above is removed.
- getRoot().resolveAll("build", "test", "examplesJava9", "classes"))
- systemProperty("TESTBASE_DATA_LOCATION",
- testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0])
+ getRoot().resolveAll("build", "test", "examplesJava9", "classes"),
+ )
+ systemProperty(
+ "TESTBASE_DATA_LOCATION",
+ testbaseJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0],
+ )
}
- val testJar by registering(Jar::class) {
- from(sourceSets.test.get().output)
- // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets. Renaming
- // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
- // the jar and not show red underlines. However, navigation to base classes will not work.
- archiveFileName.set("not_named_tests_java_9.jar")
- }
+ val testJar by
+ registering(Jar::class) {
+ from(sourceSets.test.get().output)
+ // TODO(b/296486206): Seems like IntelliJ has a problem depending on test source sets.
+ // Renaming
+ // this from the default name (tests_java_8.jar) will allow IntelliJ to find the resources in
+ // the jar and not show red underlines. However, navigation to base classes will not work.
+ archiveFileName.set("not_named_tests_java_9.jar")
+ }
}
-
diff --git a/d8_r8/test_modules/tests_java_9/settings.gradle.kts b/d8_r8/test_modules/tests_java_9/settings.gradle.kts
index 7d7a19b..cfe3db6 100644
--- a/d8_r8/test_modules/tests_java_9/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_java_9/settings.gradle.kts
@@ -4,26 +4,21 @@
pluginManagement {
repositories {
- maven {
- url = uri("file:../../../third_party/dependencies_plugin")
- }
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
+ maven { url = uri("file:../../../third_party/dependencies_plugin") }
+ maven { url = uri("file:../../../third_party/dependencies") }
}
}
dependencyResolutionManagement {
- repositories {
- maven {
- url = uri("file:../../../third_party/dependencies")
- }
- }
+ repositories { maven { url = uri("file:../../../third_party/dependencies") } }
}
rootProject.name = "tests_java_9"
+
val root = rootProject.projectDir.parentFile.parentFile
includeBuild(root.resolve("shared"))
+
includeBuild(root.resolve("main"))
+
includeBuild(root.resolve("test_modules").resolve("testbase"))
diff --git a/tools/fmt-diff.py b/tools/fmt-diff.py
index ebd6ed5..1cb966a 100755
--- a/tools/fmt-diff.py
+++ b/tools/fmt-diff.py
@@ -57,7 +57,7 @@
def FormatKotlin(upstream):
- changed_files_cmd = ['git', 'diff', '--name-only', upstream, '*.kt']
+ changed_files_cmd = ['git', 'diff', '--name-only', upstream, '*.kt', '*.kts']
changed_files = subprocess.check_output(changed_files_cmd).decode(
'utf-8').splitlines()
if not changed_files: