This repository has been archived by the owner on May 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
164 lines (146 loc) · 5.54 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
plugins {
id 'java'
}
def dateString = getDate()
group 'com.fbdev.helios'
assert JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17) : "Java 17 or newer is required"
//version dateString
version dateString + '-SNAPSHOT'
def jarNameHead = rootProject.name + "-" + version
repositories {
mavenCentral()
}
dependencies {
//START helios
implementation group: 'com.google.guava', name: 'guava', version: '31.1-jre'
implementation group: 'org.jctools', name: 'jctools-core', version: '3.3.0'
implementation group: 'org.jaudiolibs', name: 'audioservers-javasound', version: '2.0.0'
implementation group: 'org.digitalmediaserver', name: 'cuelib-core', version: '2.0.0'
implementation group: 'com.github.trilarion', name: 'java-vorbis-support', version: '1.2.1'
implementation group: 'net.java.jinput', name: 'jinput', version: '2.0.9'
implementation 'com.formdev:flatlaf:2.6'
implementation('com.google.code.gson:gson:2.10')
implementation 'org.tinylog:tinylog-api:2.5.0'
implementation 'org.tinylog:tinylog-impl:2.5.0'
implementation 'org.tinylog:slf4j-tinylog:2.5.0'
//include local jars
implementation fileTree(dir: 'lib', include: ['*.jar'])
//END helios
implementation group: 'org.ow2.asm', name: 'asm', version: '9.3'
implementation group: 'org.ow2.asm', name: 'asm-commons', version: '9.3'
implementation group: 'org.ow2.asm', name: 'asm-util', version: '9.3'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}
test {
useJUnitPlatform()
}
def static getDate() {
String date = new Date().format('yyMMdd')
date.substring(0,2) + "." + date.substring(2)
}
//create a single Jar with all dependencies
task fatJar(type: Jar) {
dependsOn "compileJava"
manifest {
attributes 'Implementation-Title': 'Helios',
'Implementation-Version': archiveVersion,
'Main-Class': 'omegadrive.SystemLoader'
}
duplicatesStrategy= "exclude"
getArchiveBaseName().set(project.name + "-all")//+ version
from { configurations.compileClasspath.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: "+ getArchiveFileName().getOrNull() +" in folder: " + destinationDirectory.getOrNull())
}
}
task copyRes {
copy {
from {
["CREDITS.md", "README.md", "HISTORY.md",
"LICENSE.md", "helios.properties"]
}
into "$buildDir/packageDir"
}
copy {
from (".") {
include "lib/**"
}
into "$buildDir/packageDir"
}
copy {
from configurations.runtimeClasspath
into "$buildDir/packageDir/lib"
}
copy {
from("res")
exclude "misc/**", "roms/**"
into "$buildDir/packageDir/res"
}
}
jar {
manifest {
attributes 'Implementation-Title': 'Helios',
'Implementation-Version': archiveVersion,
'Main-Class': 'omegadrive.SystemLoader',
'Class-Path': configurations.compileClasspath.collect { "lib/" + it.getName() }.join(' ')
}
archivesBaseName = rootProject.name
destinationDirectory = file("$buildDir/packageDir")
doLast {
println("Creating jar: " + jar.getArchiveName() + " in folder: " + jar.getDestinationDir())
}
}
task packageDistribution(type: Zip) {
dependsOn "test", "jar", "copyRes", "writeToFile"
archiveFileName = jarNameHead + ".zip"
destinationDirectory = file("$buildDir/dist")
from "$buildDir/packageDir"
doLast {
println("Creating package: " + getArchiveFileName().getOrNull() +
", folder: " + getDestinationDirectory().getOrNull())
}
}
task 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",
"-Dkey.config.file=key.config.1p",
"-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( "${buildDir}/packageDir")
if( !extraFolder.exists() ) {
extraFolder.mkdirs()
}
// create the file and write text to it.
new File("${buildDir}/packageDir/launcher.sh").text = sampleUx.join (" ")
new File("${buildDir}/packageDir/launcher.bat").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)"
}
}
}
}