//自定义一个任务
//在任务中写归档脚本
//自定义一个publishJar集合
configurations{
publishJar
}
//依赖中用这个集合来加载jar包
dependencies{
publishJar 'junit:junit:4.2'
compile configurations.publishJar.dependencies
}
task publishJar(){
archiveName = 'test.jar'
destinationDir = file(project.buildDir.absoulutePath+'/output/libs')
from(project.zipTree('libs/local.jar'))
//从自定义的集合中获取需要的jar包路径
def publishJarPath = configurations.publishJar.asPath
def publishJarArray = publishJarPath.split(";")
publishJarArray.each{
//从jar包中获取对应的文件
from(project.zipTree(it))
}
exclude('org/apache/test')
//一定要写对应jar包中的哪些文件
include('com/fr/**/*.class')
}
最后打出的jar包包含所需要的所有文件