2 回答
TA贡献1863条经验 获得超2个赞
从上面的答案中,我能够在没有依赖项文件夹的情况下构建 zip 文件,所以我努力找出如何按照设备群的预期构建具有依赖项的 zip 文件。这是在 build.gradle 文件中添加依赖项的方法,通过上述任务(从上面复制),我们可以看到在 zip 文件中添加了依赖项文件夹。
dependencies {
runtime group: 'net.serenity-bdd', name: 'serenity-junit', version: '2.0.18'
runtime group: 'net.serenity-bdd', name: 'serenity-cucumber', version: '1.9.20'
runtime group: 'net.serenity-bdd', name: 'serenity-reports-configuration', version: '1.9.43'
runtime group: 'org.assertj', name: 'assertj-core', version: '3.11.1'
runtime group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
runtime group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '3.0.0'
}
dependencies {
testCompile(
'net.serenity-bdd:serenity-junit:2.0.18',
'net.serenity-bdd:serenity-cucumber:1.9.20',
'org.assertj:assertj-core:3.11.1',
'ch.qos.logback:logback-classic:1.2.3',
'io.github.bonigarcia:webdrivermanager:3.0.0'
)
}
task getDeps(type: Copy) {
from sourceSets.main.runtimeClasspath
into 'build/libs/dependency-jars'
}
//packaging tests task which is generated from sample using gradle init
task packageTests(type: Jar) {
dependsOn getDeps
from sourceSets.test.output
classifier = 'tests'
}
//create zip archive
task zip(type: Zip) {
dependsOn packageTests
from 'build/libs/'
include '*'
include '*/*' //to include contents of a folder present inside dependency-jars directory
archiveName 'zip-with-dependencies.zip'
destinationDir(file('build/libs/'))
}
添加回答
举报