Please Help me to integrate with node ui module and Spring boot using gradle.
I just want to deploy war file with web jar file.
My Project structure is like
myproject
api
src/main/java
src/main/resources
build/libs
web
<--- node files
dist
build/libs
gradle
build.gradle
gradlew
gradlew.bat
settings.gradle
api module is rest-api java application.
And web module is npm node app.
I want to do this senario.
If I type
./gradlew clean buildthen
:webproject compile first and makedistdirectory and then makejarfile.And then
:apiproject make war with this jar file. I will deployapi warto server.
Maybe above step is not right because I'm not good at it.
How should I make code to do it? I have to write script in one build.gradle file. There is only one build.gradle file. I have to use only this file.
buildscript {
ext {
springBootVersion = '1.5.7.RELEASE'
}
repositories {
mavenCentral()
maven { url 'http://repo.spring.io/plugins-release'}
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'io.spring.gradle:propdeps-plugin:0.0.9.RELEASE'
classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
}
project('api') {
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
apply plugin: 'propdeps'
dependencies {
compile project(':web')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.springframework.boot:spring-boot-devtools')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
optional('org.springframework.boot:spring-boot-configuration-processor')
}
compileJava.dependsOn(processResources)
}
project('web') {
apply plugin: 'com.moowork.node'
node {
version = '6.11.4'
npmVersion = '3.10.10'
download = true
distBaseUrl = 'https://nodejs.org/dist'
}
task nodeBuild(type: NpmTask) {
args = ['run', 'build']
}
jar {
from ("dist/")
into ("${rootProject.project('api').projectDir}/src/main/resources/")
includeEmptyDirs = true
}
clean {
delete 'dist/'
}
nodeBuild.dependsOn(npm_install)
build.dependsOn(nodeBuild)
}