-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Error in compileJava task after upgrading to 4.2.1 #3249
Comments
Hi @cballesteros. Thank you for reporting. Could you provide an example build script where this problem appears? Could you point me to the |
Thanks @wolfs, I'm using this plugin 2.5.0 version. I tried with the latest version but the same error appear. Let me prepare a simple project to reproduce the issue. |
@wolfs I just updated the issue description with an example. Thank you! |
@cballesteros Thank you for your example! The problem you are experiencing is due to a new feature of Gradle 4.2.1: Safer handling of stale output files.
As a consequence
This problems can be fixed easily. If you declare the output directories of the
If you declare some inputs for the task, too, then you will even benefit from incremental build! For more information about inputs and outputs see the userguide chapter about incremental build.
I hope that clarifies things a bit. I am closing this issue as I consider it not being a bug of Gradle. Please re-open if you think otherwise or ask on the forum if you need more help solving your use case. |
@wolfs I applied the suggested changes and everything works pretty fine for me! I will learn more about inputs and outputs. Thank you! |
Expected Behavior
compileJava task should use generated java beans in buildDir.
Current Behavior
compileJava Task cleans the buildDir folder before compile. It produces a "package does not exists" error since source code uses generated code in the buildDir.
Context
I'm using xmlBeans plugin to generates java beans. Also I'm using java plugin to compile the source code. The task compileJava from java plugin dependson task compileXmlSchemas from xmlBeans plugin. Since the generated beans are used in the source code, a "package does not exists" error appear in compilation time. With gradle 2.4, 3.5 and 4.0 everything works fine but after upgrading to 4.2.1 this error blocks the compileJava task.
I found that recently you introduce a change to Cleanup directories when sources become empty (here). I think that these change will clean the buildDir folder before compileJava execution. Additionally, I found this line in the logs:
16:16:15.821 [INFO] [org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter] Deleting stale output file: D:\main-project\java\sub-project\build\gen-classes\xmlbeans
I need that the gen-classes\xmlbeans folder stay there for compileJava execution.
How to reproduce
You can find a gradle sample using xmlBeans plugin in this repo https://github.com/cballesteros/xmlbeans-sample
Just execute compileJava task using Gradle 4.0 or lower and 4.2.1. With 4.0 or lower everything should work fine but in 4.2.1 version a "package does not exists" error appear.
The text was updated successfully, but these errors were encountered: