I would like to create a new task in my project that creates a jar archive with class files of my project and dependency class files (also called "shaded bank" or "bold bank").
The solution proposed by Gradle's cookie book modifies the standard JavaPlugin jar task:
jar { from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } }
However, I would like to keep the original jar taks as it is and have an additional task for the hatched jar, that is, a task that behaves exactly the same as the jar task, but includes additional files in accordance with
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
and has a different classifier ("shaded").
I tried to take on the configuration of the jar task by copying the following properties:
task shadedJar(type: Jar, dependsOn: configurations.compile) { dependencies = tasks.jar.taskDependencies source = tasks.jar.source manifest = tasks.jar.manifest includes = tasks.jar.includes classifier = 'shaded' from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } }
But the resulting tasks do not affect the jar dependencies, and as a result, jar does not include project class files. In addition, this approach seems cumbersome to be the recommended way to use an existing task as a template for a new one.
What would be the recommended approach to my specific need (a separate shadedJar task) and for cloning tasks to use them as templates for additional tasks in general?
(Currently I'm still on Gradle 1.3, but solutions for the current version of Gradle are also welcome)
neradis
source share