I have a java project which has a couple of dependencies, e.g.:
dependencies {
compile("com.whatever.jar:jar-1:1.2.3")
compile("com.whatever.jar:jar-2:4.5.6")
compile("com.whatever.jar:jar-3:7.8.9")
}
I package it as a jar library and publish it to the repository together with a POM file that describes those dependencies:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.project</groupId>
<artifactId>my-library</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>com.whatever.jar</groupId>
<artifactId>jar-1</artifactId>
<version>1.2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.whatever.jar</groupId>
<artifactId>jar-2</artifactId>
<version>4.5.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.whatever.jar</groupId>
<artifactId>jar-3</artifactId>
<version>7.8.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
I also have another project which depends on this previously built jar on compile time:
dependencies {
compileOnly("com.my.project:my-library:1.0.0")
}
I would like to create a task that builds the second project and creates a zip file containing both com.my.project:my-library:1.0.0
jar and its transitive dependencies (jar-1
, jar-2
and jar-3
).
task createZip << {
into('lib') {
// here I would like to do something like (it's a horrible pseudo-code):
from configurations.(com.my.project:my-library:1.0.0).jar.transitiveDependencies.files
}
}
How do I achieve that?
Edit: I also would like to access the list of my-library
's transitive dependencies (and precisely those, not any other dependencies in the project) programmatically in order to build a Loader-Path
manifest attribute using those.