2013-07-24 50 views
0

我已经具备以下条件:如何在distZip中包含测试类?

task packageTests(type: Jar) { 
    from sourceSets.test.output 
} 
distZip { 
    into(jarFolderName) { 
     from '.' 
     include 'conf/**' 
    } 
    into(jarFolderName) { 
     from '.' 
     include 'bin/**' 
     fileMode = 0755 
    } 
    into(jarFolderName) { 
     from 'build' 
     include 'logs' 
    } 
} 

添加dependOn将创建试验瓶,但我怎么能那么它包含在分配zip文件?

回答

1

第1步:创建测试的jar:

task testJar(type: Jar) { 
    classifier = 'tests' 
    from sourceSets.test.output 
} 

第2步:它distZip:

applicationDistribution.from(testJar) { 
    into "tests" 
} 
+0

谢谢!如果我将'from sourceSets.test.classes'更改为'from sourceSets.test.output',那对我有用。 – morja

+0

你是否也知道如何创建一个distZip,其中还包含测试依赖项? – morja

+0

使用fat-jar插件并自定义fatJar任务(这是一个Zip任务)https://github.com/musketyr/gradle-fatjar-plugin – JBaruch

1
into(someFolder) { 
    from packageTests 
} 

PS:我会写其他into就像这样:

into("$jarFolderName/conf") { 
    from "conf" 
} 
    into("$jarFolderName/bin") { 
    from "bin" 
} 
... 
+0

谢谢你,我确实改变了你的建议。 – morja

相关问题