Reputation: 5654
I have to copy a jar from the repository (say local) in my ZIP packaging. I understand that we can define compile/runtime in dependencies. However, I could not use it them in ZIP.
I'm able to copy the jar file by specifying the path in my filesystem. However, I don't know how to do it from repository.
Here is how my code looks like:
task createZipFile (type: Zip, dependsOn: [...]) {
baseName 'xyz'
from(fileTree("src/main"), {
include "prjName/css/**"
include "prjName/images/**"
include "prjName/javascript/**"
include "prjName/WEB-INF/**"
exclude "prjName/WEB-INF/web.xml"
})
from file("<Absolute-path-to-jar-file-in-my-filesystem>") //this works
// how to copy the same jar file from repository ??
}
Upvotes: 1
Views: 3747
Reputation: 51
To specify a specific jar without its dependencies, qualify it with "@jar". E.g. "commons-beanutils:commons-beanutils:1.6@jar" For an example that explains how to reference a set of jars using a custom configuration, see Download some dependencies and copy them to a local folder
Upvotes: 0
Reputation: 171184
Assuming your dependencies are in the runtime configuration ie:
runtime 'org.slf4j:slf4j-log4j12:1.6.2'
you can do:
task createZipFile( type: Zip, dependsOn: [...] ) {
baseName 'xyz'
from fileTree("src/main"), {
include "prjName/css/**"
include "prjName/images/**"
include "prjName/javascript/**"
include "prjName/WEB-INF/**"
exclude "prjName/WEB-INF/web.xml"
}
from configurations.runtime.files { it.name == 'slf4j-log4j12' }
}
To add all jars downloaded for the dependency with the name slf4j-log4j12
Upvotes: 3