我最近被指示在Gradle中实现所有构建/发布工程作业.
所以我是Gradle的新手,在这个勇敢的新世界中,一些在shell提示下显而易见的东西很难理解.
我的构建创建了一组jar文件.
我需要为每个人执行一个shell任务
类似的东西:
task findBugs (type:Exec, dependsOn: fb23) {commandLine 'java', '-jar',
'./findBugs/findbugs.jar', '-textui', '-progress', '-xml', '-output',
'TrustManagerService.xml', 'TrustManagerService.jar'}
Run Code Online (Sandbox Code Playgroud)
(我不能使用FindBugs插件,因为我们在JDK8中 - 所以我从预览版本外部运行FindBugs ......)
我可以得到一个文件集合,并用以下内容迭代文件名:
FileTree iotTree = fileTree(dir: '.')
iotTree.include '*.jar'
iotTree.each {
File file -> println file.name
println 'A file'
}
Run Code Online (Sandbox Code Playgroud)
要么
def iotJars = files(file('./jars').listFiles())
println ''
println iotJars
iotJars.each { File file -> println 'The next file is: ' + file.name }
Run Code Online (Sandbox Code Playgroud)
但是对于我的生活,我无法看到如何为返回的每个文件名执行shell命令...
关于这种最直接的方法的想法?
顺便说一句 - 什么是在代码清单中包含换行符的最佳方式 - 我必须返回并向每行添加CR以使它们断开...... :(