Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 梯度任务列表_Java_Groovy_Gradle - Fatal编程技术网

Java 梯度任务列表

Java 梯度任务列表,java,groovy,gradle,Java,Groovy,Gradle,为什么下面的代码不向生成组添加任务: apply plugin: 'java' task hello << { description = 'To say hello to a task list' group = 'build' } 但以下情况确实如此: apply plugin: 'java' task hello { description = 'To say hello to a task list' group = 'build' } g

为什么下面的代码不向生成组添加任务:

apply plugin: 'java'
task hello << {
    description = 'To say hello to a task list'
    group = 'build'
}
但以下情况确实如此:

apply plugin: 'java'
task hello {
    description = 'To say hello to a task list'
    group = 'build'
}
gradle任务命令的输出:

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend
on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles classes 'main'.
clean - Deletes the build directory.
hello - To say hello to a task list
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles classes 'test'.

由于您将任务配置与任务操作混合在一起,有关详细信息,请参阅

在这段代码中:

apply plugin: 'java'
task hello << {
    description = 'To say hello to a task list'
    group = 'build'
}

因为第一个变体是以下的缩写:

task hello

hello.doLast {
    description = 'To say hello to a task list'
    group = 'build'
}
apply plugin: 'java'
task hello {
    description = 'To say hello to a task list'
    group = 'build'
}
task hello

hello.doLast {
    description = 'To say hello to a task list'
    group = 'build'
}