Gradle always executes task

android

(Metehan TOKSOY) #1

I added 3 configurations to Gradle flavors. And I add some zip dependencies to them. I unzip this zip file after preBuild. The problem is my unzip task always executes even gradle file or dependencies not changed. This unzip task takes time and I’m developing ndk application. Every time when I change my static libraries with my unzip task, gradle thinks that libraries changed so it build again.

I want to block execution of unzip task if gradle file not changed. This looks like a little cache mechanism. Here is my gradle task.

dependencies {
    compile "com.google.android.gms:play-services:9.4.0"
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:appcompat-v7:24.+'
    compile 'com.android.support:design:24.+'
    compile fileTree(dir: 'src/main/libs', include: ['*.jar'])
    alphaCompile 'my alpha release static library from private maven repository in zip type'
    betaCompile 'my beta release static library from private maven repository in zip type'
    prodCompile 'my prod release static library from private maven repository in zip type'
}


task unzip(group: "Static Libraries", description: "Unzip all static libraries") {
    doFirst{
        // get zip files from configurations
        // unzip and move static libraries to destination folder
        }
    }
}
preBuild.finalizedBy (unzip)

here is my gradle version configuration:


Gradle 2.10

Build time: 2015-12-21 21:15:04 UTC
Build number: none
Revision: 276bdcded730f53aa8c11b479986aafa58e124a6

Groovy: 2.4.4
Ant: Apache Ant™ version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_101 (Oracle Corporation 25.101-b13)
OS: Mac OS X 10.11.6 x86_64


(Stefan Oehme) #2

Your task needs to declare its inputs and outputs, otherwise Gradle can’t do up-to-date checking.


(Schalk Cronjé) #3

IN addition, if you make your unzip task of type Copy and use zipTree in the from then your input-ouput checking will be taken care of by Gradle.