使用Gradle定义Intellij 15的测试源集 [英] Defining a test source set for Intellij 15 with Gradle

查看:63
本文介绍了使用Gradle定义Intellij 15的测试源集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用类似以下内容在Gradle中定义 sourceSet

I'm able to define a sourceSet in Gradle using something like the following

sourceSets {
    unitTest {
        java {
            srcDir 'src/unitTest/java'
        }
        resources {
            srcDir 'src/unitTest/resources'
        }
    }
}

但是,我似乎无法使用gradle定义测试源集.我可以通过UI手动指定它,但是刷新gradle项目时,它们会再次设置为Source Set,而不是Test Source Set.

However, I do not seem to be able to define a Test source set using gradle. I can specify it manually via the UI, but when the gradle projects are refreshed, they are set again as a Source Set, rather than a Test Source Set.

有什么方法可以在Gradle中定义源集,并让Intellij选择它为测试源集吗?

Is there any way to define the source set in Gradle, and have Intellij pick up that it's a Test Source Set?

推荐答案

这困扰了很多人,请参阅

This has bugged many people, see IDEA-165647. The proposed solution there, which actually works would then look as follows:

sourceSets {
    test.java.srcDir 'src/unitTest/java'
    test.resources.srcDir 'src/unitTest/resources'

    unitTest {
        java {
            srcDir 'src/unitTest/java'
        }
        resources {
            srcDir 'src/unitTest/resources'
        }
    }
}

区别在于添加 test.java.srcDir test.resources.srcDir .

这篇关于使用Gradle定义Intellij 15的测试源集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆