Update support for targeted shrinking rules in JARs
Remove the specific version used for builds from main. Instead
use a version which is newer that any specific version.
Bug: b/267382635
Change-Id: I0559fc90bfa796d7985d0973a7040556dbe8c7a4
diff --git a/src/main/java/com/android/tools/r8/R8Command.java b/src/main/java/com/android/tools/r8/R8Command.java
index b4cca13..ee35e7f 100644
--- a/src/main/java/com/android/tools/r8/R8Command.java
+++ b/src/main/java/com/android/tools/r8/R8Command.java
@@ -700,15 +700,17 @@
Version.getPatchVersion())
: fakeCompilerVersion;
if (compilerVersion.getMajor() < 0) {
- compilerVersion = SemanticVersion.parse(Version.ACTIVE_DEV_VERSION);
+ compilerVersion =
+ SemanticVersion.create(
+ Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
reporter.warning(
"Running R8 version "
+ Version.getVersionString()
- + " which cannot be represented as a semantic version. Using"
- + " version "
- + compilerVersion
- + " for selecting Proguard configurations embedded under"
- + " META-INF/");
+ + ", which cannot be represented as a semantic version. Using"
+ + " an artificial version newer than any known version for selecting"
+ + " Proguard configurations embedded under META-INF/. This means that"
+ + " all rules with a '-max-' qualifier will be excluded and all rules"
+ + " with a -min- qualifier will be included.");
}
return compilerVersion;
});
diff --git a/src/main/java/com/android/tools/r8/Version.java b/src/main/java/com/android/tools/r8/Version.java
index 041bc2c..b725385 100644
--- a/src/main/java/com/android/tools/r8/Version.java
+++ b/src/main/java/com/android/tools/r8/Version.java
@@ -15,11 +15,6 @@
// Therefore, changing this field could break our release scripts.
public static final String LABEL = "main";
- // The prefix of the active dev version line being worked on from this branch. This is used in the
- // few cases where the compiler makes decisions based in the compiler version and where version
- // 'main' cannot be used.
- public static final String ACTIVE_DEV_VERSION = "8.1.0";
-
private Version() {
}
diff --git a/src/test/java/com/android/tools/r8/shaking/LibraryProvidedProguardRulesR8SpecificTest.java b/src/test/java/com/android/tools/r8/shaking/LibraryProvidedProguardRulesR8SpecificTest.java
index c3fd851..419ebfc 100644
--- a/src/test/java/com/android/tools/r8/shaking/LibraryProvidedProguardRulesR8SpecificTest.java
+++ b/src/test/java/com/android/tools/r8/shaking/LibraryProvidedProguardRulesR8SpecificTest.java
@@ -226,13 +226,16 @@
.filter(
allOf(
diagnosticMessage(containsString("Running R8 version main")),
- diagnosticMessage(containsString("Using version 8.1.0 for")))
+ diagnosticMessage(
+ containsString(
+ "Using an artificial version newer than any known"
+ + " version")))
::matches)
.count()))
.inspectProguardConfiguration(
configuration ->
assertEquals(
- StringUtils.lines(EXPECTED_A.trim(), EXPECTED_B.trim(), EXPECTED_C.trim()),
+ StringUtils.lines(EXPECTED_A.trim(), EXPECTED_B.trim(), EXPECTED_E.trim()),
configuration.toString()));
}
diff --git a/tools/r8_release.py b/tools/r8_release.py
index f98e24f..c799d90 100755
--- a/tools/r8_release.py
+++ b/tools/r8_release.py
@@ -325,17 +325,6 @@
sources.write(re.sub(pattern, replace, line))
-def replace_startswith(prefix, replacement, path):
- with open(path, "r") as source:
- lines = source.readlines()
- with open(path, "w") as source:
- for line in lines:
- if line.startswith(prefix):
- source.write(replacement)
- else:
- source.write(line)
-
-
def download_file(version, file, dst):
dir = 'raw' if len(version) != 40 else 'raw/main'
urllib.request.urlretrieve(
@@ -860,12 +849,6 @@
"R8_DEV_BRANCH = '%s.%s" % (str(semver.major), str(semver.minor)),
THIS_FILE_RELATIVE)
- # Update main version file with the new dev branch.
- replace_startswith(
- ' public static final String ACTIVE_DEV_VERSION = ',
- ' public static final String ACTIVE_DEV_VERSION = "' + branch_version + '.0"',
- R8_VERSION_FILE)
-
message = \
'Prepare %s for branch %s' % (THIS_FILE_RELATIVE, branch_version)
subprocess.check_call(['git', 'commit', '-a', '-m', message])