Skip to content

Commit 9cdb6a4

Browse files
authored
Merge pull request #116 from runningcode/no/dex-file-dependencies
Make DexFileDependencies cacheable
2 parents 824b2d5 + a1d3d44 commit 9cdb6a4

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableList
99
import groovy.transform.CompileStatic
1010
import org.gradle.android.workarounds.CompileLibraryResourcesWorkaround
1111
import org.gradle.android.workarounds.CompilerArgsProcessor
12+
import org.gradle.android.workarounds.DexFileDependenciesWorkaround
1213
import org.gradle.android.workarounds.MergeJavaResourcesWorkaround
1314
import org.gradle.android.workarounds.MergeNativeLibsWorkaround
1415
import org.gradle.android.workarounds.MergeResourcesWorkaround
@@ -46,7 +47,8 @@ class AndroidCacheFixPlugin implements Plugin<Project> {
4647
new MergeNativeLibsWorkaround(),
4748
new RoomSchemaLocationWorkaround(),
4849
new CompileLibraryResourcesWorkaround(),
49-
new MergeResourcesWorkaround()
50+
new MergeResourcesWorkaround(),
51+
new DexFileDependenciesWorkaround(),
5052
)
5153
}
5254
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.gradle.android.workarounds
2+
3+
import com.android.build.gradle.internal.tasks.DexFileDependenciesTask
4+
import org.gradle.android.AndroidIssue
5+
import org.gradle.api.Project
6+
7+
@AndroidIssue(introducedIn = "3.5.0", fixedIn = [], link = "https://issuetracker.google.com/160138798")
8+
class DexFileDependenciesWorkaround implements Workaround {
9+
@Override
10+
void apply(WorkaroundContext context) {
11+
Project project = context.project
12+
project.tasks.withType(DexFileDependenciesTask).configureEach {
13+
outputs.cacheIf {true }
14+
}
15+
}
16+
17+
@Override
18+
boolean canBeApplied(Project project) {
19+
return true
20+
}
21+
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,7 @@ class CrossVersionOutcomeAndRelocationTest extends AbstractTest {
477477
}
478478

479479
static void android42xOrHigherExpectations(ExpectedOutcomeBuilder builder) {
480-
// Should be made cacheable: https://issuetracker.google.com/160138798
481-
builder.expect(':app:desugarDebugFileDependencies', SUCCESS)
482-
builder.expect(':app:desugarReleaseFileDependencies', SUCCESS)
480+
builder.expect(':app:desugarDebugFileDependencies', FROM_CACHE)
481+
builder.expect(':app:desugarReleaseFileDependencies', FROM_CACHE)
483482
}
484483
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class WorkaroundTest extends Specification {
1212
workarounds.collect { it.class.simpleName.replaceAll(/Workaround/, "") }.sort() == expectedWorkarounds.sort()
1313
where:
1414
androidVersion | expectedWorkarounds
15-
"4.2.0-alpha07" | ['RoomSchemaLocation', 'CompileLibraryResources', 'MergeResources']
16-
"4.1.0-rc01" | ['RoomSchemaLocation', 'CompileLibraryResources', 'MergeResources']
17-
"4.0.1" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation', 'CompileLibraryResources', 'MergeResources']
18-
"3.6.4" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation']
19-
"3.5.4" | ['MergeJavaResources', 'RoomSchemaLocation']
15+
"4.2.0-alpha07" | ['RoomSchemaLocation', 'CompileLibraryResources', 'MergeResources', 'DexFileDependencies']
16+
"4.1.0-rc01" | ['RoomSchemaLocation', 'CompileLibraryResources', 'MergeResources', 'DexFileDependencies']
17+
"4.0.1" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation', 'CompileLibraryResources', 'MergeResources', 'DexFileDependencies']
18+
"3.6.4" | ['MergeJavaResources', 'MergeNativeLibs', 'RoomSchemaLocation', 'DexFileDependencies']
19+
"3.5.4" | ['MergeJavaResources', 'RoomSchemaLocation', 'DexFileDependencies']
2020
}
2121
}

0 commit comments

Comments
 (0)