以下是hello
中的两个任务printProperties
和build.gradle
:
task('hello', {
description("Hey student! Run this one :D")
group("Our demo")
doLast({println("Hello World!")})
}
)
plugins({
id('java')
})
ext({
springVersion = "3.1.0.RELEASE"
emailNotification = "[email protected]"
})
sourceSets.all({ ext.purpose = null })
sourceSets({
main({
purpose = "production"
})
test({
purpose = "test"
})
plugin({
purpose = "production"
})
})
task('printProperties', {
doLast({
println(springVersion)
println(emailNotification)
sourceSets.matching({ it.purpose == "production" }.each({ println it.name }))
})
})
给出错误:
> startup failed:
build file '/../../build.gradle': 8:
only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed
为什么
plugins({id('java')})
给groovy脚本语法错误? 最佳答案