vanniktech / gradle-android-apk-size-plugin

Gradle plugin that generates CSV files with apk size per output and variant of an apk
http://vanniktech.com
Apache License 2.0
84 stars 14 forks source link

Does not find APK files if I rewrite the variable outputs outputFile #37

Closed bricestacey closed 8 years ago

bricestacey commented 8 years ago

I modify the variant filenames, so the plugin does not find the resulting apks. Is there anything that can be done to resolve that? Here is my code.

   applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def buildSuffix = project.versionName + "-" + project.versionCode
            if (isCi) {
                output.outputFile = new File(output.outputFile.parent, applicationId + "-" + buildSuffix + "-${gitSha}.apk")
            } else {
                output.outputFile = new File(output.outputFile.parent, applicationId + "-" + buildSuffix + ".apk")
            }
        }
    }

I'm thinking somewhere here https://github.com/vanniktech/gradle-android-apk-size-plugin/blob/b7103c46f4c9eee947d89cae7ab0b93ff56cc009/src/main/groovy/com/vanniktech/android/apk/size/ApkSizePlugin.groovy#L24 we could use the variant.outputFile instead of generating the path yourself.

vanniktech commented 8 years ago

That path is just used for the output. Not for the name itself. Android gradle plugin has a archivesBaseName or something that's called like. With that you can change the apk name and that one is also the preferred way since the one you use has never been meant to be a stable API.

bricestacey commented 8 years ago

I'll give that a shot and follow up.

vanniktech commented 8 years ago

Now that I'm on my computer I can show you how I use it:

defaultConfig {
  archivesBaseName = "app-$versionName"
}

That way it'll work.

bricestacey commented 8 years ago

That fixes it up. Thanks.

bricestacey commented 8 years ago

I wasn't too happy with the resulting filenames using the archivesBaseName property so I simply moved the apply plugin: 'com.vanniktech.android.apk.size' after my code that renamed the output files and it worked great without me having to change anything.

vanniktech commented 8 years ago

Alright cool thanks for letting me know