【问题标题】:Error:(56, 0) Cause: org.gradle.api.tasks.testing.Test_Decorated cannot be cast to java.lang.Class错误:(56, 0) 原因:org.gradle.api.tasks.testing.Test_Decorated 无法转换为 java.lang.Class
【发布时间】:2015-04-19 05:42:02
【问题描述】:

我有这个build.gradle

apply plugin: 'java'

sourceCompatibility = 1.8
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
//
//    configurations.all*.exclude(group: 'com.sun.jersey', module: 'jersey-bundle')
//    configurations.all*.exclude(group: 'com.fasterxml.jackson.core', module:'jackson-databind')


    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'

    compile 'com.google.inject:guice:4.0-beta5'
    compile 'com.sun.jersey:jersey-core:1.18.3'
    compile 'com.sun.jersey:jersey-client:1.18.3'

    //testCompile group: 'junit', name: 'junit', version: '4.11'
}


sourceSets {
    main {
        java {
            srcDirs = ['src/main']
        }
    }

    test {
        java {
            srcDirs = ['src/main']
        }
    }
}


test {
    testLogging {
// Show that tests are run in the command-line output
        events 'started', 'passed'
    }
}


task testBaseLineGenerator(type: test) {
    systemProperties['test.single'] = 'BaseLineGenerator'
}

task testTotalLatency(type: test) {
    systemProperties['test.single'] = 'TotalLatencyTest'
}

添加后出现 Intellij 错误:

task testBaseLineGenerator(type: test) {
    systemProperties['test.single'] = 'BaseLineGenerator'
}

task testTotalLatency(type: test) {
    systemProperties['test.single'] = 'TotalLatencyTest'
}

我得到这个错误:

Error:(56, 0) Cause: org.gradle.api.tasks.testing.Test_Decorated cannot be cast to java.lang.Class
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

尝试了它建议的两个选项,但没有帮助。

【问题讨论】:

    标签: java groovy intellij-idea build gradle


    【解决方案1】:

    我设法解决了我的问题:

    我改成task testBaseLineGenerator(type: Test) {

    Test 而不是test

    【讨论】:

    • 请使用您问题上的编辑链接添加更多信息。 Post Answer 按钮应仅用于问题的完整答案。
    • 但没有更多信息。你觉得我应该补充什么?它解决了我的问题
    • 那么您应该编辑此内容以提及进行此更改解决了您的问题并将其标记为已接受
    • 我在自定义 jar 任务中遇到了类似的问题,问题是类型应该是“Jar”而不是“jar”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-22
    • 1970-01-01
    • 1970-01-01
    • 2012-02-13
    • 1970-01-01
    相关资源
    最近更新 更多