gradle-不过滤二进制换行符的Include JAR
我有一个包含子项目的项目 A/B 空调 (B和C次级项目)。B和C被编译成一个Jar文件。使用下面的代码gradle-不过滤二进制换行符的Include JAR,gradle,Gradle,我有一个包含子项目的项目 A/B 空调 (B和C次级项目)。B和C被编译成一个Jar文件。使用下面的代码 gradle.taskGraph.whenReady { jar { from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } manifest { attributes("Main-Class": "brut.apktool.Main")
gradle.taskGraph.whenReady {
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest {
attributes("Main-Class": "brut.apktool.Main")
}
}
}
这很好,但是我在/a/b/src/main/resources/prebuild.JAR中有一个预构建的JAR。这个jar只是封装了我在程序中需要的一些随机文件。没有任何java或其他东西。我从inputStream中获取它们,但在使用Gradle构建之后,它会转换二进制换行符数据,然后将归档文件弄乱
我尝试使用CopyTask post-build复制jar,但我从未在gradle.TaskGraph.whenrady之前运行过任务
回到Maven。我只想对该文件禁用筛选,但在Gradle中找不到相同的表达式
编辑:这是我目前所做的,它将我的更改过滤到属性文件中,但不进行换行过滤
processResources {
ext.fullrev = ''
ant.loadfile(srcFile: "../../.git/refs/heads/master", property: ext.fullrev)
filter(FixCrLfFilter)
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [version: apktoolversion, gitrev: ant.properties[ext.fullrev].substring(0,10)])
}
很好地解决了这个问题。为未来的谷歌人
processResources {
from('src/main/resources/properties') {
include '**/*.properties'
into 'properties'
ext.fullrev = ''
ant.loadfile(srcFile: "../../.git/refs/heads/master", property: ext.fullrev)
filter(ReplaceTokens, tokens: [version: apktoolversion, gitrev: ant.properties[ext.fullrev].substring(0,10)])
}
from('src/main/resources/') {
include '**/*.jar'
}
includeEmptyDirs = false
}
解释起来很简单。如果文件属于my*.properties include,则其已过滤等
如果它落在*.jar中,它只是继续复制而不进行过滤。防止graddle/plugin过滤JAR文件中的二进制换行符。您是否为
a/b
的JAR任务配置了过滤器?是的。我试着像这样添加它(刚刚编辑并显示在上面)。