I’m trying to make a build with root project, and one spring boot project and one project with react components for frontend.
I want to pack frontend components to jar, and then build fat jar for spring boot app with fontend jar in WEB-INF\lib\ in fat jar.
Fromtend jar built with id(“com.moowork.node”) gradle plugin, and produced jar:
val npm_run_build = tasks.getByName("npm_run_build") {
if (this == null) throw Exception("npm_run_build is null")
inputs.files(fileTree("public"))
inputs.files(fileTree("src"))
inputs.file("package.json")
inputs.file("package-lock.json")
outputs.dir("build")
println("npm_run_build")
}
val packageNpmApp by tasks.registering(Zip::class) {
dependsOn(npm_run_build)
archiveBaseName.set("app-react-components")
archiveExtension.set("jar")
destinationDirectory.set(File("$projectDir/build_packageNpmApp"))
from("build")
into("static")
}
val npmResources by configurations.creating
configurations {
// npmResources
default.get().extendsFrom(npmResources)
}
artifacts {
add("archives", packageNpmApp) {
type = "jar"
builtBy(packageNpmApp)
}
}
This jar appears after build, all seems ok. Next, in spring boot application I add dependency to frontend project:
dependencies {
...
runtimeOnly(project(":app-react-components"))
// implementation(project(":app-react-components"))
....
}
My github repo.
But frontend jar not appears in fat jar. What wrong and how to fix it?