I have a folder (“distJarPath”) with all the runtime jars and project jar. I need to copy some into another folder ("${gridlibPath}/jar").
project.ext.gridlibJarList = [rootProject.name, 'commons-lang', 'commons-logging', 'visualNumerics', 'jini-core']
private boolean isGridlibJar(final File file) {
gridlibJarList.each {
gridlibJar ->
if (file.name.startsWith(gridlibJar)) {
println "One jar for gridlib: ${file}"
return true;
}
}
println "not for gridlib: ${file}"
return false;
}
task buildDistribution(dependsOn: ['buildJarDir', 'buildGridlib']) << {
println "Building the files for distribution..."
println "Building the jar libs @ ${distJarPath} by the task "buildJarDir" ..."
println "Building the gridlib jar folder @ "${gridlibPath}/jar" ..."
def distJarCollection = fileTree(distJarPath)
def gridlibJars=file(distJarPath).listFiles().findAll{println it.name; isGridlibJar(it)}.collect{println it;it}
println " ${distJarCollection};\t ${distJarCollection.files}"
println "gridlib jars: (${gridlibJars.class})
${gridlibJars}"
copy {
from gridlibJars
into "${gridlibPath}/jar"
}
}
However I got the result as such:
commons-lang-2.4.jar
One jar for gridlib: C:\test\biz_sim\build\dist\fmac\jars\commons-lang-2.4.jar
not for gridlib: C:\test\biz_sim\build\dist\fmac\jars\commons-lang-2.4.jar
commons-logging-1.2.jar
One jar for gridlib: C:\test\biz_sim\build\dist\fmac\jars\commons-logging-1.2.jar
not for gridlib: C:\test\biz_sim\build\dist\fmac\jars\commons-logging-1.2.jar
commons-math3-3.2.jar
not for gridlib: C:\test\biz_sim\build\dist\fmac\jars\commons-math3-
......
directory 'build/dist/fmac/jars';
[C:\test\biz_sim\build\dist\fmac\jars\aopalliance-1.0.jar, ..... C:\test\biz_sim\build\dist\fmac\jars\xsdlib-1.0.jar]
gridlib jars: (class java.util.ArrayList)
[]
Why does the final ‘gridlibJars’ object have no element?