-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathbuild.gradle
More file actions
164 lines (146 loc) · 4.06 KB
/
build.gradle
File metadata and controls
164 lines (146 loc) · 4.06 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
plugins {
id 'java'
id 'application'
}
defaultTasks 'dist'
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
repositories {
// Empty - using local JAR files only
}
dependencies {
implementation files('jars/capi.jar')
implementation files('jars/bcp47j.jar')
implementation files('jars/json.jar')
implementation files('jars/sqlite-jdbc-3.50.3.0.jar')
implementation files('jars/tmxvalidator.jar')
implementation files('jars/xmljava.jar')
}
application {
mainModule = 'tmxserver'
}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs = ['src']
exclude '**/*.java'
}
}
}
compileJava {
outputs.upToDateWhen { false } // Always rebuild
doFirst {
delete 'out'
mkdir 'out'
}
options.compilerArgs = ['--module-path', configurations.compileClasspath.asPath]
destinationDirectory = file('out')
doLast {
copy {
from 'src'
into 'out'
exclude '**/*.java'
}
println "✓ Java compilation and resource copying completed"
}
}
tasks.register('createJar', Jar) {
dependsOn compileJava
outputs.upToDateWhen { false }
description = 'Build tmxserver.jar file'
group = 'build'
archiveBaseName = 'tmxserver'
destinationDirectory = file('jars')
from 'out'
doFirst {
delete 'jars/tmxserver.jar'
}
include '**/*'
exclude '**/*.java'
manifest {
attributes(
'Automatic-Module-Name': 'tmxserver',
'Module-Path': configurations.runtimeClasspath.asPath
)
}
doLast {
println "✓ 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', 'tmxserver',
'--output', 'dist',
'--verbose'
doLast {
def jrtFile = file('dist/lib/jrt-fs.jar')
if (jrtFile.exists()) {
delete jrtFile
}
println "✓ Runtime image created successfully"
}
}
tasks.register('copyWindows') {
dependsOn linkJava
outputs.upToDateWhen { false }
onlyIf { System.getProperty('os.name').toLowerCase().contains('windows') }
doLast {
delete 'bin', 'conf', 'include', 'legal', 'lib', 'release'
copy { from 'dist/bin'; into 'bin' }
copy { from 'dist/conf'; into 'conf' }
copy { from 'dist/include'; into 'include' }
copy { from 'dist/legal'; into 'legal' }
copy { from 'dist/lib'; into 'lib' }
copy { from 'dist/release'; into '.' }
delete 'dist', 'build', 'out'
}
}
tasks.register('copyUnix') {
dependsOn linkJava
outputs.upToDateWhen { false }
onlyIf { !System.getProperty('os.name').toLowerCase().contains('windows') }
doLast {
delete 'bin', 'conf', 'include', 'legal', 'lib', 'release'
copy { from 'dist/bin'; into 'bin' }
copy { from 'dist/conf'; into 'conf' }
copy { from 'dist/include'; into 'include' }
copy { from 'dist/legal'; into 'legal' }
copy { from 'dist/lib'; into 'lib' }
copy { from 'dist/release'; into '.' }
delete 'dist', 'build', 'out'
}
}
tasks.register('dist') {
dependsOn copyWindows, copyUnix
outputs.upToDateWhen { false }
description = 'Prepare distribution'
doFirst {
println "✓ Starting distribution build..."
}
doLast {
delete 'jars/tmxserver.jar'
println "✓ Distribution ready"
}
}
tasks.register('distclean', Delete) {
delete 'dist', 'bin', 'conf', 'include', 'legal', 'lib', 'release'
}
clean {
delete 'out', 'build'
}