Build r8lib without passing exclude_deps to gradle
This makes it easier to produce targets from archive (or locally) and
also allows us to put both r8lib and r8lib-exclude-deps as
dependencies for tests.
Change-Id: I8defc1f917bed6d3d40438b04ae5320fe83d9f7f
diff --git a/build.gradle b/build.gradle
index 7ff46eb..653af09 100644
--- a/build.gradle
+++ b/build.gradle
@@ -255,9 +255,10 @@
}
def r8LibPath = "$buildDir/libs/r8lib.jar"
+def r8LibExludeDepsPath = "$buildDir/libs/r8lib-exclude-deps.jar"
def r8LibGeneratedKeepRulesPath = "$buildDir/generated/keep.txt"
+def r8LibGeneratedKeepRulesExcludeDepsPath = "$buildDir/generated/keep-exclude-deps.txt"
def r8LibTestPath = "$buildDir/classes/r8libtest"
-def r8TestsJarPath = "$buildDir/libs/r8tests.jar"
def osString = OperatingSystem.current().isLinux() ? "linux" :
OperatingSystem.current().isMacOsX() ? "mac" : "windows"
@@ -674,7 +675,6 @@
}
task testJar(type: ShadowJar, dependsOn: testClasses) {
- outputs.upToDateWhen { false }
baseName = "r8tests"
from sourceSets.test.output
if (!project.hasProperty('exclude_deps')) {
@@ -682,24 +682,30 @@
}
}
-task generateR8LibKeepRules(type: Exec) {
- doFirst {
- standardOutput new FileOutputStream(r8LibGeneratedKeepRulesPath)
+task testJarNoDeps(type: ShadowJar, dependsOn: testClasses) {
+ baseName = "r8tests-exclude-deps"
+ from sourceSets.test.output
+}
+
+def generateR8LibKeepRules(name, r8Source, testSource, output) {
+ return tasks.create("generateR8LibKeepRules_" + name, Exec) {
+ doFirst {
+ standardOutput new FileOutputStream(output)
+ }
+ dependsOn r8WithRelocatedDeps
+ dependsOn r8Source
+ dependsOn testSource
+ dependsOn downloadOpenJDKrt
+ inputs.files ([r8WithRelocatedDeps.outputs, r8Source.outputs, testSource.outputs])
+ outputs.file output
+ commandLine baseR8CommandLine([
+ "printuses",
+ "--keeprules",
+ "third_party/openjdk/openjdk-rt-1.8/rt.jar",
+ r8Source.outputs.files[0],
+ testSource.outputs.files[0]])
+ workingDir = projectDir
}
- def libSourceTask = project.hasProperty('exclude_deps') ? R8NoManifestNoDeps : R8NoManifest
- dependsOn r8WithRelocatedDeps
- dependsOn libSourceTask
- dependsOn testJar
- dependsOn downloadOpenJDKrt
- inputs.files ([r8WithRelocatedDeps.outputs, libSourceTask.outputs, testJar.outputs])
- outputs.file r8LibGeneratedKeepRulesPath
- commandLine baseR8CommandLine([
- "printuses",
- "--keeprules",
- "third_party/openjdk/openjdk-rt-1.8/rt.jar",
- libSourceTask.outputs.files[0],
- testJar.outputs.files[0]])
- workingDir = projectDir
}
task R8LibApiOnly {
@@ -707,29 +713,40 @@
outputs.file r8LibPath
}
-task R8LibNoDeps {
- dependsOn r8LibCreateTask(
- "NoDeps",
- "src/main/keep.txt",
- R8NoManifestNoDeps,
- r8LibPath,
- ["--pg-conf", generateR8LibKeepRules.outputs.files[0]],
- repackageDepsNoRelocate.outputs.files
- ).dependsOn(repackageDepsNoRelocate, generateR8LibKeepRules)
- outputs.file r8LibPath
-}
-
task R8Lib {
+ def genRulesTask = generateR8LibKeepRules(
+ "Main",
+ R8NoManifest,
+ testJar,
+ r8LibGeneratedKeepRulesPath)
dependsOn r8LibCreateTask(
"Main",
"src/main/keep.txt",
R8NoManifest,
r8LibPath,
- ["--pg-conf", generateR8LibKeepRules.outputs.files[0]]
- ).dependsOn(generateR8LibKeepRules)
+ ["--pg-conf", genRulesTask.outputs.files[0]]
+ ).dependsOn(genRulesTask)
outputs.file r8LibPath
}
+task R8LibNoDeps {
+ def genRulesTask = generateR8LibKeepRules(
+ "NoDeps",
+ R8NoManifestNoDeps,
+ testJarNoDeps,
+ r8LibGeneratedKeepRulesExcludeDepsPath
+ )
+ dependsOn r8LibCreateTask(
+ "NoDeps",
+ "src/main/keep.txt",
+ R8NoManifestNoDeps,
+ r8LibExludeDepsPath,
+ ["--pg-conf", genRulesTask.outputs.files[0]],
+ repackageDepsNoRelocate.outputs.files
+ ).dependsOn(repackageDepsNoRelocate, genRulesTask)
+ outputs.file r8LibExludeDepsPath
+}
+
task CompatDxLib {
dependsOn r8LibCreateTask(
"CompatDx", "src/main/keep-compatdx.txt", CompatDx, "build/libs/compatdxlib.jar")
@@ -1413,7 +1430,7 @@
task configureTestForR8Lib(type: Copy) {
dependsOn testJar
- inputs.file r8TestsJarPath
+ inputs.file "$buildDir/libs/r8tests.jar"
if (getR8LibTask() != null) {
dependsOn getR8LibTask()
delete r8LibTestPath
diff --git a/tools/archive.py b/tools/archive.py
index ce04494..d8fb4d0 100755
--- a/tools/archive.py
+++ b/tools/archive.py
@@ -91,12 +91,6 @@
if not utils.is_bot() and not options.dry_run:
raise Exception('You are not a bot, don\'t archive builds')
- # Generate an r8-ed build without dependencies.
- # The '-Pno_internal' flag is important because we generate the lib based on uses in tests.
- gradle.RunGradleExcludeDeps([utils.R8LIB_NO_DEPS, '-Pno_internal'])
- shutil.copyfile(utils.R8LIB_JAR, utils.R8LIB_EXCLUDE_DEPS_JAR)
- shutil.copyfile(utils.R8LIB_JAR + '.map', utils.R8LIB_EXCLUDE_DEPS_JAR + '.map')
-
# Create maven release which uses a build that exclude dependencies.
create_maven_release.main(["--out", utils.LIBS])
@@ -114,6 +108,7 @@
utils.COMPATDX,
utils.COMPATPROGUARD,
utils.R8LIB,
+ utils.R8LIB_NO_DEPS,
utils.COMPATDXLIB,
utils.COMPATPROGUARDLIB,
'-Pno_internal'
diff --git a/tools/test.py b/tools/test.py
index 6b24433..043487c 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -185,7 +185,6 @@
gradle_args.append('-Pr8lib')
if options.r8lib_no_deps:
gradle_args.append('-Pr8lib_no_deps')
- gradle_args.append('-Pexclude_deps')
# Add Gradle tasks
gradle_args.append('cleanTest')