Intellij idea 如何在Gradle/IntelliJ中添加测试资源根
使用IntelliJ 14和Gradle 2.2中的“idea”插件生成IntelliJ项目。我可以通过以下方式为集成测试添加新的测试源根:Intellij idea 如何在Gradle/IntelliJ中添加测试资源根,intellij-idea,gradle,Intellij Idea,Gradle,使用IntelliJ 14和Gradle 2.2中的“idea”插件生成IntelliJ项目。我可以通过以下方式为集成测试添加新的测试源根: idea { module { testSourceDirs += file('src/integrationTest/java') } } 但是,我没有找到一种方法来添加位于“src/integrationTest/Resources”的相应测试Resources根目录。有什么办法吗?非常感谢 -丹尼尔这应该行得通:)
idea {
module {
testSourceDirs += file('src/integrationTest/java')
}
}
但是,我没有找到一种方法来添加位于“src/integrationTest/Resources”的相应测试Resources根目录。有什么办法吗?非常感谢
-丹尼尔这应该行得通:)
只是尝试使用Cucumber插件。插件正确地标记了
src/cucumber/java
和src/cucumber/groovy
,但没有标记src/cucumber/resources
,因此IntelliJ cucumber支持变得混乱。对上述建议进行了讨论,目前正在发挥作用:
idea {
// Workaround to make sure the cucumber resources folder is
// marked as "Test Resource Root" in IntelliJ. Otherwise the
// IntelliJ cucumber integration gets confused wrt looking
// up step definitions, highlighting, etc.
module {
testSourceDirs += file('src/cucumber/resources')
}
module.iml.withXml {
def node = it.asNode()
def content = node.component.find { it.'@name' == 'NewModuleRootManager' }.content[0]
def cucumberSources = content.sourceFolder.findAll { it.@url?.contains('/src/cucumber/resources') }
cucumberSources.each {
it.@type = 'java-test-resource'
}
}
}
可以确认这一点非常有效(至少对于IntelliJ 2016.1.3)。请注意,这需要应用于多项目构建中的每个单独子项目。将其添加到子项目{}中如何?在根项目中-build.gradle?或者甚至更好地创建一个有你名字选择的脚本,让我们来配置。把它放在那里,然后把它应用到你需要的。YUP,我正在做的事情:请考虑。
idea {
// Workaround to make sure the cucumber resources folder is
// marked as "Test Resource Root" in IntelliJ. Otherwise the
// IntelliJ cucumber integration gets confused wrt looking
// up step definitions, highlighting, etc.
module {
testSourceDirs += file('src/cucumber/resources')
}
module.iml.withXml {
def node = it.asNode()
def content = node.component.find { it.'@name' == 'NewModuleRootManager' }.content[0]
def cucumberSources = content.sourceFolder.findAll { it.@url?.contains('/src/cucumber/resources') }
cucumberSources.each {
it.@type = 'java-test-resource'
}
}
}