-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
119 lines (95 loc) · 3.57 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import com.eriwen.gradle.css.tasks.MinifyCssTask
import com.eriwen.gradle.js.tasks.MinifyJsTask
buildscript {
ext {
springBootVersion = '2.0.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id "com.eriwen.gradle.css" version "2.14.0"
id "com.eriwen.gradle.js" version "2.14.1"
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'css'
apply plugin: 'js'
version = '2.3.0'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
css.source {
custom {
css {
srcDir "src/main/resources/static/css"
include "**/*.css"
exclude "**/*.min.css"
}
}
}
javascript.source {
custom {
js {
srcDir "src/main/resources/static/js"
include "**/*.js"
exclude "**/*.min.js"
}
}
}
css.source.custom.css.files.eachWithIndex { cssFile, idx ->
tasks.create(name: "minifyCss_${cssFile.getName().replaceFirst(/[.][^.]+$/, "")}", type: MinifyCssTask) {
source = cssFile
dest = cssFile.getAbsolutePath().replace('.css', '.min.css')
yuicompressor {
lineBreakPos = -1
}
}
}
javascript.source.custom.js.files.eachWithIndex { jsFile, idx ->
tasks.create(name: "minifyJs_${jsFile.getName().replaceFirst(/[.][^.]+$/, "")}", type: MinifyJsTask) {
def absolutePath = jsFile.getAbsolutePath()
source = jsFile
dest = absolutePath.replace('.js', '.min.js')
sourceMap = absolutePath.replace('.js', '.min.js.map')
closure {
warningLevel = 'QUIET'
}
doLast {
def sourceMapFile = file(absolutePath.replace('.js', '.min.js.map'))
sourceMapFile.write(sourceMapFile.text.replaceAll("\\[\".*src/main/resources/static", "[\""))
file(absolutePath.replace('.js', '.min.js')) << "\n//# sourceMappingURL=" + jsFile.getName().replace('.js', '.min.js.map')
}
}
}
task minifyAllCss(dependsOn: tasks.matching { Task task ->
task.name.startsWith("minifyCss_")
})
task minifyAllJs(dependsOn: tasks.matching { Task task ->
task.name.startsWith("minifyJs_")
})
task minify(dependsOn: [minifyAllCss, minifyAllJs])
bootJar.dependsOn minify
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-cache'
compile group: 'org.springframework.session', name: 'spring-session-jdbc'
compile group: 'com.googlecode.htmlcompressor', name: 'htmlcompressor', version: '1.5.2'
compile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.9'
compile group: 'de.svenkubiak', name: 'jBCrypt', version: '0.4.1'
compile group: 'com.google.guava', name: 'guava', version: '24.1-jre'
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
compile group: 'com.yahoo.platform.yui', name: 'yuicompressor', version: '2.4.8'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
}