我正在尝试使用 Gradle 构建包含在下载示例文件夹中的 google-test 示例。在 OS X 和 Linux 上它编译正确,但在 Windows 上我得到错误 Plugin with id "google-test"not found.
我的 build.gradle 文件如下所示:
apply plugin: "cpp"
apply plugin: "google-test"
model {
flavors {
passing
failing
}
platforms {
x86 {
architecture "x86"
}
}
repositories {
libs(PrebuiltLibraries) {
googleTest {
headers.srcDir "libs/googleTest/1.7.0/include"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile =
file("libs/googleTest/1.7.0/lib/" +
findGoogleTestCoreLibForPlatform(targetPlatform))
}
}
}
}
components {
operators(NativeLibrarySpec) {
targetPlatform "x86"
}
}
}
binaries.withType(GoogleTestTestSuiteBinarySpec) {
lib library: "googleTest", linkage: "static"
if (flavor == flavors.failing) {
cppCompiler.define "PLUS_BROKEN"
}
}
tasks.withType(RunTestExecutable) {
args "--gtest_output=xml:test_detail.xml"
}
def findGoogleTestCoreLibForPlatform(Platform platform) {
if (platform.operatingSystem.windows) {
return "vs2013/gtest.lib"
// return "vs2013/gtest-core.lib"
// return "cygwin/gtest-core.lib"
// return "mingw/gtest-core.lib"
} else if (platform.operatingSystem.macOsX) {
return "osx/libgtest.a"
} else {
return "linux/libgtest.a"
}
}
关于什么可能导致这种情况的任何想法?
最佳答案
检查您在 windows/macosx 上安装的 gradle 版本。我不确定,但我认为 google-test 插件附带版本 2.5 rc https://docs.gradle.org/release-candidate/release-notes#google-test-support
关于c++ - Gradle 无法仅在 Windows 上找到插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31248978/