-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
212 lines (184 loc) · 6.87 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
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds
*/
// TODO: groovy要お勉強 (*_*;
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.nio.file.Files
import java.nio.file.Path
final def version = '0.19.1'
final def timetag = LocalDateTime.now().format(DateTimeFormatter.ofPattern('yyyyMMdd-HHmmss-SSS'))
final def baseDir = projectDir.toPath()
final def targetFatZip = baseDir.resolve('xyz.hotchpotch.hogandiff/build/distributions/xyz.hotchpotch.hogandiff.zip')
final def outputDir = baseDir.resolve('build/' + timetag)
final def outputDirTmpJars = outputDir.resolve("tmp/fat/xyz.hotchpotch.hogandiff/lib")
final def outputDirWinX64 = outputDir.resolve("hogandiff-${version}-win-x64")
final def outputDirMacX64 = outputDir.resolve("hogandiff-${version}-mac-x64")
// TODO: module-info.java なんもわからん
final def requiredMods = '' \
+ 'java.base,' \
+ 'java.desktop,' \
+ 'java.management,' \
+ 'java.xml,' \
+ 'javafx.base,' \
+ 'javafx.controls,' \
+ 'javafx.fxml,' \
+ 'javafx.graphics,' \
+ 'jdk.charsets,' \
+ 'jdk.zipfs'
task pickupAndExpandFatJar(type: Copy) {
group 'distribution_common'
from zipTree(targetFatZip)
into outputDir.resolve("tmp/fat")
}
// executable on [win-x64, mac-x64]
task jlinkForWinX64(type: Exec) {
group 'distribution_win_x64'
commandLine project['myprop.cmd.jlink'],
'--no-header-files',
'--no-man-pages',
'--module-path', "${project['myprop.jre.mod.win.x64']};${project['myprop.jfx.mod.win.x64']}",
'--add-modules', requiredMods,
'--output', outputDir.resolve('tmp/jre-min-win-x64'),
'--strip-debug',
'--verbose'
}
// executable on [win-x64, mac-x64]
task jlinkForMacX64(type: Exec) {
group 'distribution_mac_x64'
commandLine project['myprop.cmd.jlink'],
'--no-header-files',
'--no-man-pages',
'--module-path', "${project['myprop.jre.mod.mac.x64']};${project['myprop.jfx.mod.mac.x64']}",
'--add-modules', requiredMods,
'--output', outputDir.resolve('tmp/jre-min-mac-x64'),
'--strip-debug',
'--verbose'
}
// executable on [win-x64]
task exewrapForWinX64(type: Exec, dependsOn: pickupAndExpandFatJar) {
group 'distribution_win_x64'
commandLine project['myprop.cmd.exewrap'],
'-g',
// 直近の LTS-version とする。
'-t', '21',
'-i', baseDir.resolve('resources/favicon.ico'),
'-v', version,
'-V', version,
'-d', '方眼Diff',
'-p', '方眼Diff',
'-c', '(c) 2018-2024 nmby',
'-j', outputDirTmpJars.resolve("xyz.hotchpotch.hogandiff.jar"),
'-o', outputDirWinX64.resolve('hogandiff.exe')
}
// executable on [win-x64, mac-x64]
task gatherFilesForWinX64(dependsOn: [pickupAndExpandFatJar, jlinkForWinX64]) {
group 'distribution_win_x64'
doLast {
copy {
from baseDir
include 'README.md', 'LICENSE.txt', 'NOTICE.txt'
into outputDirWinX64
}
copy {
from baseDir.resolve('resources')
include 'hogandiff.exe.vmoptions'
into outputDirWinX64
}
copy {
from outputDirTmpJars
exclude "xyz.hotchpotch.hogandiff.jar"
into outputDirWinX64.resolve("lib")
}
copy {
from outputDir.resolve('tmp/jre-min-win-x64')
into outputDirWinX64.resolve("jre-min")
}
copy {
from project['myprop.poi.src']
include 'LICENSE', 'NOTICE'
into outputDirWinX64.resolve("lib/legal/poi")
}
copy {
from project['myprop.log4j.bin']
include 'LICENSE.txt', 'NOTICE.txt'
into outputDirWinX64.resolve("lib/legal/log4j")
}
}
}
// executable on [win-x64, mac-x64]
task gatherFilesForMacX64(dependsOn: [pickupAndExpandFatJar, jlinkForMacX64]) {
group 'distribution_mac_x64'
doLast {
copy {
from baseDir.resolve('resources/hogandiff.app')
exclude '**/.gitkeep'
into outputDirMacX64.resolve('hogandiff.app')
}
copy {
from baseDir
include 'README.md', 'LICENSE.txt', 'NOTICE.txt'
into outputDirMacX64.resolve('hogandiff.app/Contents/Resources')
}
copy {
from outputDirTmpJars
into outputDirMacX64.resolve('hogandiff.app/Contents/Java')
}
copy {
from outputDir.resolve('tmp/jre-min-mac-x64')
into outputDirMacX64.resolve('hogandiff.app/Contents/PlugIns/jre-min')
}
copy {
from project['myprop.poi.src']
include 'LICENSE', 'NOTICE'
into outputDirMacX64.resolve('hogandiff.app/Contents/Java/legal/poi')
}
copy {
from project['myprop.log4j.bin']
include 'LICENSE.txt', 'NOTICE.txt'
into outputDirMacX64.resolve('hogandiff.app/Contents/Java/legal/log4j')
}
}
}
// executable on [win-x64]
task zipForWinX64(type: Zip, dependsOn: [exewrapForWinX64, gatherFilesForWinX64]) {
group 'distribution_win_x64'
metadataCharset = 'UTF-8'
archiveBaseName = "hogandiff-${version}-win-x64"
destinationDirectory = file(outputDir)
from outputDirWinX64
into outputDirWinX64.getFileName().toString()
}
// executable on [win-x64, mac-x64]
task zipForMacX64(type: Zip, dependsOn: gatherFilesForMacX64) {
group 'distribution_mac_x64'
metadataCharset = 'UTF-8'
archiveBaseName = "hogandiff-${version}-mac-x64"
destinationDirectory = file(outputDir)
from outputDirMacX64
into outputDirMacX64.getFileName().toString()
}
// executable on [win-x64]
task allForWinX64(dependsOn: zipForWinX64) {
group 'distribution_win_x64'
}
// executable on [win-x64, mac-x64]
task allForMacX64(dependsOn: zipForMacX64) {
group 'distribution_mac_x64'
}
// executable on [win-x64]
task all(dependsOn: [allForWinX64, allForMacX64]) {
group 'distribution_common'
}
// executable on [win-x64, mac-x64]
task checkDependencies(type: Exec, dependsOn: pickupAndExpandFatJar) {
group 'test'
commandLine project['myprop.cmd.jdeps'],
// 直近の LTS-version とする。
'--multi-release', 21,
'--module-path', "${project['myprop.jre.mod.win.x64']};${project['myprop.jfx.lib.win.x64']};${outputDirTmpJars}",
'-s', outputDirTmpJars.resolve("xyz.hotchpotch.hogandiff.jar")
}