2017-07-04 91 views
0

我想使用Gradle 3.1和Gradle play plugin。我必須添加一個任務。gradle play插件屬性testClassesDirs在gradle中丟失3.1

你能幫我解下從代碼4.03.1的片段嗎? 在搖籃3.1我找不到類似的屬性testClassesDirs

task doesNotWorkIn3_1(type: Test) { 

    dependsOn { tasks.compilePlayBinaryTests } 
    testClassesDirs = project.files { [tasks.compilePlayBinaryTests.destinationDir] } 
    classpath = project.files { testPlayBinary.classpath } 
    include '**/SwaggerControllerJsonTest.class' 
    outputs.upToDateWhen { false } 
} 

回答

0
task genSwaggerJson(type: Test) { 
    dependsOn { tasks.compilePlayBinaryTests } 
    testClassesDir = file("$buildDir/genSwaggerJson_testClasses") 
    classpath = files({ tasks.testPlayBinary.classpath }) 
    outputs.upToDateWhen { false } 
    include '**/MySingleTest.class' 
} 

這一個是3.1

0

像你說的,問題是testClassesDirs,它存在於搖籃4.x的,但不是在搖籃3.1。

所以,請更新

testClassesDirs = project.files {[tasks.compilePlayBinaryTests.destinationDir]}

testClassesDir = tasks.compilePlayBinaryTests.destinationDir 

讓我知道這是否正常工作。

+0

感謝您的回覆正常,但它並沒有幫助。我提供了我自己的答案 – Sergey

+0

@Sergey我沒有看到你的答案和我的區別,錯誤是什麼? – chenrui

+0

此外,我認爲你自己的答案不同於你原來的問題(從文件夾的角度來看)。 – chenrui