Skip to content

Commit 4027af7

Browse files
committed
Fix issues with removing non-latest patch versions
1 parent eafb1ea commit 4027af7

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

src/main/groovy/org/gradle/android/AndroidCacheFixPlugin.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class AndroidCacheFixPlugin implements Plugin<Project> {
3939
// some of the classes the workarounds reference. In such a case, we can throw a friendlier "not supported"
4040
// error instead of a ClassDefNotFound.
4141
static {
42-
if (isSupportedAndroidVersion()) {
42+
if (isMaybeSupportedAndroidVersion()) {
4343
WORKAROUNDS.addAll(
4444
new MergeJavaResourcesWorkaround(),
4545
new MergeNativeLibsWorkaround(),
@@ -55,7 +55,7 @@ class AndroidCacheFixPlugin implements Plugin<Project> {
5555

5656
private static boolean isMaybeSupportedAndroidVersion() {
5757
return Boolean.getBoolean(IGNORE_VERSION_CHECK_PROPERTY) ||
58-
(CURRENT_ANDROID_VERSION < SUPPORTED_ANDROID_VERSIONS.max() && CURRENT_ANDROID_VERSION > SUPPORTED_ANDROID_VERSIONS.min())
58+
(CURRENT_ANDROID_VERSION <= Versions.latestAndroidVersion() && CURRENT_ANDROID_VERSION >= Versions.earliestMaybeSupportedAndroidVersion())
5959
}
6060

6161
@Override

src/main/groovy/org/gradle/android/Versions.groovy

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import org.gradle.util.VersionNumber
1111

1212
@CompileStatic(TypeCheckingMode.SKIP)
1313
class Versions {
14-
public static final String OMIT_VERSION_PROPERTY = "org.gradle.android.cache-fix.omitVersion"
15-
1614
static final VersionNumber PLUGIN_VERSION;
1715
static final Set<GradleVersion> SUPPORTED_GRADLE_VERSIONS
1816
static final Set<VersionNumber> SUPPORTED_ANDROID_VERSIONS
@@ -24,9 +22,7 @@ class Versions {
2422

2523
def builder = ImmutableMultimap.<VersionNumber, GradleVersion>builder()
2624
versions.supportedVersions.each { String androidVersion, List<String> gradleVersions ->
27-
if (!shouldOmitVersion(androidVersion)) {
28-
builder.putAll(android(androidVersion), gradleVersions.collect { gradle(it) })
29-
}
25+
builder.putAll(android(androidVersion), gradleVersions.collect { gradle(it) })
3026
}
3127
def matrix = builder.build()
3228

@@ -35,10 +31,6 @@ class Versions {
3531
SUPPORTED_GRADLE_VERSIONS = ImmutableSortedSet.copyOf(matrix.values())
3632
}
3733

38-
private static boolean shouldOmitVersion(String androidVersion) {
39-
return System.getProperty(OMIT_VERSION_PROPERTY) == androidVersion
40-
}
41-
4234
static VersionNumber android(String version) {
4335
VersionNumber.parse(version)
4436
}
@@ -47,6 +39,11 @@ class Versions {
4739
GradleVersion.version(version)
4840
}
4941

42+
static VersionNumber earliestMaybeSupportedAndroidVersion() {
43+
VersionNumber earliestSupported = SUPPORTED_ANDROID_VERSIONS.min()
44+
return new VersionNumber(earliestSupported.major, earliestSupported.minor, 0, null)
45+
}
46+
5047
static VersionNumber latestAndroidVersion() {
5148
return SUPPORTED_ANDROID_VERSIONS.max()
5249
}

src/test/groovy/org/gradle/android/WorkaroundTest.groovy

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@ class WorkaroundTest extends Specification {
1313
where:
1414
androidVersion | expectedWorkarounds
1515
"4.2.0-alpha04" | ['RoomSchemaLocation', 'CompileLibraryResources']
16-
"4.1.0-beta04" | ['RoomSchemaLocation', 'CompileLibraryResources']
17-
"4.0.0" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation', 'CompileLibraryResources']
18-
"3.6.2" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation']
19-
"3.6.1" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation']
20-
"3.6.0" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation']
21-
"3.5.3" | ['MergeJavaResources', 'RoomSchemaLocation']
22-
"3.5.2" | ['MergeJavaResources', 'RoomSchemaLocation']
23-
"3.5.1" | ['MergeJavaResources', 'RoomSchemaLocation']
24-
"3.5.0" | ['MergeJavaResources', 'RoomSchemaLocation']
16+
"4.1.0-beta03" | ['RoomSchemaLocation', 'CompileLibraryResources']
17+
"4.0.1" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation', 'CompileLibraryResources']
18+
"3.6.4" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation']
19+
"3.5.4" | ['MergeJavaResources', 'RoomSchemaLocation']
2520
}
2621
}

0 commit comments

Comments
 (0)