Update script to build maven artifact for desugar_jdk_libs
This reverts commit 24396cba2b70c73c127258bebfe0b490095aa727, as the
custom conversion classes have moved to desugar_jdk_libs_configuration.
Also updates script to handle comments in VERSION.txt file.
Bug: 145393922
Change-Id: Ia395e61009ef6066e7bca7787bdef0e7ff32deca
diff --git a/tools/archive_desugar_jdk_libs.py b/tools/archive_desugar_jdk_libs.py
index 903f3b8..f866564 100755
--- a/tools/archive_desugar_jdk_libs.py
+++ b/tools/archive_desugar_jdk_libs.py
@@ -19,7 +19,6 @@
# repository to fetch the artifact com.android.tools:desugar_jdk_libs:1.0.0
import archive
-import defines
import git_utils
import optparse
import os
@@ -28,19 +27,6 @@
import subprocess
import sys
import utils
-import zipfile
-
-if defines.IsLinux():
- JDK8_JAVAC = os.path.join(
- defines.THIRD_PARTY, 'openjdk', 'jdk8', 'linux-x86', 'bin', 'javac')
-elif defines.IsOsX():
- JDK8_JAVAC = os.path.join(
- defines.THIRD_PARTY, 'openjdk', 'jdk8', 'darwin-x86', 'bin', 'javac')
-elif defines.IsWindows():
- raise Exception('Cannot compile using JDK8 on Windows hence cannot archive.')
-
-CONVERSION_FOLDER = os.path.join(
- defines.REPO_ROOT, 'src', 'test', 'desugaredLibraryConversions')
VERSION_FILE = 'VERSION.txt'
LIBRARY_NAME = 'desugar_jdk_libs'
@@ -64,15 +50,12 @@
def GetVersion():
with open(VERSION_FILE, 'r') as version_file:
- lines = version_file.readlines()
+ lines = [line.strip() for line in version_file.readlines()]
+ lines = [line for line in lines if not line.startswith('#')]
if len(lines) != 1:
raise Exception('Version file '
+ VERSION_FILE + ' is expected to have exactly one line')
version = lines[0].strip()
- if (version == '1.0.1'):
- raise Exception('Version file ' + VERSION_FILE + 'cannot have version 1.0.1')
- if (version == '1.0.0'):
- version = '1.0.1'
utils.check_basic_semver_version(
version, 'in version file ' + VERSION_FILE)
return version
@@ -94,13 +77,6 @@
print('File available at: %s' %
destination.replace('gs://', 'http://storage.googleapis.com/', 1))
-def GetFilesInFolder(folder):
- resulting_files = []
- for root, dirs, files in os.walk(folder):
- for name in files:
- resulting_files.append(os.path.join(root, name))
- assert len(resulting_files) > 0
- return resulting_files
def Main(argv):
(options, args) = ParseOptions(argv)
@@ -146,46 +122,12 @@
utils.PrintCmd(cmd)
subprocess.check_call(cmd)
- # Compile the stubs for conversion files compilation.
- stub_compiled_folder = os.path.join(checkout_dir, 'stubs')
- os.mkdir(stub_compiled_folder)
- all_stubs = GetFilesInFolder(os.path.join(CONVERSION_FOLDER, 'stubs'))
- cmd = [JDK8_JAVAC, '-d', stub_compiled_folder] + all_stubs
- utils.PrintCmd(cmd)
- subprocess.check_call(cmd)
-
- # Compile the conversion files.
- conversions_compiled_folder = os.path.join(checkout_dir, 'conversions')
- os.mkdir(conversions_compiled_folder)
- all_conversions = GetFilesInFolder(
- os.path.join(CONVERSION_FOLDER, 'conversions'))
- cmd = [JDK8_JAVAC, '-cp', stub_compiled_folder, '-d',
- conversions_compiled_folder] + all_conversions
- utils.PrintCmd(cmd)
- subprocess.check_call(cmd)
-
# Locate the library jar and the maven zip with the jar from the
# bazel build.
library_jar = os.path.join(
'bazel-bin', 'src', 'share', 'classes', 'java', 'libjava.jar')
maven_zip = os.path.join('bazel-bin', LIBRARY_NAME +'.zip')
- # Make a writable copy of the jar.
- jar_folder = os.path.join(checkout_dir, 'jar')
- os.mkdir(jar_folder)
- shutil.copy(library_jar, jar_folder)
- library_jar = os.path.join(jar_folder,'libjava.jar')
- os.chmod(library_jar, 0o777)
-
- # Add conversion classes into the jar.
- all_compiled_conversions = GetFilesInFolder(conversions_compiled_folder)
- with zipfile.ZipFile(library_jar, mode='a', allowZip64=True) as jar:
- for clazz in all_compiled_conversions:
- jar.write(clazz,arcname=os.path.relpath(
- clazz,
- conversions_compiled_folder),
- compress_type = zipfile.ZIP_DEFLATED)
-
storage_path = LIBRARY_NAME + '/' + version
# Upload the jar file with the library.
destination = archive.GetUploadDestination(