Version 1.5.68
Cherry-pick: Update archive script
CL: https://r8-review.googlesource.com/c/r8/+/40140
Bug: 136241862
Change-Id: I59d3d42d7cbd1131112cbb3ef3337c9ad3bf0321
diff --git a/src/main/java/com/android/tools/r8/Version.java b/src/main/java/com/android/tools/r8/Version.java
index 6d50dfe..2f166c3 100644
--- a/src/main/java/com/android/tools/r8/Version.java
+++ b/src/main/java/com/android/tools/r8/Version.java
@@ -11,7 +11,7 @@
// This field is accessed from release scripts using simple pattern matching.
// Therefore, changing this field could break our release scripts.
- public static final String LABEL = "1.5.67";
+ public static final String LABEL = "1.5.68";
private Version() {
}
diff --git a/tools/archive.py b/tools/archive.py
index 909faa2..e6b9b37 100755
--- a/tools/archive.py
+++ b/tools/archive.py
@@ -24,6 +24,9 @@
result.add_option('--dry-run', '--dry_run',
help='Build only, no upload.',
default=False, action='store_true')
+ result.add_option('--dry-run-output', '--dry_run_output',
+ help='Output directory for \'build only, no upload\'.',
+ type="string", action="store")
return result.parse_args()
def GetToolVersion(jar_path):
@@ -107,7 +110,15 @@
def Main():
(options, args) = ParseOptions()
if not utils.is_bot() and not options.dry_run:
- raise Exception('You are not a bot, don\'t archive builds')
+ raise Exception('You are not a bot, don\'t archive builds. '
+ + 'Use --dry-run to test locally')
+ if options.dry_run_output and not options.dry_run:
+ raise Exception('Option --dry-run-output require --dry-run.')
+ if (options.dry_run_output and
+ (not os.path.exists(options.dry_run_output) or
+ not os.path.isdir(options.dry_run_output))):
+ raise Exception(options.dry_run_output
+ + ' does not exist or is not a directory')
if utils.is_bot():
SetRLimitToMax()
@@ -149,8 +160,14 @@
version_file = os.path.join(temp, 'r8-version.properties')
with open(version_file,'w') as version_writer:
version_writer.write('version.sha=' + GetGitHash() + '\n')
- version_writer.write(
- 'releaser=go/r8bot (' + os.environ.get('SWARMING_BOT_ID') + ')\n')
+ if not os.environ.get('SWARMING_BOT_ID') and not options.dry_run:
+ raise Exception('Environment variable SWARMING_BOT_ID not set')
+
+ releaser = \
+ ("<local developer build>" if options.dry_run
+ else 'releaser=go/r8bot ('
+ + os.environ.get('SWARMING_BOT_ID') + ')\n')
+ version_writer.write(releaser)
version_writer.write('version-file.version.code=1\n')
for file in [
@@ -181,7 +198,13 @@
destination = GetUploadDestination(version, file_name, is_master)
print('Uploading %s to %s' % (tagged_jar, destination))
if options.dry_run:
- print('Dry run, not actually uploading')
+ if options.dry_run_output:
+ dry_run_destination = os.path.join(options.dry_run_output, file_name)
+ print('Dry run, not actually uploading. Copying to '
+ + dry_run_destination)
+ shutil.copyfile(tagged_jar, dry_run_destination)
+ else:
+ print('Dry run, not actually uploading')
else:
utils.upload_file_to_cloud_storage(tagged_jar, destination)
print('File available at: %s' % GetUrl(version, file_name, is_master))
diff --git a/tools/create_maven_release.py b/tools/create_maven_release.py
index 72098a3..aa4c3f8 100755
--- a/tools/create_maven_release.py
+++ b/tools/create_maven_release.py
@@ -23,6 +23,14 @@
<version>$version</version>
</dependency>""")
+LICENSETEMPLATE = Template(
+"""
+ <license>
+ <name>$name</name>
+ <url>$url</url>
+ <distribution>repo</distribution>
+ </license>""")
+
POMTEMPLATE = Template(
"""<project
xmlns="http://maven.apache.org/POM/4.0.0"
@@ -43,7 +51,7 @@
<name>BSD-3-Clause</name>
<url>https://opensource.org/licenses/BSD-3-Clause</url>
<distribution>repo</distribution>
- </license>
+ </license>$library_licenses
</licenses>
<dependencies>$dependencies
</dependencies>
@@ -82,25 +90,35 @@
raise Exception('Unable to determine version.')
def generate_library_licenses():
+ artifact_prefix = '- artifact: '
license_prefix = 'license: '
licenses = []
license_url_prefix = 'licenseUrl: '
license_urls = []
with open('LIBRARY-LICENSE', 'r') as file:
+ name = None
+ url = None
for line in file:
trimmed = line.strip()
+ # Collect license name and url for each artifact. They must come in
+ # pairs for each artifact.
+ if trimmed.startswith(artifact_prefix):
+ assert not name
+ assert not url
if trimmed.startswith(license_prefix):
- # Assert checking that licenses come in name/url pairs.
- assert len(licenses) == len(license_urls)
name = trimmed[len(license_prefix):]
- if not name in licenses:
- licenses.append(name)
if trimmed.startswith(license_url_prefix):
url = trimmed[len(license_url_prefix):]
- if not url in license_urls:
+ # Licenses come in name/url pairs. When both are present add pair
+ # to collected licenses if either name or url has not been recorded yet,
+ # as some licenses with slightly different names point to the same url.
+ if name and url:
+ if (not name in licenses) or (not url in license_urls):
+ licenses.append(name)
license_urls.append(url)
- # Assert checking that licenses come in name/url pairs.
- assert len(licenses) == len(license_urls)
+ name = None
+ url = None
+ assert len(licenses) == len(license_urls)
result = ''
for i in range(len(licenses)):
name = licenses[i]
@@ -176,8 +194,9 @@
def write_pom_file(version, pom_file, exclude_dependencies):
dependencies = "" if exclude_dependencies else generate_dependencies()
+ library_licenses = generate_library_licenses() if exclude_dependencies else ""
version_pom = POMTEMPLATE.substitute(
- version=version, dependencies=dependencies)
+ version=version, dependencies=dependencies, library_licenses=library_licenses)
with open(pom_file, 'w') as file:
file.write(version_pom)