Make gradle less chatty by filtering JDK paths and using logger.info
Change-Id: I8da2a93814ec44abc56c1eb33c2ada41646de090
diff --git a/d8_r8/assistant/gradle.properties b/d8_r8/assistant/gradle.properties
index 974fb49..a12fbef 100644
--- a/d8_r8/assistant/gradle.properties
+++ b/d8_r8/assistant/gradle.properties
@@ -28,6 +28,8 @@
# NOTE: Gradle will ignore directories which does not exist, as will be the
# case for JDK's for platforms different from the one this is running on
# when using the default downloadDeps setup.
+# These paths are provided by tools/gradle.py and tools/test.py, but kept here
+# to allow for direct gradle invocations.
org.gradle.java.installations.paths=\
third_party/openjdk/jdk-11/linux,\
third_party/openjdk/jdk-17/linux,\
diff --git a/d8_r8/blastradius/gradle.properties b/d8_r8/blastradius/gradle.properties
index 974fb49..a12fbef 100644
--- a/d8_r8/blastradius/gradle.properties
+++ b/d8_r8/blastradius/gradle.properties
@@ -28,6 +28,8 @@
# NOTE: Gradle will ignore directories which does not exist, as will be the
# case for JDK's for platforms different from the one this is running on
# when using the default downloadDeps setup.
+# These paths are provided by tools/gradle.py and tools/test.py, but kept here
+# to allow for direct gradle invocations.
org.gradle.java.installations.paths=\
third_party/openjdk/jdk-11/linux,\
third_party/openjdk/jdk-17/linux,\
diff --git a/d8_r8/commonBuildSrc/src/main/kotlin/TestConfigurationHelper.kt b/d8_r8/commonBuildSrc/src/main/kotlin/TestConfigurationHelper.kt
index c02c123..23eaab9 100644
--- a/d8_r8/commonBuildSrc/src/main/kotlin/TestConfigurationHelper.kt
+++ b/d8_r8/commonBuildSrc/src/main/kotlin/TestConfigurationHelper.kt
@@ -219,13 +219,13 @@
}
if (project.hasProperty("dex_vm") && project.property("dex_vm") != "default") {
- println("NOTE: Running with non default vm: " + project.property("dex_vm"))
+ project.logger.info("NOTE: Running with non default vm: " + project.property("dex_vm"))
test.systemProperty("dex_vm", project.property("dex_vm")!!)
}
// Forward runtime configurations for test parameters.
if (project.hasProperty("runtimes")) {
- println("NOTE: Running with runtimes: " + project.property("runtimes"))
+ project.logger.info("NOTE: Running with runtimes: " + project.property("runtimes"))
test.systemProperty("runtimes", project.property("runtimes")!!)
}
diff --git a/d8_r8/keepanno/gradle.properties b/d8_r8/keepanno/gradle.properties
index 974fb49..a12fbef 100644
--- a/d8_r8/keepanno/gradle.properties
+++ b/d8_r8/keepanno/gradle.properties
@@ -28,6 +28,8 @@
# NOTE: Gradle will ignore directories which does not exist, as will be the
# case for JDK's for platforms different from the one this is running on
# when using the default downloadDeps setup.
+# These paths are provided by tools/gradle.py and tools/test.py, but kept here
+# to allow for direct gradle invocations.
org.gradle.java.installations.paths=\
third_party/openjdk/jdk-11/linux,\
third_party/openjdk/jdk-17/linux,\
diff --git a/d8_r8/libanalyzer/gradle.properties b/d8_r8/libanalyzer/gradle.properties
index 974fb49..a12fbef 100644
--- a/d8_r8/libanalyzer/gradle.properties
+++ b/d8_r8/libanalyzer/gradle.properties
@@ -28,6 +28,8 @@
# NOTE: Gradle will ignore directories which does not exist, as will be the
# case for JDK's for platforms different from the one this is running on
# when using the default downloadDeps setup.
+# These paths are provided by tools/gradle.py and tools/test.py, but kept here
+# to allow for direct gradle invocations.
org.gradle.java.installations.paths=\
third_party/openjdk/jdk-11/linux,\
third_party/openjdk/jdk-17/linux,\
diff --git a/d8_r8/main/build.gradle.kts b/d8_r8/main/build.gradle.kts
index b4f2592..6021426 100644
--- a/d8_r8/main/build.gradle.kts
+++ b/d8_r8/main/build.gradle.kts
@@ -288,7 +288,7 @@
tasks.withType<JavaCompile> {
dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
- println("NOTE: Running with JDK: " + org.gradle.internal.jvm.Jvm.current().javaHome)
+ logger.info("NOTE: Running with JDK: " + org.gradle.internal.jvm.Jvm.current().javaHome)
}
tasks.withType<ProcessResources> { dependsOn(gradle.includedBuild("shared").task(":downloadDeps")) }
diff --git a/d8_r8/main/gradle.properties b/d8_r8/main/gradle.properties
index 974fb49..a12fbef 100644
--- a/d8_r8/main/gradle.properties
+++ b/d8_r8/main/gradle.properties
@@ -28,6 +28,8 @@
# NOTE: Gradle will ignore directories which does not exist, as will be the
# case for JDK's for platforms different from the one this is running on
# when using the default downloadDeps setup.
+# These paths are provided by tools/gradle.py and tools/test.py, but kept here
+# to allow for direct gradle invocations.
org.gradle.java.installations.paths=\
third_party/openjdk/jdk-11/linux,\
third_party/openjdk/jdk-17/linux,\
diff --git a/d8_r8/resourceshrinker/gradle.properties b/d8_r8/resourceshrinker/gradle.properties
index 974fb49..a12fbef 100644
--- a/d8_r8/resourceshrinker/gradle.properties
+++ b/d8_r8/resourceshrinker/gradle.properties
@@ -28,6 +28,8 @@
# NOTE: Gradle will ignore directories which does not exist, as will be the
# case for JDK's for platforms different from the one this is running on
# when using the default downloadDeps setup.
+# These paths are provided by tools/gradle.py and tools/test.py, but kept here
+# to allow for direct gradle invocations.
org.gradle.java.installations.paths=\
third_party/openjdk/jdk-11/linux,\
third_party/openjdk/jdk-17/linux,\
diff --git a/d8_r8/test/build.gradle.kts b/d8_r8/test/build.gradle.kts
index 3e73d9c..07beedb 100644
--- a/d8_r8/test/build.gradle.kts
+++ b/d8_r8/test/build.gradle.kts
@@ -485,8 +485,8 @@
}
fun Test.testR8Lib(r8Lib: TaskProvider<Exec>, unzipRewrittenTests: TaskProvider<Copy>) {
- println("NOTE: Number of processors " + Runtime.getRuntime().availableProcessors())
- println("NOTE: Max parallel forks " + maxParallelForks)
+ logger.info("NOTE: Number of processors " + Runtime.getRuntime().availableProcessors())
+ logger.info("NOTE: Max parallel forks " + maxParallelForks)
dependsOn(
packageTestDeps,
processKeepRulesLibWithRelocatedDepsTask,
diff --git a/gradle.properties b/gradle.properties
index 974fb49..a12fbef 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -28,6 +28,8 @@
# NOTE: Gradle will ignore directories which does not exist, as will be the
# case for JDK's for platforms different from the one this is running on
# when using the default downloadDeps setup.
+# These paths are provided by tools/gradle.py and tools/test.py, but kept here
+# to allow for direct gradle invocations.
org.gradle.java.installations.paths=\
third_party/openjdk/jdk-11/linux,\
third_party/openjdk/jdk-17/linux,\
diff --git a/tools/gradle.py b/tools/gradle.py
index 11486ca..ee92fca 100755
--- a/tools/gradle.py
+++ b/tools/gradle.py
@@ -56,6 +56,11 @@
'the gradle caches.',
action='store_true',
default=False)
+ parser.add_argument('--quiet',
+ '-q',
+ help='Only print warnings and errors from gradle.',
+ action='store_true',
+ default=False)
return parser.parse_known_args()
@@ -121,26 +126,63 @@
ensure_protoc()
-def run_gradle_in(gradle_cmd, args, cwd, throw_on_failure=True, env=None):
+def run_gradle_in(gradle_cmd,
+ args,
+ cwd,
+ throw_on_failure=True,
+ env=None,
+ quiet=False):
ensure_deps()
cmd = [gradle_cmd]
# Changes to these flags should be copied to gradle_benchmark.scenarios.
args.extend(['--offline'])
+ if not any(
+ arg.startswith('-Porg.gradle.java.installations.paths=')
+ for arg in args):
+ args.append('-Porg.gradle.java.installations.paths=' +
+ get_java_installations_paths())
+ if not any(
+ arg.startswith('-Porg.gradle.java.installations.auto-detect=')
+ for arg in args):
+ args.append('-Porg.gradle.java.installations.auto-detect=false')
+ if not any(
+ arg.startswith('-Porg.gradle.java.installations.auto-download=')
+ for arg in args):
+ args.append('-Porg.gradle.java.installations.auto-download=false')
+ if quiet:
+ args.append('--quiet')
cmd.extend(args)
with utils.ChangedWorkingDirectory(cwd):
- utils.PrintCmd(cmd)
+ if not quiet:
+ utils.PrintCmd(cmd)
return_value = subprocess.call(cmd, env=get_java_env(env))
if throw_on_failure and return_value != 0:
raise Exception('Failed to execute gradle')
return return_value
-def run_gradle(args, throw_on_failure=True, env=None):
+def run_gradle(args, throw_on_failure=True, env=None, quiet=False):
return run_gradle_in(get_gradle_executable(),
args,
utils.REPO_ROOT,
throw_on_failure,
- env=env)
+ env=env,
+ quiet=quiet)
+
+
+def get_java_installations_paths():
+ paths = []
+ openjdk_dir = os.path.join(utils.THIRD_PARTY, 'openjdk')
+ if os.path.exists(openjdk_dir):
+ for jdk in os.listdir(openjdk_dir):
+ jdk_dir = os.path.join(openjdk_dir, jdk)
+ if not os.path.isdir(jdk_dir):
+ continue
+ for platform in ['linux', 'osx', 'windows']:
+ platform_dir = os.path.join(jdk_dir, platform)
+ if os.path.exists(platform_dir):
+ paths.append(platform_dir)
+ return ','.join(paths)
def main():
@@ -153,7 +195,7 @@
args.append('-Pexclude_deps')
if options.worktree:
args.append('-g=' + os.path.join(utils.REPO_ROOT, ".gradle_user_home"))
- return run_gradle(args)
+ return run_gradle(args, quiet=options.quiet)
if __name__ == '__main__':
diff --git a/tools/gradle_benchmark.scenarios b/tools/gradle_benchmark.scenarios
index 6338d8f..48524dc 100644
--- a/tools/gradle_benchmark.scenarios
+++ b/tools/gradle_benchmark.scenarios
@@ -20,7 +20,11 @@
base_config {
# These flags should mirror gradle.py
- gradle-args = ["--offline"]
+ gradle-args = [
+ "--offline",
+ "-Porg.gradle.java.installations.auto-detect=false",
+ "-Porg.gradle.java.installations.auto-download=false"
+ ]
# A bug in the csv output prevents changing the amount of warmups per scenario
# https://github.com/gradle/gradle-profiler/issues/317
warm-ups = 2
diff --git a/tools/test.py b/tools/test.py
index 839cf22..5192880 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -87,6 +87,11 @@
help='Print test stdout to, well, stdout.',
default=False,
action='store_true')
+ result.add_argument('-q',
+ '--quiet',
+ help='Only print warnings and errors from gradle.',
+ default=False,
+ action='store_true')
result.add_argument(
'--dex-vm',
'--dex_vm',
@@ -361,7 +366,7 @@
def test(options, args):
if utils.is_bot():
- gradle.run_gradle(['--no-daemon', 'clean'])
+ gradle.run_gradle(['--no-daemon', 'clean'], quiet=options.quiet)
print('Running with python ' + str(sys.version_info))
# Always print stats on bots if command cache is enabled
options.command_cache_stats = options.command_cache_dir is not None
@@ -610,7 +615,9 @@
runtimes.extend(matches)
gradle_args.append('-Pruntimes=%s' % ':'.join(runtimes))
- return_code = gradle.run_gradle(gradle_args, throw_on_failure=False)
+ return_code = gradle.run_gradle(gradle_args,
+ throw_on_failure=False,
+ quiet=options.quiet)
return archive_and_return(return_code, options)
# Legacy testing populates the runtimes based on dex_vm.
@@ -626,7 +633,8 @@
'-Pdex_vm=%s' % art_vm + vm_suffix,
'-Pruntimes=%s' % ':'.join(runtimes),
],
- throw_on_failure=False)
+ throw_on_failure=False,
+ quiet=options.quiet)
if options.generate_golden_files_to:
sha1 = '%s' % utils.get_HEAD_sha1()
with utils.ChangedWorkingDirectory(