-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
97 lines (86 loc) · 3.38 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
//beware that IDEA uses the term "project" to refer to the top-level thing, and "module" to refer to children,
//but Gradle would call those the "root project" and "projects"/"subprojects" respectively
//with that said:
//set the *default* (project-wide, not module-wide) IDEA language level to 17
//the default language level is sometimes used for things like determining which JDK to run Gradle with.
//this project mixes java versions across the modules, and IDEA seems to be a bit unpredictable about
//which one it decides to use as the default.
//TODO: doesn't seem to work? it's still picking java 6
apply plugin: "idea"
idea.project {
languageLevel("JDK_17")
}
//this block is executed for each subproject, as if it was copied and pasted into the buildscript
subprojects {
apply plugin: "java"
apply plugin: "idea"
//defines a function available through ext.gimmeJava (basically, a crude form of gradle plugin)
//this configures a project-specific gradle toolchain
project.ext.gimmeJava = (int ver) -> {
if(ver <= 8) {
//For java 6-8 projects, use a java 8 toolchain and set target/source compatibility
//It's hard to get actual java 6 toolchains so this will do
java.toolchain {
project.logger.lifecycle("{}: configuring Java 8 toolchain", project.displayName)
languageVersion = JavaLanguageVersion.of(8)
vendor = JvmVendorSpec.ADOPTIUM
}
String compat = "1." + ver
//i forgor if setting these on project scope does anything but it can't hurt..?????
it.sourceCompatibility = compat
it.targetCompatibility = compat
tasks.withType(JavaCompile).configureEach {
project.logger.lifecycle("{}: setting source/target compatibility to {} on task {}", project.displayName, compat, it.name)
sourceCompatibility = compat
targetCompatibility = compat
}
} else {
//For newer versions, use the exact requested toolchain and set -release flag
java.toolchain {
project.logger.lifecycle("{}: configuring Java {} toolchain", project.displayName, ver)
languageVersion = JavaLanguageVersion.of(ver)
vendor = JvmVendorSpec.ADOPTIUM
}
tasks.withType(JavaCompile).configureEach {
project.logger.lifecycle("{}: setting release to {} on task {}", project.displayName, ver, it.name)
options.release = ver
}
}
}
//i heard this is good practice? sure
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
}
//probably broken due to all the remapping nonsense that minecraft gradle plugins do
//not entirely sure, though (and also not really sure what this does in the first place)
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
//substitute ${version} placeholders in certain files in /resources
processResources {
inputs.property "version", project.version
filesMatching(["**/fabric.mod.json", "**/mods.toml", "**/version.properties", "**/mcmod.info"]) {
expand "version": project.version
}
}
repositories {
//mainly so i don't have to keep configuring where to get mixin stuff from a zillion times on forge projects
maven {
name = "spunchbob"
url = "https://repo.spongepowered.org/repository/maven-public/"
content {
includeGroup "org.spongepowered"
}
}
//i want my nonnull annotations
mavenCentral({
content {
includeGroup("org.jetbrains")
}
})
}
//give me my nonnull annotations
dependencies {
implementation "org.jetbrains:annotations:16.0.2"
}
}