-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle
182 lines (164 loc) · 6.85 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
def dateString = getDate()
group 'com.fbdev.helios'
//version dateString
version dateString + '-SNAPSHOT'
def jarNameHead = rootProject.name + "-" + version
String packageDir = getLayout().getBuildDirectory().dir("packageDir").get()
assert JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17) : "Java 17 or newer is required"
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/net.java.jinput/jinput
implementation group: 'net.java.jinput', name: 'jinput', version: '2.0.10'
// https://mvnrepository.com/artifact/com.google.guava/guava
implementation group: 'com.google.guava', name: 'guava', version: '33.3.0-jre'
implementation group: 'org.jctools', name: 'jctools-core', version: '4.0.4'
// https://mvnrepository.com/artifact/org.digitalmediaserver/cuelib-core
implementation group: 'org.digitalmediaserver', name: 'cuelib-core', version: '2.0.0'
implementation group: 'com.github.trilarion', name: 'java-vorbis-support', version: '1.2.1'
// https://mvnrepository.com/artifact/org.jaudiolibs/audioservers-javasound
implementation group: 'org.jaudiolibs', name: 'audioservers-javasound', version: '2.0.0'
implementation 'com.google.code.gson:gson:2.11.0'
implementation 'com.formdev:flatlaf:3.5.4'
implementation group: 'org.ow2.asm', name: 'asm', version: '9.7.1'
implementation group: 'org.ow2.asm', name: 'asm-commons', version: '9.7.1'
implementation group: 'org.ow2.asm', name: 'asm-util', version: '9.7.1'
implementation 'org.tinylog:tinylog-api:2.7.0'
implementation 'org.tinylog:tinylog-impl:2.7.0'
implementation 'org.tinylog:slf4j-tinylog:2.7.0'
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.11.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.11.0'
//include local jars
implementation fileTree(dir: 'lib', include: ['*.jar'])
testImplementation fileTree(dir: 'lib', include: ['*.jar'])
}
def static getDate() {
String date = new Date().format('yyMMdd')
date.substring(0,2) + "." + date.substring(2)
}
//create a single Jar with all dependencies
tasks.register('fatJar', Jar) {
manifest {
attributes 'Implementation-Title': 'Helios',
'Implementation-Version': archiveVersion,
'Main-Class': 'omegadrive.SystemLoader'
}
getArchiveBaseName().set(project.name + "-all")//+ version
from { configurations.implementation.collect { it.isDirectory() ? it : zipTree(it) } }
from {
["CREDITS.md", "README.md", "HISTORY.md", "LICENSE.md", "helios.properties"]
}
from("bios") {
include "*.rom"
}
with jar
doLast {
println("Creating fatJar in folder: " + destinationDirectory)
}
}
tasks.register('copyRes') {
copy {
from(".") {
include "res/**"
}
into packageDir
exclude "**/*.col", "**/bios.sms", "**/site/**", "**/misc/**", "**/sms/**", "**/mcd/**"
}
copy {
from {
["CREDITS.md", "README.md", "HISTORY.md",
"LICENSE.md", "helios.properties", "key.config.1p"]
}
into packageDir
}
copy {
from(".") {
include "lib/**"
}
into packageDir
}
copy {
from configurations.runtimeClasspath
into packageDir + "/lib"
}
}
jar {
manifest {
attributes 'Implementation-Title': 'Helios',
'Implementation-Version': archiveVersion,
'Main-Class': 'omegadrive.SystemLoader',
'Class-Path': configurations.compileClasspath.collect { "lib/" + it.getName() }.join(' ')
}
getArchiveBaseName().set(rootProject.name)
destinationDirectory = file(packageDir)
doLast {
println("Creating jar: " + getArchiveFileName().getOrNull() +
" in folder: " + getDestinationDirectory().getOrNull())
}
}
tasks.register('jarWithSources', org.gradle.jvm.tasks.Jar) {
from sourceSets.main.allSource
manifest {
attributes 'Implementation-Title': 'Helios',
'Implementation-Version': archiveVersion,
'Main-Class': 'omegadrive.SystemLoader',
'Class-Path': configurations.compileClasspath.collect { "lib/" + it.getName() }.join(' ')
}
getArchiveFileName().set(rootProject.name + "-binsrc-${project.version}.jar")
destinationDirectory = file(packageDir)
with jar
doLast {
println("Creating jar with sources: " + getArchiveFileName().getOrNull() +
" in folder: " + getDestinationDirectory().getOrNull())
}
}
tasks.register('packageDistribution', Zip) {
dependsOn "test", "jar", "copyRes", "writeToFile"
archiveFileName = jarNameHead + ".zip"
destinationDirectory = file(getLayout().getBuildDirectory().dir("dist"))
from packageDir
doLast {
println("Creating package: " + getArchiveFileName().getOrNull() +
", folder: " + getDestinationDirectory().getOrNull())
println("" + getDestinationDirectory().getOrNull() + "/" + getArchiveFileName().getOrNull())
}
}
tasks.register('writeToFile') {
String jarName = jarNameHead + ".jar"
List<String> javaAdvOpts =
["-XX:AutoBoxCacheMax=65536", "-XX:-DontCompileHugeMethods", "-XX:+AlwaysCompileLoopMethods"]
//win: default to busy wait
List<String> winOpts = ["-Dhelios.busy.wait=true"]
List<String> sampleBase = ["java",
"-Dtinylog.configuration=./res/tinylog.properties",
"-Djinput.enable=true -Djinput.native.location=lib",
"-jar", "$jarName"] as String[]
sampleBase.addAll(1, javaAdvOpts)
List<String> sampleUx = new ArrayList<>(sampleBase)
sampleUx.add("\"\$@\"" + "\n")
List<String> sampleWin = new ArrayList<>(sampleBase)
sampleWin.addAll(1, winOpts)
sampleWin.add("\"%1\"" + "\n")
// create the folders if it does not exist.(otherwise it will throw exception)
File extraFolder = new File(packageDir)
if (!extraFolder.exists()) {
extraFolder.mkdirs()
}
// create the file and write text to it.
Directory dir = getLayout().getBuildDirectory().dir("packageDir").get()
dir.file("launcher.sh").getAsFile().text = sampleUx.join(" ")
dir.file("launcher.bat").getAsFile().text = sampleWin.join(" ")
}
test {
testLogging {
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
}
}
}
}