如何在Gradle中引用或链接JavaSRC与测试结构

如何在Gradle中引用或链接JavaSRC与测试结构,gradle,build.gradle,Gradle,Build.gradle,我是gradle的新手,目前我在编译测试类时遇到了一个问题,我将测试类中的Java类引用到测试程序中,但我无法编译。我不明白如何将JavaSRC结构与测试结构链接或引用。有人能帮我解决这些问题吗 下面我提供了Src和测试包结构以及编译问题的截图 javasrc与测试结构 编译错误 构建属性 编辑:: 我正在使用netbeans,在gradle插件的帮助下,我在下面创建了这个项目结构,您可以找到屏幕截图。如果我遗漏了什么,请纠正我 如果有更多信息,请告诉我。通常,测试类应提供同一包装中的产品类别。

我是gradle的新手,目前我在编译测试类时遇到了一个问题,我将测试类中的Java类引用到测试程序中,但我无法编译。我不明白如何将JavaSRC结构与测试结构链接或引用。有人能帮我解决这些问题吗

下面我提供了Src和测试包结构以及编译问题的截图

javasrc与测试结构

编译错误

构建属性

编辑::

我正在使用netbeans,在gradle插件的帮助下,我在下面创建了这个项目结构,您可以找到屏幕截图。如果我遗漏了什么,请纠正我


如果有更多信息,请告诉我。

通常,测试类应提供同一包装中的产品类别。您能否验证测试类中的包没有在与产品类不同的包中定义它的键入错误?没有键入错误,上面我已经给出了详细的项目结构。我还遗漏了什么吗?
apply plugin: 'java'

sourceCompatibility = '1.7'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
    ext.mainClass = ''
}

jar {
    manifest {
        attributes 'Main-Class': 'com.gradle.shopcart.ShopCartApp'
    }
}

repositories {
    mavenCentral()
    // You may define additional repositories, or even remove "mavenCentral()".
    // Read more about repositories here:
    //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}

dependencies {
    // TODO: Add dependencies here ...
    // You can read more about how to add dependency here:
    //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
    testCompile group: 'junit', name: 'junit', version: '4.12'

}