我尝试使用Gradle构建包含在samples文件夹中的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"
}
}
关于可能导致这种情况的任何想法?
答案 0 :(得分:1)
检查您在windows / macosx上安装的gradle版本。我不确定,但我认为google-test插件附带2.5版rc https://docs.gradle.org/release-candidate/release-notes#google-test-support