我想从一个.Jar文件中复制多个目录:
这样两个目录中的所有.class文件都捆绑成一个.jar文件,这可能吗?
task makeJar(type: Copy)
from('directory1')
into('another directory')
include('classes.jar')
我可以从这样的目录中复制:
string value = "11,.Ad23";
int n;
bool isNumeric = int.TryParse(value, out n);
答案 0 :(得分:3)
命令:
gradlew jarDebug / gradlew jarRelease
代码:
android.libraryVariants.all { variant ->
task("jar${variant.name}", type: Jar) {
description "Bundles compiled .class files into a JAR file for $variant.name."
dependsOn variant.javaCompile
from variant.javaCompile.destinationDir
exclude '**/R.class', '**/R$*.class', '**/R.html', '**/R.*.html'
}
}
来源: https://stackoverflow.com/a/19967914/950427
task makeJar(type: Copy) {
from('directory1/')
from('directory2/')
into('another directory/')
include('classes.jar')
}
类似: https://stackoverflow.com/a/19037807/950427
task initConfig(type: Copy) {
from('src/main/config') {
include '**/*.properties'
include '**/*.xml'
filter(ReplaceTokens, tokens: [version: '2.3.1'])
}
from('src/main/config') {
exclude '**/*.properties', '**/*.xml'
}
from('src/main/languages') {
rename 'EN_US_(.*)', '$1'
}
into 'build/target/config'
exclude '**/*.bak'
includeEmptyDirs = false
with dataContent
}
来源: http://gradle.org/docs/current/dsl/org.gradle.api.tasks.Copy.html