나는 user guide을 통해 작업을 해왔다. 이것은 내가하고 싶은 엄청나게 단순한 것처럼 보이지만, 어떻게 작동시키는지를 알 수는 없습니다.gradle : 그루비 작업을 작성하는 방법
작업을 정의하기 위해 외부 Groovy 파일을 작성한 다음 build.gradle
에서 해당 작업을 호출하고 싶습니다. 나는 절대적으로 가지고,이 시점에서
$ gradle tasks
FAILURE: Build failed with an exception.
* Where:
Build file '/projects/gradle/build.gradle' line: 21
* What went wrong:
A problem occurred evaluating root project 'gradle'.
> Could not get unknown property 'my' for root project 'gradle' of type org.gradle.api.Project.
* 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: 3.193 secs
:
package my.package
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
class MyTask extends DefaultTask {
String greeting = 'hello from MyTask'
@TaskAction
def greet(){
println greeting
}
}
심지어 작업을 나열 할 수 없습니다 : 나는 MyTask.groovy
이 src/main/groovy/my/package
에서, 그리고
// Apply the groovy plugin to add support for Groovy
apply plugin: 'groovy'
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
// In this section you declare the dependencies for your production and test code
dependencies {
// We use the latest groovy 2.x version for building this library
compile 'org.codehaus.groovy:groovy-all:2.4.7'
compile gradleApi()
compile localGroovy()
// We use the awesome Spock testing and specification framework
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
testCompile 'junit:junit:4.12'
}
task myTask (type: my.package.MyTask)
: 여기 내 build.gradle
파일입니다 무슨 일이 벌어지고 있는지 또는 내가 원하는 것을 어떻게 할 것인지 전혀 모른다. 이것은 가장 간단한 가능한 예제처럼 보이지만 사용자 가이드를 따르면 아무데도 나에게 다가 가지 못했습니다. 내가 뭘하든 그 예외를 지나칠 수는 없습니다.
그루비 파일을 작성하고이를 사용하여 빌드 파일에서 새 작업을 정의하는 방법은 무엇입니까?
이제 새로운 오류가 발생했습니다. 감사합니다. 그러나 Sidenote : 그것을 바꿀 수있는 방법이 있습니까? 나는 이것을 배우려고 노력하고 있으므로 더 큰 프로젝트에 기여할 수 있지만 더 큰 프로젝트에는 buildSrc 폴더가 없습니다. – ewok
@ewok 업데이트 확인 – CMPS