-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
162 lines (136 loc) · 4.72 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
buildscript {
ext {
springBootVersion = '3.1.11'
lombokVersion = '1.18.30'
springDepVersion = '1.1.0'
hutoolVersion = '5.8.27'
oracleVersion = '21.11.0.0'
mysqlVersion = '8.3.0'
mssqlVersion = '10.2.3.jre17'
pgsqlVersion = '42.7.3'
dmVersion = '8.1.3.140'
highgoVersion = '6.2.4'
kingbaseVersion = '8.6.0'
}
// 插件仓库
repositories {
mavenLocal()
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
}
dependencies {
classpath 'com.guardsquare:proguard-gradle:7.4.1'
}
}
plugins {
id 'java'
id 'application'
id 'org.springframework.boot' version "${springBootVersion}"
id 'io.spring.dependency-management' version "${springDepVersion}"
id 'org.openjfx.javafxplugin' version '0.1.0'
id 'org.javamodularity.moduleplugin' version '1.8.12'
id 'org.beryx.jlink' version '2.26.0'
}
group = 'com.zhiyi'
version = '0.0.3'
javafx {
version = "17.0.10"
modules = ['javafx.controls', 'javafx.fxml', 'javafx.web', 'javafx.swing', 'javafx.media']
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation("cn.hutool:hutool-core:${hutoolVersion}")
implementation("cn.hutool:hutool-http:${hutoolVersion}")
implementation("cn.hutool:hutool-json:${hutoolVersion}")
// lombok
compileOnly("org.projectlombok:lombok:${lombokVersion}")
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
// database
runtimeOnly("com.oracle.database.jdbc:ojdbc8:${oracleVersion}")
runtimeOnly("com.oracle.database.nls:orai18n:${oracleVersion}")
runtimeOnly("com.mysql:mysql-connector-j:${mysqlVersion}")
runtimeOnly("com.microsoft.sqlserver:mssql-jdbc:${mssqlVersion}")
runtimeOnly("org.postgresql:postgresql:${pgsqlVersion}")
runtimeOnly("com.dameng:DmJdbcDriver18:${dmVersion}")
runtimeOnly("com.dameng:DmDialect-for-hibernate6.2:${dmVersion}")
runtimeOnly("com.highgo:HgdbJdbc:${highgoVersion}")
runtimeOnly("cn.com.kingbase:kingbase8:${kingbaseVersion}")
}
test {
useJUnitPlatform()
}
application {
mainClass = 'com.zhiyi.showdoctools.ShowdoctoolsApplication'
executableDir = 'bin'
}
def configDir = 'config'
tasks.register('copyConfig', Copy) {
from 'src/main/resources'
include "**/*.*"
into layout.buildDirectory.dir("${configDir}")
}
distributions {
main {
contents {
from(copyConfig) {
into "${configDir}"
}
}
}
}
startScripts {
classpath = files('%APP_HOME%/lib/*', "%APP_HOME%/${configDir}")
}
jlink {
imageZip = project.file(layout.buildDirectory.file("distributions/app-${javafx.platform.classifier}.zip"))
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}
jlinkZip {
group = 'distribution'
}
// 2. Add tasks
// 2.1 Clean buildDir before running proguard
task cleanClasses(type: Delete) {
delete layout.buildDirectory.dir("classes/java/main")
delete layout.buildDirectory.dir("resources/java/main")
}
classes.dependsOn(cleanClasses)
// 2.2 Add proguard task
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: classes) {
injars project.sourceSets.main.output
outjars layout.buildDirectory.file("proguard/output.jar")
libraryjars project.sourceSets.main.compileClasspath
configuration 'proguard.pro'
}
// 2.3 Clean after proguard task
task cleanAfterProguard(type: Delete, dependsOn: proguard) {
delete layout.buildDirectory.dir("classes/java/main")
delete layout.buildDirectory.dir("resources/java/main")
}
// 2.4 Extract output jar to buildDir
task unpackProguardOutput(type: Copy, dependsOn: cleanAfterProguard) {
from zipTree(layout.buildDirectory.file("proguard/output.jar"))
into file(layout.buildDirectory.dir("classes/java/main"))
}
// 3. Create a task to run the app with the proguarded buildDir
task runProguard(type: JavaExec, dependsOn: unpackProguardOutput) {
classpath = sourceSets.main.runtimeClasspath
jvmArgs = ['--module-path', classpath.asPath,
'--add-modules', 'javafx.controls,javafx.fxml']
main = 'a.a.b' // <-- this name will depend on the proguard result
}