Last active
September 27, 2018 05:47
-
-
Save vigack/ef368b87b3371456ef23f3469ed845e3 to your computer and use it in GitHub Desktop.
自动化合并前端代码草稿
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
ext { | |
springBootVersion = '1.5.6.RELEASE' | |
} | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath "org.projectlombok:lombok:1.16.18" | |
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") | |
classpath "mysql:mysql-connector-java:5.1.35" | |
classpath('se.transmode.gradle:gradle-docker:1.2') | |
} | |
} | |
plugins { | |
id 'net.ltgt.apt' version '0.15' | |
id "com.ewerk.gradle.plugins.querydsl" version "1.0.9" | |
id "com.moowork.node" version "1.2.0" | |
id "com.dorongold.task-tree" version "1.3" | |
} | |
group = 'vigack' | |
apply plugin: 'java' | |
apply plugin: 'org.springframework.boot' | |
apply plugin: 'war' | |
apply plugin: 'idea' | |
version = '0.0.1-SNAPSHOT' | |
sourceCompatibility = 1.8 | |
repositories { | |
jcenter() | |
} | |
configurations { | |
providedRuntime | |
} | |
dependencies { | |
compile('org.springframework.boot:spring-boot-starter-data-jpa') | |
compile('org.springframework.boot:spring-boot-starter-web') | |
compile group: 'org.springframework.boot', name: 'spring-boot-starter-cache' | |
compile('org.apache.shiro:shiro-spring:1.2.4') | |
compile 'com.squareup.okhttp3:okhttp:3.9.0' | |
runtime('mysql:mysql-connector-java') | |
compileOnly('org.projectlombok:lombok') | |
compile 'org.apache.commons:commons-dbcp2:2.1.1' | |
compile('org.springframework.boot:spring-boot-starter-tomcat') | |
compile "io.springfox:springfox-swagger2:2.7.0" | |
compile "io.springfox:springfox-swagger-ui:2.7.0" | |
compile "com.querydsl:querydsl-jpa:4.1.3" | |
compile "com.querydsl:querydsl-apt:4.1.3" | |
compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.3' | |
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.6' | |
compile group: 'org.dom4j', name: 'dom4j', version: '2.1.0' | |
compile group: 'org.apache.poi', name: 'poi', version: '3.17' | |
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.17' | |
compile group: 'com.fasterxml.uuid', name: 'java-uuid-generator', version: '3.1.4' | |
compile group: 'commons-net', name: 'commons-net', version: '3.6' | |
compile group: 'com.jcraft', name: 'jsch', version: '0.1.54' | |
compile group: 'net.sf.ehcache', name: 'ehcache', version: '2.10.4' | |
compile group: 'org.apache.shiro', name: 'shiro-ehcache', version: '1.4.0' | |
testCompile('org.springframework.boot:spring-boot-starter-test') | |
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0' | |
compile 'org.mapstruct:mapstruct-jdk8:1.2.0.Final' | |
annotationProcessor 'org.projectlombok:lombok' | |
annotationProcessor 'org.mapstruct:mapstruct-processor:1.2.0.Final' | |
} | |
war { | |
archiveName = 'ops.war' | |
} | |
querydsl { | |
querydslSourcesDir = 'src/main/java' | |
jpa = true | |
} | |
configurations { | |
querydsl.extendsFrom compileClasspath | |
} | |
idea { | |
module { | |
sourceDirs += file('build/generated/source/apt/main') | |
} | |
} | |
//---------------------------- UI construct BEGIN ---------------------------- | |
node { | |
nodeModulesDir = file("${project.projectDir}/ops-node") | |
} | |
task pullUI(group: 'UI', description: 'Pull git submodule') { | |
doLast { | |
exec { | |
commandLine 'git', 'submodule', 'update', '--init', '--recursive' | |
} | |
exec { | |
commandLine 'git', 'submodule', 'update', '--remote' | |
} | |
} | |
} | |
task buildUI(type: NpmTask, group: 'UI', description: 'Build UI through npm run build', dependsOn: npmInstall) { | |
args = ['run', 'build'] | |
} | |
task combineUI(type: Copy, group: 'UI', description: 'Copy dist file to main/resources', dependsOn: buildUI) { | |
into("${project.projectDir}/src/main/resources/") | |
from("${project.projectDir}/ops-node/dist/static") { | |
into("static") | |
} | |
from("${project.projectDir}/ops-node/dist") { | |
exclude "static/" | |
into("public") | |
} | |
} | |
processResources.dependsOn combineUI | |
npmInstall.dependsOn pullUI | |
//---------------------------- UI construct END ---------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
除了用gradle合并,还有其他几种思路:
用gradle联合构建看起来最为自动化,但是也导致构建时间大大延长,感觉都不很完美。
果然前后端分离的项目,用CDN部署才是合理的。