We will assume that we have two folders in the project, "frontend" and "backend".
In the main folder, settings.gradle
must contain:
rootProject.name = 'my-project'
include ':frontend', ':backend'
In the backend
folder, the build.gradle
file must contain:
dependencies {
// ...
runtimeOnly project(':frontend')
}
task copyWebApplication(type: Copy) {
from project(':frontend').file('build')
into('./src/main/resources/static')
}
build.dependsOn(copyWebApplication)
copyWebApplication.dependsOn(':frontend:build')
And the frontend
folder must contain a build.gradle
file with the following:
plugins {
id 'base'
id "com.github.node-gradle.node" version "3.2.1"
}
task npmBuild(type: NpmTask) {
args = ['run', 'build']
}
task dev(type: NpmTask){
args= ['start']
}
assemble.dependsOn(npmBuild)