为什么gradle的buildscript类路径不包含buildSrc?

时间:2014-03-25 11:53:30

标签: gradle

我在gradle中的buildscript类路径上看不到buildSrc;我可以访问它......但不知何故不存在

我希望它存在......因为buildscript可以使用那些类

的build.gradle:

apply plugin: 'java'

buildscript{
        dependencies{
                classpath gradleApi()
        }
}


task show(){
A.asd()
buildscript.configurations.classpath.each { println it }
}

内容:buildSrc / src / main / java / A.java

public class A{
    public static void asd(){
        System.out.println(A.class + " is invokable from"+A.class.getProtectionDomain().getCodeSource().getLocation().getPath());
    }
}

输出:

:buildSrc:clean
...
:buildSrc:build
class A is invokable from/home/kirk/projects/bt/ews/tx3/buildSrc/build/classes/main/
/home/kirk/tools/gradle-1.11/lib/gradle-core-1.11.jar
...other nonrelated jars/etc
:show

1 个答案:

答案 0 :(得分:1)

buildscript { dependencies { classpath ... } }是显式添加构建脚本依赖项的方法。隐式添加buildSrc输出目录。