我爱上了JBoss TattleTale。通常情况下,在我的Ant构建中,我使用跟着医生来定义任务,然后按照如下方式运行它们:
<taskdef name="report"
classname="org.jboss.tattletale.ant.ReportTask"
classpathref="tattletale.lib.path.id"/>
...
<tattletale:report source="${src.dir]" destination="${dest.dir}"/>我现在正在将我的构建转换为Gradle,并且正在努力弄清楚如何在Gradle中运行Tattletale。似乎没有一个Gradle-Tattletale插件,而且我对Gradle的经验还不足以贡献一个。但是我也知道Gradle可以运行任何Ant插件,也可以从系统shell中执行一些东西;我只是不知道如何在Gradle中这样做,因为这里还没有任何文档。
因此,我问:如何从Gradle构建中运行tattle一举?
更新
下面是Gradle/Ant文档显示的示例:
task loadfile << {
def files = file('../antLoadfileResources').listFiles().sort()
files.each { File file ->
if (file.isFile()) {
ant.loadfile(srcFile: file, property: file.name)
println " *** $file.name ***"
println "${ant.properties[file.name]}"
}
}
}但是,在这里,我没有看到如何/在哪里为Tattletale和它的ReportTask定制它。
发布于 2016-10-27 16:07:24
以下内容来自于https://github.com/roguePanda/tycho-gen/blob/master/build.gradle
它绕过ant,直接调用Tattletale类。
它被修改为处理WAR,并要求一个更新的javassist,以便处理Java 8的特性,比如lambdas。
configurations {
tattletale
}
configurations.tattletale {
resolutionStrategy {
force 'org.javassist:javassist:3.20.0-GA'
}
}
dependencies {
// other dependencies here...
tattletale "org.jboss.tattletale:tattletale:1.2.0.Beta2"
}
task createTattletaleProperties {
ext.props = [reports:"*", enableDot:"true"]
ext.destFile = new File(buildDir, "tattletale.properties")
inputs.properties props
outputs.file destFile
doLast {
def properties = new Properties()
properties.putAll(props)
destFile.withOutputStream { os ->
properties.store(os, null)
}
}
}
task tattletale(type: JavaExec, dependsOn: [createTattletaleProperties, war]) {
ext.outputDir = new File(buildDir, "reports/tattletale")
outputs.dir outputDir
inputs.files configurations.runtime.files
inputs.file war.archivePath
doFirst {
outputDir.mkdirs()
}
main = "org.jboss.tattletale.Main"
classpath = configurations.tattletale
systemProperties "jboss-tattletale.properties": createTattletaleProperties.destFile
args([configurations.runtime.files, war.archivePath].flatten().join("#"))
args outputDir
}发布于 2017-10-02 14:46:05
以前的答案要么不完整,要么过于复杂。我所做的就是使用来自gradle的ant任务,它工作得很好。让我们假设你的塔塔在rootDir/tools/.
ant.taskdef(name: "tattleTaleTask", classname: "org.jboss.tattletale.ant.ReportTask", classpath: "${rootDir}/tools/tattletale-1.1.2.Final/tattletale-ant.jar:${rootDir}/tools/tattletale-1.1.2.Final/tattletale.jar:${rootDir}/tools/tattletale-1.1.2.Final/javassist.jar")
sources = "./src:./src2:./etcetera"
ant.tattleTaleTask(
source: sources,
destination: "tattleTaleReport",
classloader: "org.jboss.tattletale.reporting.classloader.NoopClassLoaderStructure",
profiles: "java5, java6",
reports: "*",
excludes: "notthisjar.jar,notthisjareither.jar,etcetera.jar"
){
}因此,上面的代码将生成./tattleTaleReport下面的报告。就这么简单。麻烦的是,源变量只接受目录,因此如果那些目录中存在jars,则需要将它们添加到排除参数中。
https://stackoverflow.com/questions/27045851
复制相似问题