-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathbuild.gradle
More file actions
198 lines (180 loc) · 5.7 KB
/
build.gradle
File metadata and controls
198 lines (180 loc) · 5.7 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
import org.gradle.internal.os.OperatingSystem
import java.nio.file.*
plugins {
id 'java'
id 'application'
id 'eclipse'
id 'idea'
id 'org.openjfx.javafxplugin' version '0.1.0'
id 'com.gradleup.shadow' version '9.2.2'
id 'com.github.ben-manes.versions' version '0.52.0'
id 'org.beryx.runtime' version '2.0.1'
}
group = 'net.querz'
compileJava.options.encoding = 'UTF-8'
application.mainClass = 'net.querz.mcaselector.Main'
java.sourceCompatibility = JavaVersion.VERSION_21
var copyright = project.findProperty('application.copyright').toString()
var applicationName = project.findProperty('application.name').toString()
var matrixType = project.findProperty("matrixType").toString()
var projectName = project.name
var projectVersion = project.version
javafx {
version = "$java.sourceCompatibility"
modules = ['javafx.controls', 'javafx.swing']
}
idea {
module.downloadJavadoc = true
module.downloadSources = true
}
repositories {
mavenCentral()
maven { url = 'https://jitpack.io/' }
maven { url = 'https://plugins.gradle.org/m2/' }
}
dependencies {
implementation 'com.github.Querz:NBT:13516d666a'
implementation 'com.google.code.gson:gson:2.12.1'
implementation 'it.unimi.dsi:fastutil:8.5.15'
implementation 'org.apache.logging.log4j:log4j-api:2.24.3'
implementation 'org.apache.logging.log4j:log4j-core:2.24.3'
implementation 'org.slf4j:slf4j-simple:2.0.16'
implementation 'commons-cli:commons-cli:1.10.0'
implementation 'me.tongfei:progressbar:0.10.1'
implementation 'org.apache.groovy:groovy-jsr223:4.0.26'
implementation 'org.fxmisc.richtext:richtextfx:0.11.7'
implementation 'org.lz4:lz4-java:1.8.0'
implementation 'org.atteo.classindex:classindex:3.13'
implementation 'org.iq80.leveldb:leveldb:0.12'
annotationProcessor('org.atteo.classindex:classindex:3.13')
annotationProcessor('org.apache.logging.log4j:log4j-core:2.24.3')
testImplementation(platform('org.junit:junit-bom:6.0.1'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation('org.reflections:reflections:0.10.2')
testImplementation 'commons-io:commons-io:2.18.0'
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
}
compileJava {
options.compilerArgs += ['-Xlint:deprecation', '-Xlint:unchecked']
}
tasks.register('minifyCss') {
dependsOn processResources
doLast {
var styleDir = Path.of("${sourceSets.main.resources.srcDirs[0]}", "style")
Files.find(styleDir, Integer.MAX_VALUE, (filePath, fileAttr) -> fileAttr.isRegularFile())
.forEach(p -> {
minCss(p, Path.of("${sourceSets.main.output.resourcesDir}", "style", styleDir.relativize(p).toString()))
})
}
}
tasks.register('generator', JavaExec) {
mainClass = 'net.querz.mcaselector.version.mapping.generator.Main'
classpath = sourceSets.main.runtimeClasspath
}
jar {
dependsOn minifyCss
archiveFileName = "${projectName}-${projectVersion}.jar"
manifest.attributes (
'Main-Class': application.mainClass,
'Application-Version': projectVersion,
'Copyright': copyright,
'Class-Path': configurations.shadow.files.stream()
.filter($it -> !$it.name.startsWith('javafx')).collect{"lib/$it.name"}.join(' ')
)
exclude 'licenses/'
from 'LICENSE'
}
shadowJar {
minimize {
exclude(dependency('org.apache.logging.log4j:log4j-core:.*'))
exclude(dependency('org.apache.groovy:groovy-jsr223:.*'))
exclude(dependency('org.lz4:lz4-java:.*'))
}
dependencies {
exclude(dependency(':javafx.*:.*'))
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
manifest.attributes (
'Main-Class': application.mainClass,
'Application-Version': projectVersion,
'Copyright': copyright
)
from 'LICENSE'
}
runtime {
options = ['--strip-debug', '--compress', 'zip-6', '--no-header-files', '--no-man-pages']
modules = [
'java.base',
'java.desktop',
'java.management',
'java.naming',
'java.scripting',
'jdk.unsupported',
'javafx.controls',
'javafx.swing',
'jdk.crypto.ec'
]
jpackage {
jvmArgs = ['-Xmx4096m']
if (OperatingSystem.current().isWindows()) {
imageName = applicationName
skipInstaller = true
imageOptions = [
'--icon', 'installer/windows/icon.ico',
'--copyright', copyright
]
} else if (OperatingSystem.current().isMacOsX()) {
installerType = "dmg"
imageName = applicationName
installerName = applicationName
imageOptions = [
'--icon', 'installer/macos/icon.icns',
'--copyright', copyright
]
installerOptions = [
'--icon', 'installer/macos/icon.icns',
'--copyright', copyright,
'--license-file', 'build/licenses/LICENSE'
]
} else if (OperatingSystem.current().isLinux()) {
installerType = matrixType ?: "deb"
imageOptions = [
'--icon', 'installer/linux/icon.png',
'--copyright', copyright,
]
installerOptions = [
'--linux-shortcut',
'--icon', 'installer/linux/icon.png',
'--copyright', copyright,
'--resource-dir', 'installer/linux',
'--license-file', 'build/licenses/LICENSE'
]
}
}
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
systemProperties = [
'junit.jupiter.tempdir.cleanup.mode.default': 'NEVER',
'net.querz.test.temp.dir': 'test_output' // if set, use this dir as temp dir
]
}
// ---------------------------------------------------------------------------------------------------------------------
/**
* "Minifies" a css file by removing all comments, \n, \t and all duplicate spaces.
*
* @param i The input css file
* @param o The output css file
* @throws IOException If something goes wrong during reading or writing
*/
static minCss(i, o) throws IOException {
String s = Files.readString(i)
s = s.replace("\t", "").replace("\r\n", " ").replace("\n", " ").replaceAll("/\\*.*?\\*/", "").replaceAll(" {2,}", " ").trim()
try {Files.writeString(o, s)}
catch (Exception ex) {
ex.printStackTrace()
}
}