[GRADLE-3491] Some tasks don't execute when inputs or outputs are out of date Created: 17/Jun/16  Updated: 14/Jul/16  Resolved: 20/Jun/16

Status: Resolved
Project: Gradle
Affects Version/s: 2.14
Fix Version/s: 2.14.1-rc-1

Type: Bug
Reporter: Lóránt Pintér Assignee: Lari Hotari
Resolution: Fixed Votes: 0

Attachments: Zip Archive gradle-2.14-lib-bug.zip    

 Description   

As reported by the Android team: https://code.google.com/p/android/issues/detail?id=213413

Library projects require double builds to pick up changes, bundleRelease task is erroneously UP-TO-DATE the first time around.

This only happens with Gradle 2.14 (2.14-rc-1 inclusive). Bug was observed on Android Gradle plugin 1.5.0, 2.1.0, 2.1.2, 2.2.0-alpha3.

Steps to reproduce with the attached gradle-2.14-lib-bug.zip project:

1) ./gradlew :clean :bundleRelease
2) ./gradlew :bundleRelease
3) any change to Foo.java # example: sed -i '' 's/foo/bar/' src/main/java/Foo.java
4) ./gradlew :bundleRelease <-- bundleRelease is UP-TO-DATE, this is wrong



 Comments   
Comment by Lóránt Pintér [ 17/Jun/16 ]

Reproducible with 2.14:

Incremental java compilation is an incubating feature.
:preBuild UP-TO-DATE
:preReleaseBuild UP-TO-DATE
:compileReleaseNdk UP-TO-DATE
:compileLint
:copyReleaseLint UP-TO-DATE
:mergeReleaseProguardFiles UP-TO-DATE
:packageReleaseRenderscript UP-TO-DATE
:checkReleaseManifest
:prepareReleaseDependencies
:compileReleaseRenderscript UP-TO-DATE
:generateReleaseResValues UP-TO-DATE
:generateReleaseResources UP-TO-DATE
:packageReleaseResources UP-TO-DATE
:compileReleaseAidl UP-TO-DATE
:generateReleaseBuildConfig UP-TO-DATE
:mergeReleaseShaders UP-TO-DATE
:compileReleaseShaders UP-TO-DATE
:generateReleaseAssets UP-TO-DATE
:mergeReleaseAssets UP-TO-DATE
:processReleaseManifest UP-TO-DATE
:processReleaseResources UP-TO-DATE
:generateReleaseSources UP-TO-DATE
:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:compileReleaseJavaWithJavac
Incremental compilation of 1 classes completed in 0.246 secs.
:processReleaseJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:transformClassesAndResourcesWithSyncLibJarsForRelease
:mergeReleaseJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
:bundleRelease UP-TO-DATE

BUILD SUCCESSFUL

It looks like both compileReleaseJavaWithJavac and transformClassesAndResourcesWithSyncLibJarsForRelease pick up the change correctly, but bundleRelease doesn't recognize the change in build/intermediates/bundles/release/classes.jar.

Comment by Lóránt Pintér [ 17/Jun/16 ]

I tried to track down where the problem comes from and it looks like noChanges ends up being true for bundleRelease here:

https://github.com/gradle/gradle/blob/c8143c9bcf412a2d19053b8c926c7787c1dc8087/subprojects/core/src/main/java/org/gradle/api/internal/changedetection/rules/InputFilesTaskStateChanges.java#L41-L41

Comment by Lari Hotari [ 20/Jun/16 ]

We will be releasing 2.14.1 with a fix for this issue.

Comment by Lari Hotari [ 20/Jun/16 ]

2.14.1 will be released from 2.14.x branch. The branch now contains a fix for this issue.

Comment by Sterling Greene [ 21/Jun/16 ]

Users can try a 2.14.1-nightly build:

./gradlew wrapper --gradle-version=2.14.1-20160622023453+0000
Comment by Artem Zinnatullin [ 23/Jun/16 ]

If you don't mind I'd like to test it for couple of days before you make a release.

We've faced non-100% reproducible problem with compilation Android project written in Kotlin: https://youtrack.jetbrains.com/issue/KT-12750

Comment by Artem Zinnatullin [ 23/Jun/16 ]

Build failed on first non-clean run. Issue still exists https://youtrack.jetbrains.com/issue/KT-12750, going back to Gradle 2.13 fixes it.

Comment by Sterling Greene [ 25/Jun/16 ]

Hey @artem_zin

Do you have a reproducible example project? I tried adapting one from KT-12750, but I don't see your problem. With 2.14, I'm trying to reproduce this like so...

  • Put example code into a one .kt file
  • Build
  • Change a different .kit file
  • Re-build

I'm using Kotlin stdlib and Kotlin-Gradle plugin 1.0.2 and Joda time 2.9.4.

Comment by Artem Zinnatullin [ 26/Jun/16 ]

Hey

Unfortunately, no. I can test other nightly/etc build if you want.

Probably it's problem of Kotlin-Gradle plugin, but since symptoms are pretty similar to this one I'm not sure.

Comment by Sterling Greene [ 26/Jun/16 ]

Have you tried with 2.14.1-20160622023453+0000 (from the comment above)?

Is there anything I can add to this project to reproduce the problem? https://github.com/big-guy/KT-12750

Comment by Artem Zinnatullin [ 29/Jun/16 ]

Yes I've tried 2.14.1-20160622023453+0000, issue reproduced.

I'm not sure what needs to be added to the project to reproduce the issue. Moreover it happens from time to time and looks like it depends on resources available on the computer (or it was a coincidence), I've only seen it on computers with 16GB of RAM while on 8GB machines it didn't happen. Probably Gradle daemon caches more if more memory is available.

Comment by Marcel Overdijk [ 29/Jun/16 ]

I also seem to have issue with latest Gradle 2.14 using the install task.
https://discuss.gradle.org/t/after-upgrading-to-gradle-2-14-we-get-uncheckedioexception-npe-on-install-task/18144

I'm getting the same error on 2.14.1 rc1 but not on 2.13. Might it be related?

[edit] for reference, this is https://issues.gradle.org/browse/GRADLE-3494

Comment by Cédric Champeau (Inactive) [ 07/Jul/16 ]

@artem_zin thanks for your inputs. I'm a bit confused by the report. While I can definitely reproduce the problem with the sample project that is attached in the original issue, I can't reproduce with 2.14.1-20160622023453+0000 or later. When you say you still have the problem, is it with that project, or the Kotlin compilation issue, which looks like a different one.

Thanks!

Comment by Artem Zinnatullin [ 07/Jul/16 ]

Well, it might be a Kotlin Gradle Plugin issue, lemme ping Kotlin team back so they can try 2.14.1-20160622023453+0000

Comment by Artem Zinnatullin [ 14/Jul/16 ]

Looks like Gradle 2.14 rc2 fixed issue for me.

Generated at Wed Jun 30 12:50:11 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.