Due to some requirements with the xjc plugin, I need to declare multiple sourceSets in my project, and gather outputs of these sourcesets in the bootjar archive.
I managed to do this with the following configuration:
sourceSets { set1 set2 main { compileClasspath += set1.output runtimeClasspath += set1.output compileClasspath += set2.output runtimeClasspath += set2.output } } With Springboot 2.3.X.RELEASE, I am able to launch the application with Bootrun task, and Bootjar worked like it should according to Gradle plugins documentation :
Creates a BootJar task named bootJar that will create an executable, fat jar for the project. The jar will contain everything on the runtime classpath of the main source set; classes are packaged in BOOT-INF/classes and jars are packaged in BOOT-INF/lib
When upgrading to springboot >= 2.4.0 bootrun task started to complain about ClassNotFoundException with other sourcesets classes (although these classes are build and exist on the filesystem), and these .class files are not included in the generated bootjar.
If this is the expected behaviour, the documentation should be fixed as it is misleading.
A demo project is available here to illustrate this issue.