michel-kraemer/gradle-download-task

The 5.1.0 version download seems not work when we integrated it into our private plugin.

simonjhy opened this issue · 6 comments

Describe the bug
When I upgrade our gradle download task from 3.2.0 to 5.1.0, It always throw output result is empty file. I set src for download task, but task alwasys think the task output is uptodate. I debug the source code and confim the sourceObjects has value, I found the line 1108 codes, the cachedSources is not null but its value is empty, so ervery time the download task executed but no actually download action happended.
A clear and concise description of what the bug is. What did you expect to happen and what happened instead?
I think it should not simply check cachedSources is null, it also need to check its size.
Sample build script
we use it in our gradle plugin. here is the code link https://github.com/simonjhy/liferay-portal/blob/master/modules/sdk/gradle-plugins-workspace/src/main/java/com/liferay/gradle/plugins/workspace/configurator/RootProjectConfigurator.java#L1018
If possible, provide a sample build script to reproduce the issue.

Thanks for the pull request. I'm not sure if that's the solution to your problem though. Can you provide a small sample build script (not a large complex project) that demonstrates the issue? If possible, please also add a unit test to your pull request to make sure you're actually fixing the bug. Thanks.

I don't have simple build script to reprodcue this problem because we emebbed it into our plugins. Its really hard to reproduce it without our plugin environment. I tested it my pull in my local and it can correctly download file. I am not sure whether I can make a simple script to reproduct this issue.

@michel-kraemer our plugin defer to configurre src property after gradle evaluated root project. but we add the download task before project evaluation finished. So the cachedSources will be firstly initialized by this "cachedSources = new ArrayList<>(sourceObjects.size());", but its size is 0. I think this is the root cause of this issue.

issue-237-sample.zip
@michel-kraemer I made a sample to reproduce this issue. When you comment the line 22("def test1 = src") in build.gradle, then download will be ok. When you remove comment this line, the download will failed because I found the cachedSources will be initialized to an empty arrayList when invoke getSrc method, although sourceObjects will be added new value for src property after project was evaluated, but the cachedSources will not be null anymore and the getSources always return an empty arraylist.

Thanks. I'll have a look at it and get back to you.

Thanks for the analysis and the test project. You were on the right track!

I've fixed the issue and released a new version 5.1.1. Please try again.

(Please also consider contributing your project to the Who's using gradle-download-task thread. Thanks)