在build.gradle脚本里加入脚本:
task srcZip2(type: Zip) {
classifier = 'src'
from projectDir
include 'src/**/*'
include 'build.gradle'
destinationDir file('.')
archiveName "src.zip"
}
tasks.whenTaskAdded { task ->
if (task.name == 'generateReleaseBuildConfig' || task.name == 'generateDebugBuildConfig') {
task.dependsOn 'srcZip2'
}
}
task srcZip2(type: Zip) {
classifier = 'src'
from projectDir
include 'src/**/*'
include 'build.gradle'
destinationDir file('.')
archiveName "src.zip"
}
tasks.whenTaskAdded { task ->
if (task.name == 'generateReleaseBuildConfig' || task.name == 'generateDebugBuildConfig') {
task.dependsOn 'srcZip2'
}
}
最后就在当前 app目录下建立了src.zip文件。