Hi fellow software engineers,
I have the following situation.
At this moment, I have a spring-boot project with a bundled web app (React) whose built source files are stored under resources/static
directory.
Basically the file structure looks something like this:
main
|----java
| |---
|---resources
| |---static
| |---static
| |---css,js...
| |---index.html
| |---...
| |---otherResources
We've come to a point where we uploaded the web-app, in the form of a zip
file on Nexus.
groupId: my.project / artifactId: my-web-app / version: 1.0 / ext: zip
my-web-app-1.0.zip
|---static
|---css,js...
|---index.html
|---...
Now I want to remove the duplicated files from my repository (resources) and replace them with the content of the zip file.
I'm not sure how can I achieve this using spring-boot and gradle and I would like some guidance please.
Thank you
CodePudding user response:
You must load zip and unzip , then replace source:
main {
resources {
srcDir 'src'
}
}
CodePudding user response:
In order to get to the same exact structure I did something like this:
build.gradle
configurations {
webAppZip
}
dependencies {
// other dependencies
webAppZip(group: 'my.project', name: 'my-web-app', version: 1.0, ext: 'zip')
}
task unzip(type: Copy) {
var webAppLocation = "src/main/resources/static"
delete webAppLocation
from zipTree(configurations.webAppZip.singleFile)
into webAppLocation
}
processResources {
dependsOn(unzip)
}
Additionally one can add the static
directory to .gitignore
file.