-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
155 lines (136 loc) · 3.83 KB
/
build.gradle
File metadata and controls
155 lines (136 loc) · 3.83 KB
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
/* Copyright (C) 2015 American Printing House for the Blind Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("net.java.dev.jna:jna:5.14.0")
}
}
import com.sun.jna.Platform as JnaPlatform
import org.panteleyev.jpackage.ImageType
plugins {
id "java"
id "application"
id "maven-publish"
id "org.panteleyev.jpackageplugin" version "1.6.0"
}
compileJava {
options.release = 17
}
group = "org.aph.braillezephyr"
version = "1.0"
publishing {
publications {
brailleZephyr(MavenPublication) {
from(components.java)
}
}
}
application {
mainClass = "org.aph.braillezephyr.Main"
}
String swtOS
switch (JnaPlatform.getOSType()) {
case JnaPlatform.WINDOWS:
swtOS = "win32.win32"
break
case JnaPlatform.MAC:
swtOS = "cocoa.macosx"
break
case JnaPlatform.LINUX:
swtOS = "gtk.linux"
break
default:
throw new RuntimeException("Unsupported OS")
}
String swtArch
if (JnaPlatform.isIntel()) {
swtArch = JnaPlatform.is64Bit() ? "x86_64" : "x86"
} else if (JnaPlatform.isARM() && JnaPlatform.is64Bit()) {
swtArch = "aarch64"
} else {
throw new RuntimeException("Unsupported architecture")
}
String swtVersion = "3.124.+"
String swtPlatform = "${swtOS}.${swtArch}"
if (JnaPlatform.isMac()) {
application.applicationDefaultJvmArgs.add("-XstartOnFirstThread")
}
configurations.configureEach {
resolutionStrategy {
dependencySubstitution {
substitute module("org.eclipse.platform:org.eclipse.swt.\${osgi.platform}") using module("org.eclipse.platform:org.eclipse.swt.${swtPlatform}:${swtVersion}")
}
}
}
dependencies {
implementation("org.eclipse.platform:org.eclipse.swt:${swtVersion}")
}
ext.defaultManifest = java.manifest {
attributes("Main-Class": application.mainClass,
"Implementation-Version": version)
}
tasks.jar {
manifest = project.java.manifest {
from(defaultManifest)
}
archiveBaseName = "BrailleZephyr"
}
tasks.register("copyDependencies", Copy) {
from(configurations.runtimeClasspath)
into("${layout.buildDirectory.get()}/jpackage-app")
}
tasks.register("copyJar", Copy) {
from(tasks.jar)
into("${layout.buildDirectory.get()}/jpackage-app")
}
tasks.jpackage {
dependsOn("build", "copyDependencies", "copyJar")
verbose = true
input = "${layout.buildDirectory.get()}/jpackage-app"
destination = "${layout.buildDirectory.get()}/dist"
appName = "BrailleZephyr"
appVersion = version
vendor = "American Printing House for the Blind"
mainJar = tasks.jar.archiveFileName.get()
mainClass = application.mainClass.get()
javaOptions = application.applicationDefaultJvmArgs.asList()
addModules = ["java.desktop"]
windows {
winDirChooser = true
winMenu = true
winShortcut = true
winShortcutPrompt = true
winConsole = false
}
mac {
type = ImageType.APP_IMAGE
macAppStore = false
macPackageIdentifier = "org.aph.BrailleZephyr"
macPackageName = "BrailleZephyr"
macSign = false
}
}
run {
systemProperties["braillezephyr.version"] = version
}
tasks.wrapper {
gradleVersion = "8.5"
}
repositories {
mavenCentral()
}