/
build.gradle
189 lines (167 loc) · 5.44 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'java'
}
group 'io.github.barteks2x.swtnativeimageexample'
version '1.0'
archivesBaseName = "SWTExample"
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
jcenter()
maven {
setUrl("https://oss.sonatype.org/content/groups/public/")
}
maven { url "https://repo.eclipse.org/content/groups/releases/"}
}
configurations {
linux_amd64
win32_amd64
win32_x86
macos_amd64
shadow
compileClasspath.extendsFrom(shadow)
runtimeClasspath.extendsFrom(shadow)
}
ext {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
osgi_platform = 'win32.win32.x86_64'
} else if (Os.isFamily(Os.FAMILY_MAC)) {
osgi_platform = 'cocoa.macosx.x86_64'
} else {
osgi_platform = 'gtk.linux.x86_64'
}
swt_version = '3.114.0'
}
sourceSets {
main
native_image {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
windows64 {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
linux {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
mac {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
}
configurations.all {
resolutionStrategy {
dependencySubstitution {
// The maven property ${osgi.platform} is not handled by Gradle
// so we replace the dependency, using the osgi platform from the project settings
substitute module('org.eclipse.platform:org.eclipse.swt.${osgi.platform}') with module("org.eclipse.platform:org.eclipse.swt.$osgi_platform:$swt_version")
}
}
}
dependencies {
linux_amd64("org.eclipse.platform:org.eclipse.swt.gtk.linux.x86_64:3.114.0") {
transitive = false
}
win32_amd64("org.eclipse.platform:org.eclipse.swt.win32.win32.x86_64:3.114.0") {
transitive = false
}
win32_x86("org.eclipse.platform:org.eclipse.swt.win32.win32.x86:3.108.0") {// this is the last version with x86 support
transitive = false
}
//macos_amd64("org.eclipse.platform:org.eclipse.swt.cocoa.macosx.x86_64:3.114.0") {
// transitive = false
//}
// workaround for https://github.com/oracle/graal/issues/2232
macos_amd64(files("lib/swt-javac.jar"))
shadow group: 'com.google.code.gson', name: 'gson', version: '2.3.1'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation "org.eclipse.platform:org.eclipse.swt:3.108.0"
}
task universalJar(type: Jar) {
exclude("META-INF/*.SF")
exclude("META-INF/*.RSA")
from(sourceSets["main"].output)
if ("true" == getProperty("swtexample.noversion")) {
archiveVersion.set("");
}
archiveClassifier.set("universal")
into("/linux") {
from(configurations.linux_amd64.files)
rename '(.+)', 'swt.jar'
}
into("/windows64") {
from(configurations.win32_amd64.files)
rename '(.+)', 'swt.jar'
}
into("/windows32") {
from(configurations.win32_x86.files)
rename '(.+)', 'swt.jar'
}
into("/mac") {
from(configurations.macos_amd64.files)
rename '(.+)', 'swt.jar'
}
dependsOn configurations.shadow
from {
configurations.shadow.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
manifest {
attributes(
'Main-Class': 'io.github.barteks2x.swtnativeimageexample.jarloader.JarLoadMain'
)
}
}
task jarLinux(type: ShadowJar) {
exclude("META-INF/*.SF")
exclude("META-INF/*.RSA")
from(sourceSets["main"].output, sourceSets["native_image"].output, sourceSets["linux"].output)
configurations = [project.configurations.shadow, project.configurations.linux_amd64]
if ("true" == getProperty("swtexample.noversion")) {
archiveVersion.set("");
}
archiveClassifier.set("linux")
manifest {
attributes(
'Main-Class': 'io.github.barteks2x.swtnativeimageexample.swt.GuiMain'
)
}
}
task jarWindows(type: ShadowJar) {
exclude("META-INF/*.SF")
exclude("META-INF/*.RSA")
from(sourceSets["main"].output, sourceSets["native_image"].output, sourceSets["windows64"].output)
configurations = [project.configurations.shadow, project.configurations.win32_amd64]
if ("true" == getProperty("swtexample.noversion")) {
archiveVersion.set("");
}
archiveClassifier.set("windows")
manifest {
attributes(
'Main-Class': 'io.github.barteks2x.swtnativeimageexample.swt.GuiMain'
)
}
}
task jarMac(type: ShadowJar) {
exclude("META-INF/*.SF")
exclude("META-INF/*.RSA")
from(sourceSets["main"].output, sourceSets["native_image"].output, sourceSets["mac"].output)
configurations = [project.configurations.shadow, project.configurations.macos_amd64]
if ("true" == getProperty("swtexample.noversion")) {
archiveVersion.set("");
}
archiveClassifier.set("mac")
manifest {
attributes(
'Main-Class': 'io.github.barteks2x.swtnativeimageexample.swt.GuiMain'
)
}
}
build.dependsOn(jarMac, jarLinux, jarWindows, universalJar)