During build, i am facing following error.
The TaskInternal.execute() method has been deprecated and is scheduled to be removed in Gradle 5.0.
Actually, it is caused from perform a ant unittests task .
project.task(‘run_unittests’, type: TestExecutionTask, group: BUILD_TEST_GROUP, description: “Runs the target ‘unittests’ with given test execution configuration”) { taskName ‘unittests’ }
I checked this project.task(string, closure) is not planned to be deprecated. In this case, how can i avoid the exception?
I guess the task type TestExecutionTask is trying to use TaskInternal.execute for whatever task is configured. That is not supported any more.
I would be interested in the use case of the run_unittests task and the TestExecutionTask type in general. Why don’t you just run the task unittests directly from the command line?
IIUC correctly then you want to have your build logic split into different plugins. That is perfectly fine. What I am saying is that the task run_unittests could be replaced by
task run_unittests {
dependsOn 'unittests'
}
You see, no custom task type, no call to TaskInternal.execute. If you want to have a task which depends on a group of tasks (even from sub-projects) or add some dependencies from a plugin that is also not a problem.
I understand that, when running on Jenkins, you invoke Gradle. I guess you will invoke some tasks from Gradle (that is the point), and these should depend on whatever tasks you want to run. So there is still no need to use TaskInternal.execute.
Am I missing something?
Confused. Task.dependson is in gradle context. But i am talking in groovy code. I need set the dependency inside groovy code. Otherwise i need refactor too much.
I don’t understand what kind of Groovy code you are talking about? Where does your Groovy code life and how do you apply it to your build script? Could you give me a self contained example?
I have groovy based plugin. Then with 'apply plugin ‘groovy plugin name’, i include it in build.gradle file.
in side groovy code , i have following code which cause exception now.And now i have to change this code to let it be able to executed.
project.task(‘run_unittests’, type: TestExecutionTask, group: BUILD_TEST_GROUP, description: “Runs the target ‘unittests’ with given test execution configuration”) { taskName ‘unittests’ }
project.task('run_unittests', group: BUILD_TEST_GROUP, description: "Runs the target ‘unittests’ with given test execution configuration") {
dependsOn 'unittests'
}
Doesn’t that work? What is ‘unittests’? The name of another task?
I guess you are importing the ant build into Gradle.
Does my above suggestion work? Does your custom code now work?
There shouldn’t be any difference when calling methods an TaskInternal from a build script or from a Groovy class when developing a plugin. The dependsOn method should still be present.