Hi!
I am rather new to gradle but I am currently switching from Maven to it (finally).
However, I am failing at the last step where I need to add the compiled web-client to the final server.jar under BOOT-INF/classes/static
such that it is being served by the Spring Boot server.
In my despair I even considered adding those files using jar
(the executable) but that’s not working anyway.
The “simple” question is: How can this be done?
Imo there are three options:
First, I could copy the files to build/classes/static
and let Spring Boot package management take care of everything. The problem here is that the jar seems to get created before I can run a copy { }
.
Second, The other option is to add those files after the .jar
file was build using the jar
command.
And third, set mobile-client/build
as a static resource for the Spring Boot server. But even if I knew how to do that I would probably have the same problem again: The jar will be built before the client got generated
This here is my project structure:
web-client/ # Angular Client
build/
build.gradle
server/ # Spring Boot Application
build/
build.gradle
build.gradle # The "parent" project. Works on web-client and server
And this here is the build.gradle
file of the “parent”:
task buildWebApp {
outputs.dir('mobile-client/build')
dependsOn ':mobile-client:buildWebApp'
}
task copyWebApp {
doFirst {
copy {
from 'mobile-client/build'
into 'server/build/classes/static'
}
}
dependsOn tasks.buildWebApp
}
assemble.dependsOn copyWebApp
Thanks for any help on this …
See also: related stackoverflow question