Add gradle tasks to utils.py for easy update with moving

Bug: 300387869
Change-Id: Ia25ca9c88e7d5c734a43acaf4566577077dfd2c8
diff --git a/tools/archive.py b/tools/archive.py
index 3db2cbe..8ec73ea 100755
--- a/tools/archive.py
+++ b/tools/archive.py
@@ -146,27 +146,21 @@
         version_file=version_file,
         skip_gradle_build=options.skip_gradle_build)
 
-
-    # Generate and copy a full build without dependencies.
-    if (not options.skip_gradle_build):
-      gradle.RunGradle([':main:swissArmyKnife'], new_gradle=True)
-
     # Ensure all archived artifacts has been built before archiving.
     # The target tasks postfixed by 'lib' depend on the actual target task so
     # building it invokes the original task first.
     # The '-Pno_internal' flag is important because we generate the lib based on uses in tests.
     if (not options.skip_gradle_build):
       gradle.RunGradle([
-          ':keepanno:keepAnnoAnnotationsJar',
-          ':main:consolidatedLicense',
-          ':main:r8WithRelocatedDeps',
-          ':main:swissArmyKnife',
-          ':test:r8LibNoDeps',
-          ':test:r8LibWithRelocatedDeps',
-          ':test:retraceNoDeps',
-          ':test:retraceWithRelocatedDeps',
-          ':test:sourcesJar',
-          ':test:sourcesJar',
+          utils.GRADLE_TASK_CONSOLIDATED_LICENSE,
+          utils.GRADLE_TASK_KEEP_ANNO_JAR,
+          utils.GRADLE_TASK_R8,
+          utils.GRADLE_TASK_R8LIB,
+          utils.GRADLE_TASK_R8LIB_NO_DEPS,
+          utils.GRADLE_TASK_RETRACE,
+          utils.GRADLE_TASK_RETRACE_NO_DEPS,
+          utils.GRADLE_TASK_SOURCE_JAR,
+          utils.GRADLE_TASK_SWISS_ARMY_KNIFE,
           '-Pno_internal'
       ], new_gradle=True)
 
diff --git a/tools/create_maven_release.py b/tools/create_maven_release.py
index f93213a..8079c61 100755
--- a/tools/create_maven_release.py
+++ b/tools/create_maven_release.py
@@ -252,7 +252,7 @@
                           new_gradle=False):
   if not skip_gradle_build:
     if (new_gradle):
-      gradle.RunGradle([':test:r8LibWithRelocatedDeps',
+      gradle.RunGradle([utils.GRADLE_TASK_R8LIB,
                         '-Pno_internal'], new_gradle=True)
     else:
       gradle.RunGradle([utils.R8LIB, '-Pno_internal'])
diff --git a/tools/run_benchmark.py b/tools/run_benchmark.py
index c066678..929a672 100755
--- a/tools/run_benchmark.py
+++ b/tools/run_benchmark.py
@@ -16,8 +16,7 @@
 NONLIB_BUILD_TARGET = 'R8WithRelocatedDeps'
 NONLIB_TEST_BUILD_TARGETS = [utils.R8_TESTS_TARGET, utils.R8_TESTS_DEPS_TARGET]
 
-# TODO(b/300387869): Cleanup targets
-R8LIB_BUILD_TARGET = ':test:r8LibWithRelocatedDeps'
+R8LIB_BUILD_TARGET = utils.GRADLE_TASK_R8LIB
 R8LIB_TEST_BUILD_TARGETS = [utils.R8LIB_TESTS_TARGET, utils.R8LIB_TESTS_DEPS_TARGET]
 
 # The r8lib target is always the golem target.
diff --git a/tools/run_on_app_dump.py b/tools/run_on_app_dump.py
index 8602ea9..feb584d 100755
--- a/tools/run_on_app_dump.py
+++ b/tools/run_on_app_dump.py
@@ -24,8 +24,8 @@
 import utils
 
 # TODO(b/300387869): Cleanup targets
-GOLEM_BUILD_TARGETS = [':test:r8LibWithRelocatedDeps',
-                       ':test:retraceWithRelocatedDeps']
+GOLEM_BUILD_TARGETS = [utils.GRADLE_TASK_R8LIB,
+                       utils.GRADLE_TASK_RETRACE]
 SHRINKERS = ['r8', 'r8-full', 'r8-nolib', 'r8-nolib-full']
 
 class AttrDict(dict):
diff --git a/tools/test.py b/tools/test.py
index e39a79a..07adad9 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -375,9 +375,9 @@
   gradle_args.append('-Part_profile_rewriting_completeness_check=true')
 
   # Build an R8 with dependencies for bootstrapping tests before adding test sources.
-  gradle_args.append(':main:r8WithRelocatedDeps')
-  gradle_args.append(':test:cleanTest')
-  gradle_args.append('test:test')
+  gradle_args.append(utils.GRADLE_TASK_R8)
+  gradle_args.append(utils.GRADLE_TASK_CLEAN_TEST)
+  gradle_args.append(utils.GRADLE_TASK_TEST)
   gradle_args.append('--stacktrace')
   gradle_args.append('-Pprint_full_stacktraces')
 
diff --git a/tools/utils.py b/tools/utils.py
index 4c671b9..4b07b6f 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -42,6 +42,18 @@
 TEST_ROOT = os.path.join(REPO_ROOT, 'src', 'test', 'java')
 REPO_SOURCE = 'https://r8.googlesource.com/r8'
 
+GRADLE_TASK_CLEAN_TEST = ':test:cleanTest'
+GRADLE_TASK_CONSOLIDATED_LICENSE = ':main:consolidatedLicense'
+GRADLE_TASK_KEEP_ANNO_JAR = ':keepanno:keepAnnoAnnotationsJar'
+GRADLE_TASK_R8 = ':main:r8WithRelocatedDeps'
+GRADLE_TASK_R8LIB = ':test:r8LibWithRelocatedDeps'
+GRADLE_TASK_R8LIB_NO_DEPS = ':test:r8LibNoDeps'
+GRADLE_TASK_RETRACE = ':test:retraceWithRelocatedDeps'
+GRADLE_TASK_RETRACE_NO_DEPS = ':test:retraceNoDeps'
+GRADLE_TASK_SOURCE_JAR = ':test:sourcesJar'
+GRADLE_TASK_SWISS_ARMY_KNIFE = ':main:swissArmyKnife'
+GRADLE_TASK_TEST = ':test:test'
+
 D8 = 'd8'
 R8 = 'r8'
 R8LIB = 'r8lib'