[Gradle] Using class from .groovy file in another folder

Link : http://stackoverflow.com/questions/11580057/using-class-from-groovy-file-located-in-another-folder-gradle 

If you change your build.gradle to simply be

task hello << {
  def utils = new Utils()
  utils.doit();
}

Then instead of

test
 -> groovy
     -> Utils.groovy
 -> build.gradle

move the Utils.groovy file to buildSrc/src/main/groovy like so:

test
 -> buildSrc
     -> src
         -> main
             -> groovy
                 -> Utils.groovy
 -> build.gradle

and gradle should pick it up automatically...

//=================

所以缺省的约定是Groovy脚本应放在buildSrc/main/src/groovy下面

原文地址:https://www.cnblogs.com/buhaiqing/p/2794045.html