本文介绍了告诉Gradle检查两个目录以获取主要的Java源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个充满测试的项目,可用于查询环境.我们使用Gradle运行这些测试.我想从一个独立的应用程序运行这些测试,以摆脱Gradle依赖关系.我正在使用gradle的应用程序"插件,并尝试使用JUnitCore运行JUnit测试,除了我无法从main访问测试类之外,其他一切都很好.

I have a project full of tests that we use to query our environments. We run these tests using Gradle. I would like to run these tests from a standalone application to get rid of the Gradle dependency. I am using the gradle 'application' plugin and trying to run the JUnit tests using JUnitCore and everything is fine except I can't access my test classes from main.

我有

--main
--smokeTest
--longRunningTest

当我告诉Gradle这是行不通的.

When I tell Gradle this it doesn't work.

sourceSets {
 main {
    java { srcDirs ['src/main/java', 'src/smokeTest/java'] }
    }
} 

它表示"main"不是公认的功能.之所以安装Java插件,是因为我已经有了用于定义smokeTest和longRunningTest的条目.

It says "main" is not a recognized function. The java plugin is installed because I already have entries to define smokeTest and longRunningTest.

推荐答案

不要只是从@ david-m-karr那里窃取火焰,而只是进行一些改进:

Not to steal the flame from @david-m-karr, just refining a bit:

sourceSets.main.java.srcDirs = ['src/main/java', 'src/smokeTest/java'] 

可能工作

这篇关于告诉Gradle检查两个目录以获取主要的Java源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 08:11