I have the following project structure:
application/build.gradle:
apply plugin: 'java'
settings.gradle:
include ':application'
build.gradle:
task custom << {
project.tasks.getByName("build").execute()
}
So I want to execute task "build" inside task "custom". But when I run "gradle custom" the result is:
:custom FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/tmp/test/build.gradle' line: 3
* What went wrong:
Execution failed for task ':custom'.
> Task with name 'build' not found in root project 'test'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.183 secs
How I can execute the task "build" inside task "custom" ?
Gradle ensures that all task dependencies and ordering rules are honored when executing tasks, so that the task is executed after all of its dependencies and any "must run after" tasks have been executed. Dependencies to a task are controlled using Task. dependsOn(java. lang.
Each project is made up of different tasks and a task is a piece of work which a build performs. The task might be compiling some classes, storing class files into separate target folder, creating JAR, generating Javadoc, or publishing some achieves to the repositories.
You can do gradle -Dtest. single=ClassUnderTestTest test if you want to test single class or use regexp like gradle -Dtest. single=ClassName*Test test you can find more examples of filtering classes for tests under this link.
You cannot. Task execution is declarative, not imperative. Tasks depend on each other, they do not execute each other. (Also, since you don't apply the Java (base) plugin in the root build script, the root project doesn't have a build
task.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With