blob: 27c3b2595bd9491e6bd48ad3e280517f6953a036 [file] [log] [blame]
Ian Zernydcb172e2022-02-22 15:36:45 +01001#!/usr/bin/env python3
Rico Windb4621c12017-08-28 12:48:53 +02002# Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5
Mads Agerac794132017-11-09 11:38:45 +01006import create_maven_release
Mathias Ravdd6a6de2018-05-18 10:18:33 +02007import gradle
Ian Zerny3f54e222019-02-12 10:51:17 +01008import jdk
Rico Wind63a13562018-12-10 14:31:02 +01009import optparse
Rico Windb4621c12017-08-28 12:48:53 +020010import os
Morten Krogh-Jespersenfe0d7e12020-01-31 08:50:17 +010011try:
12 import resource
13except ImportError:
14 # Not a Unix system. Do what Gandalf tells you not to.
15 pass
Mathias Ravdd6a6de2018-05-18 10:18:33 +020016import shutil
Rico Wind0c24ae72017-09-08 11:33:56 +020017import subprocess
Rico Windb4621c12017-08-28 12:48:53 +020018import sys
Mathias Ravdd6a6de2018-05-18 10:18:33 +020019import toolhelper
Rico Windb4621c12017-08-28 12:48:53 +020020import utils
Yohann Roussel73f58e12017-10-13 17:33:14 +020021import zipfile
Tamas Kenez180be092018-12-05 15:23:06 +010022from build_r8lib import build_r8lib
Rico Windb4621c12017-08-28 12:48:53 +020023
Rico Wind792e8c72017-08-30 09:43:46 +020024ARCHIVE_BUCKET = 'r8-releases'
Rico Windb4621c12017-08-28 12:48:53 +020025
Rico Wind63a13562018-12-10 14:31:02 +010026def ParseOptions():
27 result = optparse.OptionParser()
28 result.add_option('--dry-run', '--dry_run',
29 help='Build only, no upload.',
30 default=False, action='store_true')
Søren Gjessec425e6a2019-06-28 11:41:14 +020031 result.add_option('--dry-run-output', '--dry_run_output',
32 help='Output directory for \'build only, no upload\'.',
33 type="string", action="store")
Søren Gjesse1b035b32022-08-19 08:53:57 +020034 result.add_option('--skip-gradle-build', '--skip_gradle_build',
35 help='Skip Gradle build. Can only be used for local testing.',
36 default=False, action='store_true')
Rico Wind63a13562018-12-10 14:31:02 +010037 return result.parse_args()
38
Rico Windb4621c12017-08-28 12:48:53 +020039def GetVersion():
Rico Windd31b5892022-04-25 11:06:30 +020040 output = subprocess.check_output([
41 jdk.GetJavaExecutable(), '-cp', utils.R8_JAR, 'com.android.tools.r8.R8',
42 '--version'
43 ]).decode('utf-8')
44 r8_version = output.splitlines()[0].strip()
45 return r8_version.split()[1]
Rico Windb4621c12017-08-28 12:48:53 +020046
Rico Wind0c24ae72017-09-08 11:33:56 +020047def GetGitBranches():
48 return subprocess.check_output(['git', 'show', '-s', '--pretty=%d', 'HEAD'])
Rico Windb4621c12017-08-28 12:48:53 +020049
Rico Wind0c24ae72017-09-08 11:33:56 +020050def GetGitHash():
Rico Windfd186372022-02-28 08:55:48 +010051 return subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip()
Rico Windb4621c12017-08-28 12:48:53 +020052
Rico Wind1b52acf2021-03-21 12:36:55 +010053def IsMain(version):
Rico Windfd186372022-02-28 08:55:48 +010054 branches = subprocess.check_output(['git', 'branch', '-r', '--contains',
55 'HEAD']).decode('utf-8')
Rico Wind1b52acf2021-03-21 12:36:55 +010056 # CL runs from gerrit does not have a branch, we always treat them as main
Rico Windd450ba12019-04-24 13:18:40 +020057 # commits to archive these to the hash based location
58 if len(branches) == 0:
59 return True
Rico Wind1b52acf2021-03-21 12:36:55 +010060 if not version == 'main':
Rico Wind0c24ae72017-09-08 11:33:56 +020061 # Sanity check, we don't want to archive on top of release builds EVER
62 # Note that even though we branch, we never push the bots to build the same
Rico Wind1b52acf2021-03-21 12:36:55 +010063 # commit as main on a branch since we always change the version to
64 # not be just 'main' (or we crash here :-)).
65 if 'origin/main' in branches:
66 raise Exception('We are seeing origin/main in a commit that '
67 'don\'t have \'main\' as version')
Mads Agerac794132017-11-09 11:38:45 +010068 return False
Rico Wind1b52acf2021-03-21 12:36:55 +010069 if not 'origin/main' in branches:
70 raise Exception('We are not seeing origin/main '
71 'in a commit that have \'main\' as version')
Mads Agerac794132017-11-09 11:38:45 +010072 return True
Rico Wind0c24ae72017-09-08 11:33:56 +020073
Rico Windc0b16382018-05-17 13:23:43 +020074def GetStorageDestination(storage_prefix,
75 version_or_path,
76 file_name,
Rico Wind1b52acf2021-03-21 12:36:55 +010077 is_main):
78 # We archive main commits under raw/main instead of directly under raw
Rico Windc0b16382018-05-17 13:23:43 +020079 version_dir = GetVersionDestination(storage_prefix,
80 version_or_path,
Rico Wind1b52acf2021-03-21 12:36:55 +010081 is_main)
Rico Wind1a29c4f2018-01-25 08:43:08 +010082 return '%s/%s' % (version_dir, file_name)
83
Rico Wind1b52acf2021-03-21 12:36:55 +010084def GetVersionDestination(storage_prefix, version_or_path, is_main):
85 archive_dir = 'raw/main' if is_main else 'raw'
Rico Windc0b16382018-05-17 13:23:43 +020086 return '%s%s/%s/%s' % (storage_prefix, ARCHIVE_BUCKET,
87 archive_dir, version_or_path)
Rico Wind0c24ae72017-09-08 11:33:56 +020088
Rico Wind1b52acf2021-03-21 12:36:55 +010089def GetUploadDestination(version_or_path, file_name, is_main):
90 return GetStorageDestination('gs://', version_or_path, file_name, is_main)
Rico Wind0c24ae72017-09-08 11:33:56 +020091
Rico Wind1b52acf2021-03-21 12:36:55 +010092def GetUrl(version_or_path, file_name, is_main):
Rico Wind70d614f2020-01-31 08:45:21 +010093 return GetStorageDestination('https://storage.googleapis.com/',
Rico Wind1b52acf2021-03-21 12:36:55 +010094 version_or_path, file_name, is_main)
Rico Windc0b16382018-05-17 13:23:43 +020095
Rico Wind1b52acf2021-03-21 12:36:55 +010096def GetMavenUrl(is_main):
97 return GetVersionDestination('https://storage.googleapis.com/', '', is_main)
Rico Windb4621c12017-08-28 12:48:53 +020098
Rico Wind7219bb02019-03-18 08:30:12 +010099def SetRLimitToMax():
100 (soft, hard) = resource.getrlimit(resource.RLIMIT_NOFILE)
101 resource.setrlimit(resource.RLIMIT_NOFILE, (hard, hard))
102
Rico Windcea9ce02019-03-06 14:25:52 +0100103def PrintResourceInfo():
104 (soft, hard) = resource.getrlimit(resource.RLIMIT_NOFILE)
105 print('INFO: Open files soft limit: %s' % soft)
106 print('INFO: Open files hard limit: %s' % hard)
107
Rico Windb4621c12017-08-28 12:48:53 +0200108def Main():
Rico Wind63a13562018-12-10 14:31:02 +0100109 (options, args) = ParseOptions()
Rico Wind089ca042019-03-06 13:27:25 +0000110 if not utils.is_bot() and not options.dry_run:
Søren Gjessec425e6a2019-06-28 11:41:14 +0200111 raise Exception('You are not a bot, don\'t archive builds. '
112 + 'Use --dry-run to test locally')
Søren Gjessec425e6a2019-06-28 11:41:14 +0200113 if (options.dry_run_output and
114 (not os.path.exists(options.dry_run_output) or
115 not os.path.isdir(options.dry_run_output))):
116 raise Exception(options.dry_run_output
117 + ' does not exist or is not a directory')
Søren Gjesse1b035b32022-08-19 08:53:57 +0200118 if (options.skip_gradle_build and not options.dry_run):
119 raise Exception('Using --skip-gradle-build only supported with --dry-run')
Tamas Kenez180be092018-12-05 15:23:06 +0100120
Morten Krogh-Jespersenfe0d7e12020-01-31 08:50:17 +0100121 if utils.is_bot() and not utils.IsWindows():
Rico Wind7219bb02019-03-18 08:30:12 +0100122 SetRLimitToMax()
Morten Krogh-Jespersenfe0d7e12020-01-31 08:50:17 +0100123 if not utils.IsWindows():
124 PrintResourceInfo()
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200125
Yohann Roussel73f58e12017-10-13 17:33:14 +0200126 with utils.TempDir() as temp:
Rico Wind257044c2019-11-22 08:21:21 +0100127
Yohann Roussel73f58e12017-10-13 17:33:14 +0200128 version_file = os.path.join(temp, 'r8-version.properties')
129 with open(version_file,'w') as version_writer:
130 version_writer.write('version.sha=' + GetGitHash() + '\n')
Søren Gjessec425e6a2019-06-28 11:41:14 +0200131 if not os.environ.get('SWARMING_BOT_ID') and not options.dry_run:
132 raise Exception('Environment variable SWARMING_BOT_ID not set')
133
134 releaser = \
135 ("<local developer build>" if options.dry_run
136 else 'releaser=go/r8bot ('
137 + os.environ.get('SWARMING_BOT_ID') + ')\n')
138 version_writer.write(releaser)
Yohann Roussel73f58e12017-10-13 17:33:14 +0200139 version_writer.write('version-file.version.code=1\n')
140
Rico Windcdc39b62022-04-08 12:37:57 +0200141 # Create maven release which uses a build that exclude dependencies.
Rico Windcdc39b62022-04-08 12:37:57 +0200142 create_maven_release.generate_r8_maven_zip(
Søren Gjesse1b035b32022-08-19 08:53:57 +0200143 utils.MAVEN_ZIP,
144 version_file=version_file,
145 skip_gradle_build=options.skip_gradle_build)
146 create_maven_release.generate_r8_maven_zip(
147 utils.MAVEN_ZIP_LIB,
148 is_r8lib=True,
149 version_file=version_file,
150 skip_gradle_build=options.skip_gradle_build)
Rico Windcdc39b62022-04-08 12:37:57 +0200151
152 # Generate and copy a full build without dependencies.
Søren Gjesse1b035b32022-08-19 08:53:57 +0200153 if (not options.skip_gradle_build):
154 gradle.RunGradleExcludeDeps([utils.R8, utils.R8_SRC])
Rico Windcdc39b62022-04-08 12:37:57 +0200155 shutil.copyfile(utils.R8_JAR, utils.R8_FULL_EXCLUDE_DEPS_JAR)
156
157 # Ensure all archived artifacts has been built before archiving.
158 # The target tasks postfixed by 'lib' depend on the actual target task so
159 # building it invokes the original task first.
160 # The '-Pno_internal' flag is important because we generate the lib based on uses in tests.
Søren Gjesse1b035b32022-08-19 08:53:57 +0200161 if (not options.skip_gradle_build):
162 gradle.RunGradle([
163 utils.R8,
164 utils.R8LIB,
165 utils.R8LIB_NO_DEPS,
166 utils.R8RETRACE,
167 utils.R8RETRACE_NO_DEPS,
168 utils.LIBRARY_DESUGAR_CONVERSIONS,
Ian Zernyf13d18f2023-05-24 12:50:37 +0200169 utils.KEEPANNO_ANNOTATIONS_TARGET,
Søren Gjesse1b035b32022-08-19 08:53:57 +0200170 '-Pno_internal'
171 ])
Rico Windcdc39b62022-04-08 12:37:57 +0200172
173 # Create maven release of the desuage_jdk_libs configuration. This require
174 # an r8.jar with dependencies to have been built.
175 create_maven_release.generate_desugar_configuration_maven_zip(
176 utils.DESUGAR_CONFIGURATION_MAVEN_ZIP,
177 utils.DESUGAR_CONFIGURATION,
Søren Gjessee18fa6e2022-06-24 15:14:53 +0200178 utils.DESUGAR_IMPLEMENTATION,
179 utils.LIBRARY_DESUGAR_CONVERSIONS_LEGACY_ZIP)
Rico Windcdc39b62022-04-08 12:37:57 +0200180 create_maven_release.generate_desugar_configuration_maven_zip(
Søren Gjessee18fa6e2022-06-24 15:14:53 +0200181 utils.DESUGAR_CONFIGURATION_JDK11_LEGACY_MAVEN_ZIP,
Rico Windcdc39b62022-04-08 12:37:57 +0200182 utils.DESUGAR_CONFIGURATION_JDK11_LEGACY,
Søren Gjessee18fa6e2022-06-24 15:14:53 +0200183 utils.DESUGAR_IMPLEMENTATION_JDK11,
184 utils.LIBRARY_DESUGAR_CONVERSIONS_LEGACY_ZIP)
Rico Windcdc39b62022-04-08 12:37:57 +0200185
Søren Gjesse2b047692022-08-19 16:34:38 +0200186 create_maven_release.generate_desugar_configuration_maven_zip(
187 utils.DESUGAR_CONFIGURATION_JDK11_MINIMAL_MAVEN_ZIP,
188 utils.DESUGAR_CONFIGURATION_JDK11_MINIMAL,
189 utils.DESUGAR_IMPLEMENTATION_JDK11,
190 utils.LIBRARY_DESUGAR_CONVERSIONS_ZIP)
191 create_maven_release.generate_desugar_configuration_maven_zip(
192 utils.DESUGAR_CONFIGURATION_JDK11_MAVEN_ZIP,
193 utils.DESUGAR_CONFIGURATION_JDK11,
194 utils.DESUGAR_IMPLEMENTATION_JDK11,
195 utils.LIBRARY_DESUGAR_CONVERSIONS_ZIP)
196 create_maven_release.generate_desugar_configuration_maven_zip(
197 utils.DESUGAR_CONFIGURATION_JDK11_NIO_MAVEN_ZIP,
198 utils.DESUGAR_CONFIGURATION_JDK11_NIO,
199 utils.DESUGAR_IMPLEMENTATION_JDK11,
200 utils.LIBRARY_DESUGAR_CONVERSIONS_ZIP)
201
Rico Windcdc39b62022-04-08 12:37:57 +0200202 version = GetVersion()
203 is_main = IsMain(version)
204 if is_main:
205 # On main we use the git hash to archive with
206 print('On main, using git hash for archiving')
207 version = GetGitHash()
208
209 destination = GetVersionDestination('gs://', version, is_main)
210 if utils.cloud_storage_exists(destination) and not options.dry_run:
211 raise Exception('Target archive directory %s already exists' % destination)
212
213 # Create pom file for our maven repository that we build for testing.
214 default_pom_file = os.path.join(temp, 'r8.pom')
215 create_maven_release.write_default_r8_pom_file(default_pom_file, version)
216
Tamas Kenez03ab76f2018-12-07 14:33:25 +0100217 for file in [
Tamas Kenez03ab76f2018-12-07 14:33:25 +0100218 utils.R8_JAR,
219 utils.R8LIB_JAR,
Tamas Kenez54b939a2018-12-07 15:55:26 +0100220 utils.R8LIB_JAR + '.map',
Morten Krogh-Jesperseneda55812023-04-25 09:26:07 +0200221 utils.R8LIB_JAR + '_map.zip',
Tamas Kenez03ab76f2018-12-07 14:33:25 +0100222 utils.R8_SRC_JAR,
223 utils.R8_FULL_EXCLUDE_DEPS_JAR,
224 utils.R8LIB_EXCLUDE_DEPS_JAR,
Tamas Kenez54b939a2018-12-07 15:55:26 +0100225 utils.R8LIB_EXCLUDE_DEPS_JAR + '.map',
Morten Krogh-Jesperseneda55812023-04-25 09:26:07 +0200226 utils.R8LIB_EXCLUDE_DEPS_JAR + '_map.zip',
Morten Krogh-Jespersen98ee89a2021-10-25 20:59:02 +0200227 utils.R8RETRACE_JAR,
Morten Krogh-Jespersend997f242023-05-11 12:15:10 +0200228 utils.R8RETRACE_JAR + '.map',
229 utils.R8RETRACE_JAR + '_map.zip',
Morten Krogh-Jespersen98ee89a2021-10-25 20:59:02 +0200230 utils.R8RETRACE_EXCLUDE_DEPS_JAR,
Morten Krogh-Jespersend997f242023-05-11 12:15:10 +0200231 utils.R8RETRACE_EXCLUDE_DEPS_JAR + '.map',
232 utils.R8RETRACE_EXCLUDE_DEPS_JAR + '_map.zip',
Tamas Kenez03ab76f2018-12-07 14:33:25 +0100233 utils.MAVEN_ZIP,
Rico Wind8fc8bfa2019-03-22 09:57:36 +0100234 utils.MAVEN_ZIP_LIB,
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200235 utils.DESUGAR_CONFIGURATION,
236 utils.DESUGAR_CONFIGURATION_MAVEN_ZIP,
Søren Gjessee18fa6e2022-06-24 15:14:53 +0200237 utils.DESUGAR_CONFIGURATION_JDK11_LEGACY,
238 utils.DESUGAR_CONFIGURATION_JDK11_LEGACY_MAVEN_ZIP,
Søren Gjesse2b047692022-08-19 16:34:38 +0200239 utils.DESUGAR_CONFIGURATION_JDK11_MINIMAL_MAVEN_ZIP,
240 utils.DESUGAR_CONFIGURATION_JDK11_MAVEN_ZIP,
241 utils.DESUGAR_CONFIGURATION_JDK11_NIO_MAVEN_ZIP,
Ian Zernyf13d18f2023-05-24 12:50:37 +0200242 utils.KEEPANNO_ANNOTATIONS_JAR,
Tamas Kenez03ab76f2018-12-07 14:33:25 +0100243 utils.GENERATED_LICENSE,
244 ]:
Mads Agerac794132017-11-09 11:38:45 +0100245 file_name = os.path.basename(file)
Yohann Roussel73f58e12017-10-13 17:33:14 +0200246 tagged_jar = os.path.join(temp, file_name)
Mads Agerac794132017-11-09 11:38:45 +0100247 shutil.copyfile(file, tagged_jar)
Mads Agerb10c07f2017-11-27 13:25:52 +0100248 if file_name.endswith('.jar') and not file_name.endswith('-src.jar'):
Mads Agerafc0cda2017-11-27 13:04:27 +0100249 with zipfile.ZipFile(tagged_jar, 'a') as zip:
250 zip.write(version_file, os.path.basename(version_file))
Rico Wind1b52acf2021-03-21 12:36:55 +0100251 destination = GetUploadDestination(version, file_name, is_main)
Yohann Roussel73f58e12017-10-13 17:33:14 +0200252 print('Uploading %s to %s' % (tagged_jar, destination))
Rico Wind63a13562018-12-10 14:31:02 +0100253 if options.dry_run:
Søren Gjessec425e6a2019-06-28 11:41:14 +0200254 if options.dry_run_output:
255 dry_run_destination = os.path.join(options.dry_run_output, file_name)
256 print('Dry run, not actually uploading. Copying to '
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200257 + dry_run_destination)
Søren Gjessec425e6a2019-06-28 11:41:14 +0200258 shutil.copyfile(tagged_jar, dry_run_destination)
259 else:
260 print('Dry run, not actually uploading')
Rico Wind63a13562018-12-10 14:31:02 +0100261 else:
262 utils.upload_file_to_cloud_storage(tagged_jar, destination)
Rico Wind1b52acf2021-03-21 12:36:55 +0100263 print('File available at: %s' % GetUrl(version, file_name, is_main))
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200264
265 # Upload R8 to a maven compatible location.
Rico Windc0b16382018-05-17 13:23:43 +0200266 if file == utils.R8_JAR:
Søren Gjesse1c115b52019-08-14 12:43:57 +0200267 maven_dst = GetUploadDestination(utils.get_maven_path('r8', version),
Rico Wind1b52acf2021-03-21 12:36:55 +0100268 'r8-%s.jar' % version, is_main)
Rico Wind257044c2019-11-22 08:21:21 +0100269 maven_pom_dst = GetUploadDestination(
270 utils.get_maven_path('r8', version),
Rico Wind1b52acf2021-03-21 12:36:55 +0100271 'r8-%s.pom' % version, is_main)
Rico Wind63a13562018-12-10 14:31:02 +0100272 if options.dry_run:
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200273 print('Dry run, not actually creating maven repo for R8')
Rico Wind63a13562018-12-10 14:31:02 +0100274 else:
275 utils.upload_file_to_cloud_storage(tagged_jar, maven_dst)
Rico Wind257044c2019-11-22 08:21:21 +0100276 utils.upload_file_to_cloud_storage(default_pom_file, maven_pom_dst)
Rico Wind1b52acf2021-03-21 12:36:55 +0100277 print('Maven repo root available at: %s' % GetMavenUrl(is_main))
Rico Windc0b16382018-05-17 13:23:43 +0200278
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200279 # Upload desugar_jdk_libs configuration to a maven compatible location.
280 if file == utils.DESUGAR_CONFIGURATION:
Rico Wind92f796f2020-08-25 14:36:18 +0200281 jar_basename = 'desugar_jdk_libs_configuration.jar'
282 jar_version_name = 'desugar_jdk_libs_configuration-%s.jar' % version
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200283 maven_dst = GetUploadDestination(
284 utils.get_maven_path('desugar_jdk_libs_configuration', version),
Rico Wind1b52acf2021-03-21 12:36:55 +0100285 jar_version_name, is_main)
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200286
287 with utils.TempDir() as tmp_dir:
Rico Wind92f796f2020-08-25 14:36:18 +0200288 desugar_jdk_libs_configuration_jar = os.path.join(tmp_dir,
289 jar_version_name)
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200290 create_maven_release.generate_jar_with_desugar_configuration(
Søren Gjesse17fc67d2019-12-04 14:50:17 +0100291 utils.DESUGAR_CONFIGURATION,
Søren Gjessedd1f8152020-10-30 13:00:01 +0100292 utils.DESUGAR_IMPLEMENTATION,
Søren Gjesse17fc67d2019-12-04 14:50:17 +0100293 utils.LIBRARY_DESUGAR_CONVERSIONS_ZIP,
294 desugar_jdk_libs_configuration_jar)
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200295
296 if options.dry_run:
297 print('Dry run, not actually creating maven repo for '
298 + 'desugar configuration.')
Søren Gjesse706f7552019-09-23 13:34:58 +0200299 if options.dry_run_output:
300 shutil.copyfile(
301 desugar_jdk_libs_configuration_jar,
Rico Wind92f796f2020-08-25 14:36:18 +0200302 os.path.join(options.dry_run_output, jar_version_name))
Søren Gjesse6e5e5842019-09-03 08:48:30 +0200303 else:
304 utils.upload_file_to_cloud_storage(
305 desugar_jdk_libs_configuration_jar, maven_dst)
Rico Wind1b52acf2021-03-21 12:36:55 +0100306 print('Maven repo root available at: %s' % GetMavenUrl(is_main))
Rico Wind92f796f2020-08-25 14:36:18 +0200307 # Also archive the jar as non maven destination for Google3
308 jar_destination = GetUploadDestination(
Rico Wind1b52acf2021-03-21 12:36:55 +0100309 version, jar_basename, is_main)
Rico Wind92f796f2020-08-25 14:36:18 +0200310 utils.upload_file_to_cloud_storage(
311 desugar_jdk_libs_configuration_jar, jar_destination)
312
Søren Gjessee78b1652022-06-30 12:38:36 +0200313 # TODO(b/237636871): Refactor this to avoid the duplication of what is above.
Søren Gjessee18fa6e2022-06-24 15:14:53 +0200314 # Upload desugar_jdk_libs JDK-11 legacyconfiguration to a maven compatible location.
315 if file == utils.DESUGAR_CONFIGURATION_JDK11_LEGACY:
316 jar_basename = 'desugar_jdk_libs_configuration.jar'
317 jar_version_name = 'desugar_jdk_libs_configuration-%s-jdk11-legacy.jar' % version
318 maven_dst = GetUploadDestination(
319 utils.get_maven_path('desugar_jdk_libs_configuration', version),
320 jar_version_name, is_main)
321
322 with utils.TempDir() as tmp_dir:
323 desugar_jdk_libs_configuration_jar = os.path.join(tmp_dir,
324 jar_version_name)
325 create_maven_release.generate_jar_with_desugar_configuration(
326 utils.DESUGAR_CONFIGURATION_JDK11_LEGACY,
327 utils.DESUGAR_IMPLEMENTATION_JDK11,
328 utils.LIBRARY_DESUGAR_CONVERSIONS_ZIP,
329 desugar_jdk_libs_configuration_jar)
330
331 if options.dry_run:
332 print('Dry run, not actually creating maven repo for '
333 + 'desugar configuration.')
334 if options.dry_run_output:
335 shutil.copyfile(
336 desugar_jdk_libs_configuration_jar,
337 os.path.join(options.dry_run_output, jar_version_name))
338 else:
339 utils.upload_file_to_cloud_storage(
340 desugar_jdk_libs_configuration_jar, maven_dst)
341 print('Maven repo root available at: %s' % GetMavenUrl(is_main))
342 # Also archive the jar as non maven destination for Google3
343 jar_destination = GetUploadDestination(
344 version, jar_basename, is_main)
345 utils.upload_file_to_cloud_storage(
346 desugar_jdk_libs_configuration_jar, jar_destination)
Rico Windb4621c12017-08-28 12:48:53 +0200347
348if __name__ == '__main__':
349 sys.exit(Main())