c++ - Gradle 无法仅在 Windows 上找到插件

标签 c++ gradle

我正在尝试使用 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/

相关文章:

gradle - 控制gradle任务执行顺序

c++ - CUDA 'dot product' 内核能否加速批量 RMS 计算?

c++ - main() 在 C 和 C++ 中应该返回什么?

c++ - 使用 fork 执行多个命令

java - Gradle 对 Ubuntu 上的现有文件抛出 NoSuchFileException

java - Glassfish Websocket无法正常工作

c++ - 的优先级是多少!表达式 !x--? 中的运算符 vs --

书中的 C++ 素数任务

jsp - 使用 Gradle 预编译 JSP

java - 配置 Gradle + Robolectric