Java – gradle always executes println from any task
•
Java
I have a simple build Gradle (or build. Gradle for any task with println)
println GradLeversion.current().prettyPrint() task task1{ println 'task1 starting' }
Now, when I run $gradle build, I always see the task or printout being executed
task1 starting :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :jar :assemble :compileTestJava UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test UP-TO-DATE :check UP-TO-DATE :build BUILD SUCCESSFUL Total time: 1.291 secs
Why does the task in println always have output?
Solution
If you have the following code:
task task1 { println 'task1 starting' }
You are in the configuration phase of the task This phase runs during script evaluation If you want to print something while executing a task, you need to add an action to the task
Look like:
task task1 << { println 'task1 action' }
This code is evaluated when the task is run<< It is exactly the same as calling the dolast method on the task object You can add many actions
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码