Gradle Jar task and Copy task


(kpramesh) #1

I am having the following tasks in my build.gradle file

task genFile {
def smFile = fileTree(dir: ‘src’, include: ‘**/SmartModelUpgrade.txt’)

  doLast {
     ['SmartModel', 'SmartModelBasic', 'SmartModelComplex'].each  { param ->
         copy {
             from smFile
             rename { String fileName -> fileName.replace 'SmartModelUpgrade.txt', "${param}Upgrade.java"
             into 'src'
         }
     }
  }

}

task genJar {
inputs.files fileTree(dir: sourceSets.main.java.outputDir, include: “/SmartModelUpgrade.class")
outputs.files fileTree(dir: libsDir, include: "
/SmartModel*.jar”)
doLast {
outputs.files.each {println it}
[‘SmartModel’, ‘SmartModelBasic’, ‘SmartModelComplex’].each { param ->
println param
jar {
archiveName = “${param}Upgrade.jar"
from inputs.files
includes = [”**/${param}Upgrade*.class"]
manifest {
attributes(“Build-By”: “Ramesh”)
}
}
}
}
}

Task genFile works fine

However

Task genJar runs fine but I cannot see any jar file in the build/lib directory

Please note:
I am using java plugin
and compilation is successful
I could see the class files genereated after compile
its only that the jar task wont produce any output

could anyone explain why the genJar task not working.

Regards
Ramesh