Extend release script to handle desugared library JDK-11 legacy

Bug: b/237636871
Change-Id: I5b3ca414819e24efcb5c4ebbd1bb2dab4c6778c5
diff --git a/tools/archive.py b/tools/archive.py
index 91affd6..652fbe9 100755
--- a/tools/archive.py
+++ b/tools/archive.py
@@ -270,7 +270,7 @@
             utils.upload_file_to_cloud_storage(
                 desugar_jdk_libs_configuration_jar, jar_destination)
 
-      # TODO(sgjesse): Refactor this to avoid the duplication of what is above.
+      # TODO(b/237636871): Refactor this to avoid the duplication of what is above.
       # Upload desugar_jdk_libs JDK-11 legacyconfiguration to a maven compatible location.
       if file == utils.DESUGAR_CONFIGURATION_JDK11_LEGACY:
         jar_basename = 'desugar_jdk_libs_configuration.jar'
diff --git a/tools/r8_release.py b/tools/r8_release.py
index f19c99e..a25baf6 100755
--- a/tools/r8_release.py
+++ b/tools/r8_release.py
@@ -495,12 +495,19 @@
     library_version = args.desugar_library[0]
     configuration_version = args.desugar_library[1]
 
+    # TODO(b/237636871): Cleanup and generalize.
+    if (not (library_version.startswith('1.1') or library_version.startswith('1.2'))):
+      print("Release script does not support desugared library version %s"
+        % library_version)
+      sys.exit(1)
+
     library_archive = DESUGAR_JDK_LIBS + '.zip'
     library_jar = DESUGAR_JDK_LIBS + '.jar'
     library_artifact_id = \
         '%s:%s:%s' % (ANDROID_TOOLS_PACKAGE, DESUGAR_JDK_LIBS, library_version)
 
-    configuration_archive = DESUGAR_JDK_LIBS_CONFIGURATION + '.zip'
+    postfix = "" if library_version.startswith('1.1') else '_jdk11_legacy'
+    configuration_archive = DESUGAR_JDK_LIBS_CONFIGURATION + postfix + '.zip'
 
     with utils.TempDir() as temp:
       with utils.ChangedWorkingDirectory(temp):
@@ -631,15 +638,23 @@
 
 %s
 
-Add the following repository to gradle.build for using 'redir':
+Then add the following repository to settings.gradle to search the 'redir'
+repository:
 
-repositories {
-  maven {
-    url 'http://localhost:1480'
-    allowInsecureProtocol true
+dependencyResolutionManagement {
+  repositories {
+    maven {
+      url 'http://localhost:1480'
+      allowInsecureProtocol true
+    }
   }
-  dependencies {
-    classpath '%s'  // Must be before the Gradle Plugin for Android.
+}
+
+and add the following repository to gradle.build for for the staged version:
+
+dependencies {
+  coreLibraryDesugaring('%s') {
+    changing = true
   }
 }