-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathbuild.gradle
151 lines (132 loc) · 4.43 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
plugins {
id 'java'
id 'application'
id 'eclipse'
id 'idea'
id 'org.openjfx.javafxplugin' version '0.1.0'
id 'com.gradleup.shadow' version '9.0.0-beta11'
id 'com.github.ben-manes.versions' version '0.52.0'
}
group 'net.querz'
compileJava.options.encoding = 'UTF-8'
application.mainClass = 'net.querz.mcaselector.Main'
java {
sourceCompatibility = JavaVersion.VERSION_21
}
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:6bc3de6961'
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.9.0'
implementation 'me.tongfei:progressbar:0.10.1'
implementation 'org.apache.groovy:groovy-jsr223:4.0.26'
implementation 'org.fxmisc.richtext:richtextfx:0.11.4'
implementation 'org.lz4:lz4-java:1.8.0'
implementation 'org.atteo.classindex:classindex:3.13'
implementation 'org.iq80.leveldb:leveldb:0.12'
shadow 'com.github.Querz:NBT:6bc3de6961'
shadow 'com.google.code.gson:gson:2.12.1'
shadow 'it.unimi.dsi:fastutil:8.5.15'
shadow 'org.apache.logging.log4j:log4j-api:2.24.3'
shadow 'org.apache.logging.log4j:log4j-core:2.24.3'
shadow 'org.slf4j:slf4j-simple:2.0.16'
shadow 'commons-cli:commons-cli:1.9.0'
shadow 'me.tongfei:progressbar:0.10.1'
shadow 'org.apache.groovy:groovy-jsr223:4.0.26'
shadow 'org.fxmisc.richtext:richtextfx:0.11.4'
shadow 'org.lz4:lz4-java:1.8.0'
shadow 'org.atteo.classindex:classindex:3.13'
shadow 'org.iq80.leveldb:leveldb:0.12'
annotationProcessor('org.atteo.classindex:classindex:3.13')
annotationProcessor('org.apache.logging.log4j:log4j-core:2.24.3')
testImplementation 'junit:junit:4.13.2'
testImplementation 'commons-io:commons-io:2.18.0'
}
compileJava {
options.compilerArgs += ['-Xlint:deprecation', '-Xlint:unchecked']
}
tasks.register('copyRuntimeLibs', Copy) {
from configurations.shadow
into layout.buildDirectory.dir('libs/lib')
exclude { it.file.name.startsWith('javafx') }
}
tasks.register('minifyCss') {
doLast {
var styleDir = java.nio.file.Path.of("${sourceSets.main.resources.srcDirs[0]}", "style")
Files.find(styleDir, Integer.MAX_VALUE, (filePath, fileAttr) -> fileAttr.isRegularFile())
.forEach(p -> {
minCss(p, java.nio.file.Path.of("${sourceSets.main.output.resourcesDir}", "style", styleDir.relativize(p).toString()))
})
}
dependsOn processResources
}
tasks.register('generator', JavaExec) {
mainClass = 'net.querz.mcaselector.version.mapping.generator.Main'
classpath = sourceSets.main.runtimeClasspath
}
jar {
archiveFileName = "${project.name}-${project.version}-min.jar"
manifest.attributes (
'Main-Class': application.mainClass,
'Application-Version': project.version,
'Copyright': project.findProperty('application.copyright'),
'Class-Path': configurations.shadow.files.stream()
.filter($it -> !$it.name.startsWith('javafx')).collect{"lib/$it.name"}.join(' ')
)
exclude 'licenses/'
from 'LICENSE'
dependsOn minifyCss
dependsOn copyRuntimeLibs
finalizedBy shadowJar
}
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.*:.*'))
}
archiveFileName = "${project.name}-${project.version}.jar"
configurations = [project.configurations.shadow]
from 'LICENSE'
}
assemble.dependsOn shadowJar
// ---------------------------------------------------------------------------------------------------------------------
/**
* "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
*/
import java.nio.file.Files
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()
}
}