[英]Is there a way to define the task class outside the build.gradle?
This is just a dummy task class I implemented from https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:task_outcomes这只是我从https://docs.gradle.org/current/userguide/more_about_tasks.html#es:task_outcom 实现的虚拟任务 class
root - build.gradle根 - build.gradle
class Hello extends DefaultTask {
@Input
String dummy = "hello"
@TaskAction
void hello() {
System.out.println(dummy);
}
}
task Hellotask(type: Hello) {
dummy= 'dummy'
}
Is there any way I could move this class outside build.gradle
and just add the task type Hello
to my custom task?有什么办法可以将这个 class 移到
build.gradle
之外,然后将任务类型Hello
添加到我的自定义任务中?
For instance, move the Hello.java
to Module1
and access it from a custom task in the root build.gradle
例如,将
Hello.java
移动到Module1
并从根build.gradle
中的自定义任务访问它
root
-Module1
-Hello.java ----- the task class Hello
-build.gradle
-Module2
-build.gradle
-build.gradle
root - build.gradle根 - build.gradle
task Hellotask(type: Hello) {
dummy= 'dummy'
}
Yes, you can put the class in the buildSrc
folder.是的,您可以将 class 放在
buildSrc
文件夹中。 Gradle will automatically build this and make it available in your build. Gradle 将自动构建它并使其在您的构建中可用。
root
-Module1
-buildSrc/src/main/java/Hello.java ----- the task class Hello
-build.gradle
-Module2
-build.gradle
-build.gradle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.