-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
279 lines (217 loc) · 8.49 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
270
271
272
273
274
275
276
277
import java.text.*
subprojects {
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'jacoco'
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
javadoc {
failOnError = false
}
// put sources into jar
jar {
from sourceSets.main.allSource
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
artifacts {
archives sourcesJar
archives javadocJar
}
java {
reporting.baseDir = "${rootProject.buildDir.path}/reports/${project.name}"
}
jacocoTestReport {
reports {
xml.enabled = true
csv.enabled = false
html.enabled = true
html.destination = file("${buildDir}/reports/jacoco/html")
}
}
}
def exportedProjects = [
":aprint-core",
":aprint-gui",
":aprint-machine-control",
":aprint-punch-extension",
":aprint-recognition-extension",
":aprint-book-scanner",
]
task alljavadoc(type: Javadoc, dependsOn: [ ":aprint-gui:groovydoc"]) {
failOnError = false
source exportedProjects.collect { project(it).sourceSets.main.allJava }
classpath = files(exportedProjects.collect { project(it).sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
}
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Combine all 'test' task results into a single HTML report
reportOn subprojects.collect { it.tasks.withType(Test) }
}
rootProject.ext.execAndGetOutput = { String command ->
try {
def stdout = new ByteArrayOutputStream()
exec {
workingDir rootProject.projectDir
commandLine command.split()
standardOutput = stdout
}
return stdout.toString().trim()
}
catch (Exception e) {
return null
}
}
rootProject.ext.asUTC = { Date date, String format ->
def snapshotDateFormat = new SimpleDateFormat(format)
snapshotDateFormat.setTimeZone(TimeZone.getTimeZone('UTC'))
return snapshotDateFormat.format(date)
}
rootProject.ext.getRevision = {
String currentCommit = execAndGetOutput("git rev-parse HEAD")
return (currentCommit != null) ? currentCommit : "UNKNOWN"
}
rootProject.ext.isApplicationRelease = {
String currentBranches = execAndGetOutput("git log -n 1 --pretty=%d HEAD")
return currentBranches.contains("master")
}
rootProject.ext.currentVersion = "UNKNOWN"
def nsis_home = "D:\\windows\\NSIS"
// define here the bundle project
project(':bundle') {
task copyExtensionJars(type:Copy, dependsOn: [':aprint-book-scanner:fatJar', ':aprint-punch-extension:fatJar', ':aprint-recognition-extension:fatJar']) {
into 'offlineinstall-extensions'
into ('Scan') {
from project(':aprint-book-scanner').fileTree('build/libs') {
include "*.extension"
include "*.extensionlazy"
}
}
into ('Punch') {
from project(':aprint-punch-extension').fileTree('build/libs') {
include "*.extension"
}
}
into ('DiskAndBookRecognition') {
from project(':aprint-recognition-extension').fileTree('build/libs') {
include "*.extension"
}
}
}
task copyOutputJars(type:Copy,dependsOn: [':aprint-machine-control:jar',':aprint-gui:jar', ':aprint-gui:fatJar',
':aprint-core:jar',':aprint-core:sourcesJar',
':aprint-core:javadocJar',
':aprint-gui:javadocJar',
':aprint-gui:sourcesJar' ] ) {
from project(':aprint-gui').file('build/libs')
from project(':aprint-core').file('build/libs')
into 'build'
}
task createAllJars(dependsOn: [copyOutputJars, copyExtensionJars]) {
}
task createNixMacBundle(type:Zip , dependsOn: [createAllJars]) {
archiveName "nix-and-macosX.zip"
from ('build') { include 'aprint.jar' }
from ('offlineinstall-extensions') { include '**/*' }
from ('maxosx-bundle') { include '**/*' }
}
task generateSources(type: Copy) {
outputs.upToDateWhen { false }
from ('offlineinstall-studio/templates_installer') {
include '*.nsi'
}
into "offlineinstall-studio"
filter { line -> line.replaceAll('____VERSION____', '' + rootProject.ext.currentVersion) }
}
// create installer
task createBundles(type: Exec, dependsOn: [copyOutputJars,copyExtensionJars,generateSources] ) {
commandLine nsis_home + '\\makensis.exe',
"${project.projectDir}/offlineinstall-studio/aprint_studio.nsi"
workingDir = 'offlineinstall-studio'
}
// create installer
task createBundlesSimple(type: Exec, dependsOn: [copyOutputJars,copyExtensionJars,generateSources] ) {
commandLine nsis_home + '\\makensis.exe',
"${project.projectDir}/offlineinstall-studio/aprint_studio_simple.nsi"
workingDir = 'offlineinstall-studio'
}
// create x64 installer
task createInstaller(dependsOn: ['createBundles']) {
doLast {
def f = file('offlineinstall-studio/APrintStudioInstall.exe')
assert f.exists()
assert f.renameTo(new File('build_file_x64_APrintStudioInstall_' + rootProject.ext.currentVersion + ".exe"))
}
}
// create x64 installer simple
task createInstallerSimple(dependsOn: ['createBundlesSimple']) {
doLast {
def f = file('offlineinstall-studio/APrintStudioInstall.exe')
assert f.exists()
assert f.renameTo(new File('build_file_x64_simple_APrintStudioInstall_' + rootProject.ext.currentVersion + ".exe"))
}
}
// create installer
task createBundles32(type: Exec, dependsOn: [copyOutputJars,copyExtensionJars, generateSources] ) {
commandLine nsis_home + '\\makensis.exe',
"${project.projectDir}/offlineinstall-studio/aprint_studio_32.nsi"
workingDir = 'offlineinstall-studio'
}
// create installer simple
task createBundles32simple(type: Exec, dependsOn: [copyOutputJars,copyExtensionJars,generateSources] ) {
commandLine nsis_home + '\\makensis.exe',
"${project.projectDir}/offlineinstall-studio/aprint_studio_32_simple.nsi"
workingDir = 'offlineinstall-studio'
}
// create x86 installer
task createInstaller32(dependsOn: ['createBundles32']) {
doLast {
def f = file('offlineinstall-studio/APrintStudioInstall32.exe')
assert f.exists()
assert f.renameTo(new File('build_file_x32_APrintStudioInstall_' + rootProject.ext.currentVersion + ".exe"))
}
}
// create simple x86 installer
task createInstallerSimple32(dependsOn: ['createBundles32simple']) {
doLast {
def f = file('offlineinstall-studio/APrintStudioInstall32.exe')
assert f.exists()
assert f.renameTo(new File('build_file_x32_simple_APrintStudioInstall_' + rootProject.ext.currentVersion + ".exe"))
}
}
// create zip for linux and macos
task createMacOsAndLinuxBundle(dependsOn: ['createNixMacBundle']) {
doLast {
def f = file('build/distributions/nix-and-macosX.zip')
assert f.exists()
assert f.renameTo(new File('build_file_NixAndMacOsX_' + rootProject.ext.currentVersion + ".zip"))
}
}
task createAllInstallers(dependsOn: ['createInstallerSimple', 'createInstaller', 'createInstaller32','createInstallerSimple32','createMacOsAndLinuxBundle']) {
}
task copyMainJarToInstallerFolder(type: Copy, dependsOn: [copyOutputJars, copyExtensionJars]) {
from ('build') { include 'aprint.jar'}
from ('.') { include 'icon.jpg'}
into "build/installFolder"
}
// using jpackage
task prepareInstallerFolder(type: Copy, dependsOn: [copyMainJarToInstallerFolder]) {
from('offlineinstall-extensions') { include '**/*' }
from ('maxosx-bundle') { include '**/*' }
eachFile { fcd ->
fcd.path = fcd.name
}
into "build/installFolder/aprintstudio"
}
task createjpackage(type: Exec , dependsOn: [prepareInstallerFolder] ) {
commandLine "${System.env.JAVA_HOME}/bin/jpackage",
"@${project.projectDir}/../jpackage-image.cfg"
workingDir "${project.projectDir}/.."
}
}