# Gradle always executes task

**URL:** https://discuss.gradle.org/t/gradle-always-executes-task/20772
**Category:** Help/Discuss
**Tags:** android
**Created:** [December 11, 2016, 6:07pm UTC](https://discuss.gradle.org/t/gradle-always-executes-task/20772 "2016-12-11T18:07:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![birfincankafein](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/birfincankafein/32/5779_2.png) [@birfincankafein](https://discuss.gradle.org/u/birfincankafein)
#### Post date: [December 11, 2016, 6:07pm UTC](https://discuss.gradle.org/t/gradle-always-executes-task/20772/1 "2016-12-11T18:07:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)
#### Post date: [December 11, 2016, 8:38pm UTC](https://discuss.gradle.org/t/gradle-always-executes-task/20772/2 "2016-12-11T20:38:43Z")

</div>

Your task needs to declare its [inputs and outputs](https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:up_to_date_checks), otherwise Gradle can’t do up-to-date checking.

---

<div class="post-metadata">

### Author: ![Schalk\_Cronje](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/schalk_cronje/32/6511_2.png) [@Schalk\_Cronje](https://discuss.gradle.org/u/Schalk_Cronje)
#### Post date: [December 12, 2016, 9:10am UTC](https://discuss.gradle.org/t/gradle-always-executes-task/20772/3 "2016-12-12T09:10:32Z")

</div>

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.
