forked from squirrel-sql-client/squirrel-sql-code
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
270 lines (226 loc) · 7.96 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
plugins {
id 'base'
}
group = 'squirrel-sql'
def currDate = new Date()
def DSTAMP = currDate.format('yyyyMMdd')
def TSTAMP = currDate.format('HHmm')
//DEFINE VERSION HERE ONLY
//version = '4.7.1' //release version
version = "snapshot-${DSTAMP}_${TSTAMP}"
defaultTasks 'buildAll'
ext {
targetVM = 11
versionCheckerTargetVM = 8
coreLibDir = "$projectDir/core/lib"
outputDistDir = 'output/dist'
}
repositories {
mavenCentral()
mavenLocal()
}
subprojects {
apply plugin: 'java'
compileJava {
options.encoding = 'UTF-8'
options.release = targetVM
}
dependencies {
if (!['core', 'versionChecker'].contains(project.name)) {
implementation project(':core')
//extra libraries for each plugin (where applicable)
implementation fileTree(dir: 'lib', include: '*.jar')
}
if ('versionChecker' != project.name) {
implementation fileTree(dir: coreLibDir, include: '*.jar')
}
if ('laf' == project.name) {
//extra libraries for the plugin 'laf'
implementation fileTree(dir: 'lafs', include: '*.jar')
}
}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
//initialize the srcDirs property to remove the default src/main/resources,
//and add other resources from src (excluding *.java by default)
srcDirs = ['src']
}
}
}
}
//somehow the 'base' plugin's assemble task doesn't invoke all subprojects' assemble tasks as expected,
//(it only does at the command-line 'gradlew assemble' command, but not within this build script)
//so explicitly force this assemble task to depend on all subprojects' equivalent ones,
//because many other tasks depend on this behaviour of the assemble task
subprojects.forEach { assemble.dependsOn it.assemble }
configurations {
izpack
}
dependencies {
izpack 'org.codehaus.izpack:izpack-ant:5.1.3'
}
clean {
//additional folder to delete
delete outputDistDir
}
//custom tasks for creating zip distributions
def createZipDistribution(distType) {
def distTypes = ['base', 'standard', 'optional']
if (!distTypes.contains(distType)) {
throw new GradleException("Wrong distribution type: ${distType}. Valid distribution types are: $distTypes")
}
return tasks.create("zip${distType}Task", Zip) {
dependsOn assemble
destinationDirectory = file("$buildDir/plainZip")
def internalFolder = 'squirrelsql-' + project.version + '-' + distType
archiveFileName = internalFolder + '.zip'
into internalFolder
def pluginList
if (distType == 'base') {
pluginList = []
}
else if (distType == 'standard') {
pluginList = [
'codecompletion',
'dataimport',
'dbcopy',
'graph',
'laf',
'refactoring',
'sqlbookmark',
'sqlscript',
'syntax',
]
}
else if (distType == 'optional') {
pluginList = gradle.allPlugins
}
from ('plainZipScripts') {
include '**/*'
}
//copy files from the 'launcher' folder, but don't overwrite
//the same files from the above 'plainZipScripts' folder
//(to prevent duplicate entries in the resulting zip file!)
from ('launcher') {
include '**/*'
duplicatesStrategy 'exclude'
}
from (project(':core').jar)
from (project(':core').projectDir) {
include 'lib/**', 'doc/**'
}
from (project(':versionChecker').jar) {
into 'lib'
}
pluginList.each { dirName ->
from (project(":$dirName").jar) {
into 'plugins'
}
from (project(":$dirName").projectDir) {
exclude 'src', 'build', 'build.gradle', 'bin', '.settings', '.classpath', '.project'
into "plugins/$dirName"
}
//dirty trick to include plugin folder even when it's empty
//(like the 'wikiTableConfigurations' plugin folder after all the above excludes)
//as empty folder is not included in the resulting zip file by Gradle by default
from({ file("$buildDir/tmp/plugins/$dirName/$dirName").mkdirs(); "$buildDir/tmp/plugins/$dirName" }) {
into 'plugins'
}
}
includeEmptyDirs = true
}
}
task copyMacOsxPlugin(type: Copy) {
into "$outputDistDir"
from (project(':macosx').jar) {
into 'plugins'
}
from (project(':macosx').projectDir) {
exclude 'src', 'build', 'build.gradle'
into 'plugins/macosx'
}
//force creation of empty plugin dir if need be
doLast {
file("$outputDistDir/plugins/macosx").mkdirs()
}
}
task copyToOutputDistDir {
dependsOn assemble
//use Ant's copy task which supports incremental copying (as Gradle's copy task doesn't)
doLast {
ant.copy(todir: "$outputDistDir") {
fileset(dir: 'launcher', includes: '**/*')
fileset(dir: project(':core').jar.destinationDirectory.get())
fileset(dir: project(':core').projectDir, includes: 'lib/**, doc/**')
}
ant.copy(todir: "$outputDistDir/lib") {
fileset(dir: project(':versionChecker').jar.destinationDirectory.get())
}
gradle.allPlugins.each { dirName ->
ant.copy(todir: "$outputDistDir/plugins") {
fileset(dir: project(":$dirName").jar.destinationDirectory.get())
}
ant.copy(todir: "$outputDistDir/plugins/$dirName") {
fileset(dir: project(":$dirName").projectDir,
excludes: '.classpath, .project, .settings/, bin/, build/, build.gradle, src/**/*')
}
delete "$outputDistDir/plugins/$dirName/src"
}
}
}
//task for creating IzPack installer jars
//which depend on the 'output/dist' folder to be populated (if not already)
task createIzPackInstallerJars {
dependsOn copyToOutputDistDir, copyMacOsxPlugin
def destDir = "$buildDir/izPackInstallJars"
doLast {
mkdir destDir
ant.taskdef(name: 'izpack',
classpath: configurations.izpack.asPath,
classname: 'com.izforge.izpack.ant.IzPackTask')
ant.property(name: 'squirrelsql.version', value: project.version)
ant.izpack(basedir: projectDir.path,
input: file('installer/other/izpack-other.xml').path,
output: "$destDir/squirrel-sql-${project.version}-standard.jar",
installerType: 'standard',
//compression: 'deflate',
//compressionlevel: '9',
inheritAll: 'true')
ant.izpack(basedir: projectDir.path,
input: file('installer/mac/izpack-mac.xml').path,
output: "$destDir/squirrel-sql-${project.version}-MACOS-install.jar",
installerType: 'standard',
//compression: 'deflate',
//compressionlevel: '9',
inheritAll: 'true')
}
}
task runApp(type: JavaExec) {
description = 'Run the SquirrelSQL app with all plugins available'
dependsOn copyToOutputDistDir
//run the executable squirrel-sql.jar in 'output/dist' directory
classpath = files("$outputDistDir/squirrel-sql.jar")
workingDir = file("$outputDistDir")
jvmArgs = [
'-splash:icons/splash.jpg',
]
debugOptions {
enabled = true
port = 5566
server = true
suspend = false
}
}
task buildExInstaller {
dependsOn createZipDistribution('base'),
createZipDistribution('standard'),
createZipDistribution('optional')
}
task buildAll {
dependsOn buildExInstaller,
createIzPackInstallerJars
}