Skip to content

Commit

Permalink
Revert KeepSafe#32 and remove @Input from apkOrDex
Browse files Browse the repository at this point in the history
This fixes a bug wherein the dexcount task fails if the variant's output
is renamed after the dexcount plugin is applied and prior to task execution.

This also opts dexcount out of Gradle's incremental compilation cache.  The
proximate cause of this bug is that we're holding a stale `java.io.File`
object; the cure is to instead hold a reference to the variant's output.
This doesn't work with incremental compliation, because variant output
implementations aren't `Serializable` (noted in KeepSafe#32), and Gradle depends
on task state being serializable.  This mismatch means that dexcount will
appear to randomly crash.

The least-bad solution is to just remove the task-input annotation, and
run the count task every time.  Not great, but better than not working.

Fixes KeepSafe#40 and KeepSafe#46.
  • Loading branch information
benjamin-bader committed Jan 26, 2016
1 parent 28d1210 commit d257189
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.4.1 (unreleased)
----------

* Revert pull request #32 and remove `@Input` from `apkOrDex` (issues #35 and #46)

0.4.0 (released 23 January 2016)
----------

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.getkeepsafe.dexcount
VERSION_NAME=0.4.0
VERSION_NAME=0.4.1-SNAPSHOT

POM_ARTIFACT_ID=dexcount-gradle-plugin
POM_NAME=Dexcount Gradle Plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DexMethodCountPlugin implements Plugin<Project> {
def task = project.tasks.create("count${slug}DexMethods", DexMethodCountTask)
task.description = "Outputs dex method count for ${variant.name}."
task.group = 'Reporting'
task.apkOrDexFile = output.outputFile
task.apkOrDex = output
task.mappingFile = variant.mappingFile
task.outputFile = project.file(path + '.txt')
task.summaryFile = project.file(path + '.csv')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class DexMethodCountTask extends DefaultTask {

def PackageTree tree;

@Input
def File apkOrDexFile
def BaseVariantOutput apkOrDex

@Nullable
def File mappingFile
Expand All @@ -66,7 +65,7 @@ class DexMethodCountTask extends DefaultTask {
* @return
*/
def printSummary() {
def filename = apkOrDexFile.name
def filename = apkOrDex.outputFile.name
withStyledOutput(StyledTextOutput.Style.Info) { out ->
out.println("Total methods in ${filename}: ${tree.methodCount}")
out.println("Total fields in ${filename}: ${tree.fieldCount}")
Expand Down Expand Up @@ -142,7 +141,7 @@ class DexMethodCountTask extends DefaultTask {
// If none is given, we'll get a default mapping.
def deobs = getDeobfuscator()

def dataList = DexFile.extractDexData(apkOrDexFile)
def dataList = DexFile.extractDexData(apkOrDex.outputFile)
try {
tree = new PackageTree()

Expand Down

0 comments on commit d257189

Please sign in to comment.