-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle
134 lines (112 loc) · 5.08 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
/*
* Copyright (C) 2019-2021 German Vekhorev (DarksideCode)
*
* This file is part of Keiko Plugin Inspector.
*
* Keiko Plugin Inspector is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Keiko Plugin Inspector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Keiko Plugin Inspector. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '6.1.0'
}
group 'me.darksidecode.keiko'
version '4.1.0-dev'
def buildTimestamp = new Date().format('yyyy/MM/dd_HH-mm-ss')
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
// Include resources
processResources {
expand project.properties
}
// Fill build.properties
task createProperties(dependsOn: processResources) {
doLast {
new File("$buildDir/resources/main/build.properties").withWriter { w ->
Properties p = new Properties()
p['version'] = project.version.toString()
p['timestamp'] = buildTimestamp.toString()
p.store w, null
}
}
}
classes.dependsOn createProperties
// Relocate all our internal libraries to avoid linkage errors when proxying other executables at runtime.
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = 'keiko_internals'
}
// Include MANIFEST.MF
shadowJar {
manifest {
attributes 'Main-Class': 'me.darksidecode.keiko.proxy.Keiko'
}
}
tasks.shadowJar.dependsOn tasks.relocateShadowJar
tasks.shadowJar.finalizedBy tasks.test
// Dependencies
repositories {
mavenCentral()
maven {
name 'Public Reflex Repository'
url 'https://archiva.reflex.rip/repository/public/'
}
maven {
name 'BungeeCord'
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven {
name 'Spigot'
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
}
def asmVersion = '9.1'
def lombokVersion = '1.18.6'
def junit5Version = '5.7.1'
// Some dependencies are marked with [number]. See the comments under the end of this section for details.
dependencies {
// Embed in JAR (required)
implementation group: 'me.darksidecode.kantanj', name: 'kantanj', version: '1.1.0'
implementation group: 'me.darksidecode.jminima', name: 'jminima', version: '1.4.0'
implementation group: 'org.ow2.asm', name: 'asm', version: "${asmVersion}"
implementation group: 'org.ow2.asm', name: 'asm-util', version: "${asmVersion}"
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
implementation group: 'org.reflections', name: 'reflections', version: '0.9.10'
implementation group: 'org.yaml', name: 'snakeyaml', version: '1.28'
implementation group: 'com.diogonunes', name: 'JColor', version: '5.0.1' // [1]
// Present at runtime (optional)
compileOnly group: 'org.spigotmc', name: 'spigot-api', version: '1.13.2-R0.1-SNAPSHOT'
compileOnly group: 'net.md-5', name: 'bungeecord-api', version: '1.13-SNAPSHOT'
// Annotation processors
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: "${lombokVersion}"
compileOnly group: 'org.projectlombok', name: 'lombok', version: "${lombokVersion}"
// Testing
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: "${junit5Version}"
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: "${junit5Version}"
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "${junit5Version}"
}
// Some notes regarding dependencies.
//
// [1] (JColor) -- We can't use jansi because jansi does not work when relocated with shadowjar,
// but excluding some packages is not possible because we use the automatic task
// ConfigureShadowRelocation. Switching to manual relocation will add much pain
// to maintaining the project. Additionally, even if we manage to exclude jansi
// from repackaging, Keiko proxy will not work due to LinkageErrors at run-time.
// This is because Minecraft uses jansi too, which, again, cannot be relocated or
// duplicated on the classpath (even with different class loaders) (ColouredConsoleSender).
test {
useJUnitPlatform()
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}