我有一个具有以下结构的项目:
web-client/ # Angular Client
build/
build.gradle
server/ # Spring Boot Application
build/
build.gradle
build.gradle # The "parent" project. Works on web-client and serverparent应该将编译的web应用程序复制到server/build/classes/static中,这样它就会被复制到最终jar的/BOOT-INF/classes/中,在那里它将由Spring Boot服务器提供服务。
到目前为止,除了最后一部分之外,一切都在正常工作。这些文件也不会复制到最终的jar中,我认为这是因为它在执行复制任务时已经构建好了。
这是我当前使用的脚本:
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
build.dependsOn copyWebApp如何确保这些来自mobile-client/build的文件最终出现在server的最终jar中
发布于 2021-01-10 23:24:43
我不能保证它当前的功能,但这是我几年前在我的一个项目中使用的。我确实使用了单独的gradle子模块来构建前端,然后使用单独的模块来构建后端,其中我将前端作为JAR:
root gradle project -> frontend
-> backend前端静态(使用/ build.gradle /**构建前端JAR )
apply plugin: "com.moowork.node"
apply plugin: 'java'
node {
version = '8.9.3'
download = true
}
def webResources = "$buildDir/web-resources/main"
sourceSets {
main {
output.dir(webResources, builtBy: 'buildWeb')
}
}
task webInstall(type: NpmTask) {
args = ['install']
}
task buildWeb(type: NpmTask) {
dependsOn webInstall
args = ['run', 'build']
}
build.dependsOn buildWeb后端build.gradle
apply plugin: 'spring-boot-gradle-plugin'
apply plugin: 'idea'
dependencies {
compile project(':frontend')
}https://stackoverflow.com/questions/65645773
复制相似问题