-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle
More file actions
213 lines (182 loc) · 4.44 KB
/
build.gradle
File metadata and controls
213 lines (182 loc) · 4.44 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
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
plugins {
id 'java'
id 'application'
}
defaultTasks 'dist'
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
// No repositories needed since we're using local JARs
repositories {
// Empty - using local JAR files only
}
dependencies {
implementation files('jars/bcp47j.jar')
implementation files('jars/json.jar')
implementation files('jars/jsoup.jar')
implementation files('jars/openxliff.jar')
implementation files('jars/xmljava.jar')
}
application {
mainModule = 'stingray'
}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs = ['src']
exclude '**/*.java'
}
}
}
compileJava {
outputs.upToDateWhen { false }
doFirst {
// Ensure a clean output folder before each compilation
delete 'out'
mkdir 'out'
}
options.compilerArgs = ['--module-path', configurations.compileClasspath.asPath]
destinationDirectory = file('out')
doLast {
// Copy non-Java resources alongside compiled classes
copy {
from 'src'
into 'out'
exclude '**/*.java'
}
println "\u2713 Java compilation and resource copying completed"
}
}
tasks.register('createJar', Jar) {
dependsOn compileJava
outputs.upToDateWhen { false }
description = 'Build stingray.jar file'
group = 'build'
archiveBaseName = 'stingray'
destinationDirectory = file('jars')
from 'out'
doFirst {
delete 'jars/stingray.jar'
}
include '**/*'
exclude '**/*.java'
manifest {
attributes(
'Automatic-Module-Name': 'stingray',
'Module-Path': configurations.runtimeClasspath.asPath
)
}
doLast {
println "\u2713 JAR created: ${archiveFile.get()}"
}
}
tasks.register('linkJava', Exec) {
dependsOn createJar
outputs.upToDateWhen { false }
doFirst {
delete 'dist'
}
def pathSeparator = File.pathSeparator
def fileSeparator = File.separator
def javaHome = System.getProperty('java.home')
def jmodsPath = javaHome + fileSeparator + 'jmods'
def modulePath = 'jars' + pathSeparator + jmodsPath
commandLine 'jlink',
'--module-path', modulePath,
'--add-modules', 'stingray',
'--output', 'dist',
'--verbose'
doLast {
def jrtFile = file('dist/lib/jrt-fs.jar')
if (jrtFile.exists()) {
delete jrtFile
}
println "\u2713 Runtime image created successfully"
}
}
tasks.register('copyWindows') {
dependsOn linkJava
outputs.upToDateWhen { false }
onlyIf { System.getProperty('os.name').toLowerCase().contains('windows') }
doLast {
delete 'bin', 'conf', 'legal', 'lib'
delete 'release'
copy {
from 'dist/bin'
into 'bin'
}
copy {
from 'dist/conf'
into 'conf'
}
copy {
from 'dist/legal'
into 'legal'
}
copy {
from 'dist/lib'
into 'lib'
}
copy {
from 'dist/release'
into '.'
}
delete 'dist'
delete 'build'
delete 'out'
}
}
tasks.register('copyUnix') {
dependsOn linkJava
outputs.upToDateWhen { false }
onlyIf { !System.getProperty('os.name').toLowerCase().contains('windows') }
doLast {
delete 'bin', 'conf', 'legal', 'lib'
delete 'release'
copy {
from 'dist/bin'
into 'bin'
}
copy {
from 'dist/conf'
into 'conf'
}
copy {
from 'dist/legal'
into 'legal'
}
copy {
from 'dist/lib'
into 'lib'
}
copy {
from 'dist/release'
into '.'
}
delete 'dist'
delete 'build'
delete 'out'
}
}
tasks.register('dist') {
dependsOn copyWindows, copyUnix
outputs.upToDateWhen { false }
description = 'Prepare distribution'
doFirst {
println "\u2713 Starting distribution build..."
}
doLast {
delete 'jars/stingray.jar'
println "\u2713 Distribution ready"
}
}
tasks.register('distclean', Delete) {
delete 'dist', 'bin', 'conf', 'include', 'legal', 'lib', 'release'
}
clean {
delete 'out', 'build'
}