Slok
(Thunder)
#1
I am good in java but not in groovy and new to gradle ( learning), Doing POC in gradle
Please help me on how to write java plugin for the below tasks:
- copy Specific Dependecies jars
- Extract Config or Resources files in specific dependecies to directory
- zip the step 2
- Create final deployemnt structure for application.
Please help me to write this
You can create task as you wish by using Zip
type task, without creating a plugin.
For example, the task, which copies junit excluding hamcrest
jar and MANIFEST.MF
file, can be written as follows.
configurations {
junitDep
}
dependencies {
junitDep 'junit:junit:4.12'
}
task copyOnlyJunit(type: Zip) {
from configurations.junitDep.findAll{file ->
!file.name.contains('hamcrest')
}.collect {file ->
zipTree(file)
}
exclude '**/manifest.mf'
caseSensitive = false
baseName = 'only-junit'
}
This task will copy and archive files from junit
excluding hamcrest
and manifest.mf
file into build/distribution/only-junit.zip
file.
Detail information is available at Gradle DSL Document on Zip.
Lance_Java
(Lance Java)
#3
You might want to use the [shadow plugin] (https://github.com/johnrengelman/shadow)
Slok
(Thunder)
#4
Thanks for the quick reply . It really Helps 