Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
simonjhy opened this issue Aug 3, 2022 · 6 comments

Comments

@simonjhy
Copy link

simonjhy commented Aug 3, 2022

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.

@michel-kraemer
Copy link
Owner

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.

@simonjhy
Copy link
Author

simonjhy commented Aug 3, 2022

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.

@simonjhy
Copy link
Author

simonjhy commented Aug 4, 2022

@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.

@simonjhy
Copy link
Author

simonjhy commented Aug 10, 2022

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.

@michel-kraemer
Copy link
Owner

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

@michel-kraemer
Copy link
Owner

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants