-
Notifications
You must be signed in to change notification settings - Fork 14
/
extensions.kt
35 lines (30 loc) · 918 Bytes
/
extensions.kt
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
package gg.essential.gradle.util
import net.fabricmc.loom.api.LoomGradleExtensionAPI
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
/**
* Sets `-Xjvm-default=mode` on the given task.
*/
fun KotlinCompile.setJvmDefault(mode: String) {
kotlinOptions {
val key = "-Xjvm-default="
freeCompilerArgs = freeCompilerArgs.filterNot { it.startsWith(key) } + listOf(key + mode)
}
}
/**
* Sets `-Xjvm-default=mode` on the given task.
*/
fun TaskProvider<KotlinCompile>.setJvmDefault(mode: String) = configure { setJvmDefault(mode) }
/**
* Disables all run configs.
*/
fun LoomGradleExtensionAPI.noRunConfigs() {
runConfigs.all { isIdeConfigGenerated = false }
}
/**
* Disables the server run config.
*/
fun LoomGradleExtensionAPI.noServerRunConfigs() {
runConfigs["server"].isIdeConfigGenerated = false
}