【发布时间】:2018-05-09 02:51:52
【问题描述】:
我是一名 gradle 初学者,我正在努力将前端分发构建文件夹包含在后端 jar 中(我使用 Spring Boot,前端是一个离子应用程序)。在 backend.gradle 中,我配置了应该包含 frontend-build 文件夹(称为 www)的 jar-Task 到后端的 build 文件夹中。 jar 任务运行完成,但所需的工件不存在于 backend-build 文件夹中,因此不存在于最终的 jar 中。很高兴得到任何帮助。
项目结构:
project
build.gradle
settings.gradle
backend
--> backend.gradle
frontend
--> frontend.gradle
settings.gradle
include 'backend'
include 'frontend'
rootProject.children.each {
it.buildFileName = it.name + '.gradle'
}
build.gradle
allprojects {
buildscript {
repositories {
mavenCentral()
}
}
apply plugin: 'idea'
repositories {
mavenCentral()
}
}
前端.gradle
plugins {
id "com.moowork.node" version "1.2.0"
}
task clean(dependsOn: 'npm_run_clean') {
}
task build(dependsOn: 'npm_run_build') {
}
backend.gradle
buildscript {
ext {
springBootVersion = '1.5.8.RELEASE'
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
group = 'ch.renewinkler'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
jar {
from('frontend/www') {
into('public')
}
}
processResources.dependsOn(':frontend:build')
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
【问题讨论】: