我有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.
尝试了它建议的两个选项,但它没有帮助。
答案 0 :(得分:2)
我设法解决了我的问题:
我改为task testBaseLineGenerator(type: Test) {
Test
代替test