-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
177 lines (160 loc) · 6.24 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
/*
* Copyright (c) 2018-2021 Karlatemp. All rights reserved.
* @author Karlatemp <[email protected]> <https://github.com/Karlatemp>
*
* MXLib/MXLib/build.gradle
*
* Use of this source code is governed by the MIT license that can be found via the following link.
*
* https://github.com/Karlatemp/MxLib/blob/master/LICENSE
*/
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.5.10' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.10' apply false
id 'com.github.johnrengelman.shadow' version '6.1.0' apply false
}
//noinspection GroovyAssignabilityCheck
allprojects {
group 'io.github.karlatemp.mxlib'
version '3.0-dev-20'
repositories {
mavenLocal()
mavenCentral()
//noinspection GroovyAssignabilityCheck
maven { url = "https://libraries.minecraft.net" }
//noinspection GroovyAssignabilityCheck
maven { url = 'https://hub.spigotmc.org/nexus/content/groups/public/' }
}
//noinspection GroovyAssignabilityCheck
afterEvaluate {
if (project.name == 'mxlib.z.shadow') return
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
if (project.name.endsWith("-kotlin")
|| project.name == 'mxlib.z.srx.debug'
) {
def ktimp = { f ->
if (project.name == "mxlib.z.shadowjar-kotlin"
|| project.name == 'mxlib.z.srx.debug'
) {
compile f
} else {
compileOnly f
testCompile f
}
}
ktimp "org.jetbrains.kotlin:kotlin-stdlib"
ktimp "org.jetbrains.kotlin:kotlin-serialization"
// https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-json-jvm
ktimp group: 'org.jetbrains.kotlinx', name: 'kotlinx-serialization-json-jvm', version: '1.0.1'
ktimp "org.jetbrains.kotlin:kotlin-reflect"
ktimp "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1"
testCompile "org.jetbrains.kotlin:kotlin-test-junit5"
}
}
test {
useJUnitPlatform()
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
if (project.name == 'mxlib.z.srx.debug') {
sourceCompatibility = JavaVersion.VERSION_15
targetCompatibility = JavaVersion.VERSION_15
}
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_13
targetCompatibility = JavaVersion.VERSION_13
}
try {
kotlin {
if (project.name != 'mxlib.z.srx.debug') {
explicitApi()
}
}
def freeCompilerArgs0 = [
'-Xopt-in=kotlin.RequiresOptIn',
'-Xopt-in=kotlin.contracts.ExperimentalContracts',
'-Xjvm-default=enable',
]
compileKotlin {
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += freeCompilerArgs0
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += freeCompilerArgs0
}
}
} catch (Throwable ignore) {
}
}
}
({
def buildScan = extensions.findByName('buildScan')
if (buildScan != null) {
buildScan.termsOfServiceUrl = "https://gradle.com/terms-of-service"
buildScan.termsOfServiceAgree = "yes"
}
})();
({
def versionOverrides = [
'=====================================': '',
'io.netty' : '4.1.59.Final',
'org.jetbrains.kotlin' : '1.4.30',
'org.jetbrains:annotations' : '21.0.0',
'org.junit.jupiter' : '5.7.2',
'org.ow2.asm' : '9.1',
'net.java.dev.jna' : '5.8.0',
'org.fusesource.jansi:jansi' : '2.3.4',
'org.jline:jline' : '3.20.0',
'io.github.karlatemp:unsafe-accessor' : '1.6.0',
]
allprojects {
afterEvaluate {
configurations.all { Configuration configuration ->
def lst = configuration.dependencies.matching { Dependency dependency ->
if (dependency.version != null) return false
return true
}.toList()
lst.forEach { dep ->
def result1 = versionOverrides[dep.toString()]
if (result1 == null) {
result1 = versionOverrides[dep.group]
}
if (result1 != null) {
configuration.dependencies.remove(dep)
configuration.dependencies.add(
project.dependencies.create(
group: dep.group,
name: dep.name,
version: result1,
)
)
}
}
}
}
configurations.all { Configuration configuration ->
configuration.resolutionStrategy.eachDependency { dependency ->
def result1 = versionOverrides[dependency.requested.module.toString()]
if (result1 != null) {
dependency.useVersion(result1)
dependency.because("Custom override rule")
} else {
def result2 = versionOverrides[dependency.requested.group]
if (result2 != null) {
dependency.useVersion(result2)
dependency.because("Custom override rule")
}
}
}
}
}
})();