Larry Cai Larry Cai - 3 years ago 151
Groovy Question

gradle build failure for groovy project on dependence

New to groovy, and I had one groovy project@commit 2f54b59 like below

├── build.gradle
└── src
└── main
└── groovy
├── check.groovy
└── helpers
└── Person.groovy

And the
is simple:

import helpers.*
println "hello"
person = new Person()

I try to use
to manage the project with

sourceSets {
main {
groovy {
include '*.groovy'

and meet error when build:

$ gradle build
:compileJava UP-TO-DATE
startup failed:
gradle-sample/src/main/check.groovy: 5: unable to resolve class Person
@ line 5, column 10.
person = new Person()

1 error
:compileGroovy FAILED

FAILURE: Build failed with an exception.

If u run the
command directly, it works fine

$ cd src/main/groovy
$ groovy check.groovy

How to setup the configuration to make it work?

Answer Source

There's no need to configure any source sets - gradle will handle it itself.

See a little demo here.

apply plugin: 'groovy'

repositories {

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.3.11'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download