Description
Hi. I've now spent 4 days trying to accomplish what should be a trivial task with Gradle and the spring-boot plugin's bootRepackage task. I'm developing in a multi-project setup. We're using Spring Boot (love it for the most part). Gradle builds a jar file for each of my sub-projects (by default). So my layout is similar to this:
a:
b: build/libs/b.jar
c: build/libs/c.jar
d: build/libs/d.jar
Project 'b' is the project where the spring-boot plugin is used, and that's where the fat jar is created. Project b depends on c and d. The problem I'm having is that the code from the c and d projects gets included as jar files. I.e. in the fat jar, I get:
lib/b-0.0.1-SNAPSHOT.jar
lib/c-0.0.1-SNAPSHOT.jar
I don't want this as it's causing issues for certain other classes outside of my control, that are unable to find resources inside nested jar files. So I simply want to include the classes and resources directly inside the fat jar. Like this:
b/some/path/Foo.class
b/some/other/path/Bar.class
c/...
I've managed to add the classes/resources as files like the example above, but bootRepackage
still includes the jar files IN ADDITION to the classes/resources. This is causing problems, and I just don't want the jar files included at all. I have tried everything I can possibly come up with. I've followed the recipes from http://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-gradle-plugin.html but I just can't get bootRepackage
to do what I want. I've tried using exclude()
in the jar task, I've tried creating a custom jar task, I've tried modifying the configuration, I've tried excluding from the custom configuration, and I've tried adding an explicit doLast()
kludge task to bootRepackage
which will use the zip4j library to remove the undesired nested jars from the fat jar, but no matter what I try, bootRepackage
still overwrites my fat jar file with a version that contains the nested jar files. I'm at my wit's end. This should be as simple as a couple of lines of code in the Gradle file, but it has consumed 4 days of valuable developer time.
Also, I'm getting warnings from Gradle when I try using the properties mentioned in the spring-boot/bootRepackage documentation. When trying to add something like:
springBoot {
excludeArtifactIds = "..."
}
I'm seeing this warning message when I run the build:
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "excludeArtifactIds" on "org.springframework.boot.gradle.SpringBootPluginExtension_Decorated@6740559f", value: "lib/common-0.0.1-SNAPS...".
Any help with this issue is much appreciated! Thanks.