forked from GTNewHorizons/RetroFuturaGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
199 lines (178 loc) · 6.86 KB
/
build.gradle.kts
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import org.jetbrains.gradle.ext.Application
import org.jetbrains.gradle.ext.Gradle
import org.jetbrains.gradle.ext.RunConfigurationContainer
plugins {
id("java-library")
id("maven-publish")
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.8"
id("eclipse")
id("com.gtnewhorizons.retrofuturagradle") version "1.4.0"
}
// Project properties
group = "rfg.examplemod"
version = "1.0.0"
// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
// Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64
vendor.set(org.gradle.jvm.toolchain.JvmVendorSpec.AZUL)
}
// Generate sources and javadocs jars when building and publishing
withSourcesJar()
withJavadocJar()
}
// Most RFG configuration lives here, see the JavaDoc for com.gtnewhorizons.retrofuturagradle.MinecraftExtension
minecraft {
mcVersion.set("1.7.10")
// Username for client run configurations
username.set("Developer")
// Generate a field named VERSION with the mod version in the injected Tags class
injectedTags.put("VERSION", project.version)
// If you need the old replaceIn mechanism, prefer the injectTags task because it doesn't inject a javac plugin.
// tagReplacementFiles.add("RfgExampleMod.java")
// Enable assertions in the mod's package when running the client or server
extraRunJvmArguments.add("-ea:${project.group}")
// If needed, add extra tweaker classes like for mixins.
// extraTweakClasses.add("org.spongepowered.asm.launch.MixinTweaker")
// Exclude some Maven dependency groups from being automatically included in the reobfuscated runs
groupsToExcludeFromAutoReobfMapping.addAll("com.diffplug", "com.diffplug.durian", "net.industrial-craft")
}
// Generates a class named rfg.examplemod.Tags with the mod version in it, you can find it at
tasks.injectTags.configure {
outputClassName.set("${project.group}.Tags")
}
// Put the version from gradle into mcmod.info
tasks.processResources.configure {
val projVersion = project.version.toString() // Needed for configuration cache to work
inputs.property("version", projVersion)
filesMatching("mcmod.info") {
expand(mapOf("modVersion" to projVersion))
}
}
// Create a new dependency type for runtime-only dependencies that don't get included in the maven publication
val runtimeOnlyNonPublishable: Configuration by configurations.creating {
description = "Runtime only dependencies that are not published alongside the jar"
isCanBeConsumed = false
isCanBeResolved = false
}
listOf(configurations.runtimeClasspath, configurations.testRuntimeClasspath).forEach {
it.configure {
extendsFrom(
runtimeOnlyNonPublishable
)
}
}
// Add an access tranformer
// tasks.deobfuscateMergedJarToSrg.configure {accessTransformerFiles.from("src/main/resources/META-INF/mymod_at.cfg")}
// Dependencies
repositories {
maven {
name = "OvermindDL1 Maven"
url = uri("https://gregtech.overminddl1.com/")
}
maven {
name = "GTNH Maven"
url = uri("https://nexus.gtnewhorizons.com/repository/public/")
}
}
dependencies {
// Adds NotEnoughItems and its dependencies (CCL&CCC) to runClient/runServer
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.3.39-GTNH:dev")
// Example: grab the ic2 jar from curse maven and deobfuscate
// api(rfg.deobf("curse.maven:ic2-242638:2353971"))
// Example: grab the ic2 jar from libs/ in the workspace and deobfuscate
// api(rfg.deobf(project.files("libs/ic2.jar")))
}
// Publishing to a Maven repository
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
repositories {
// Example: publishing to the GTNH Maven repository
maven {
url = uri("https://nexus.gtnewhorizons.com/repository/releases/")
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
}
}
}
// IDE Settings
eclipse {
classpath {
isDownloadSources = true
isDownloadJavadoc = true
}
}
idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
inheritOutputDirs = true // Fix resources in IJ-Native runs
}
project {
this.withGroovyBuilder {
"settings" {
"runConfigurations" {
val self = this.delegate as RunConfigurationContainer
self.add(Gradle("1. Run Client").apply {
setProperty("taskNames", listOf("runClient"))
})
self.add(Gradle("2. Run Server").apply {
setProperty("taskNames", listOf("runServer"))
})
self.add(Gradle("3. Run Obfuscated Client").apply {
setProperty("taskNames", listOf("runObfClient"))
})
self.add(Gradle("4. Run Obfuscated Server").apply {
setProperty("taskNames", listOf("runObfServer"))
})
/*
These require extra configuration in IntelliJ, so are not enabled by default
self.add(Application("Run Client (IJ Native, Deprecated)", project).apply {
mainClass = "GradleStart"
moduleName = project.name + ".ideVirtualMain"
afterEvaluate {
val runClient = tasks.runClient.get()
workingDirectory = runClient.workingDir.absolutePath
programParameters = runClient.calculateArgs(project).map { '"' + it + '"' }.joinToString(" ")
jvmArgs = runClient.calculateJvmArgs(project).map { '"' + it + '"' }.joinToString(" ") +
' ' + runClient.systemProperties.map { "\"-D" + it.key + '=' + it.value.toString() + '"' }
.joinToString(" ")
}
})
self.add(Application("Run Server (IJ Native, Deprecated)", project).apply {
mainClass = "GradleStartServer"
moduleName = project.name + ".ideVirtualMain"
afterEvaluate {
val runServer = tasks.runServer.get()
workingDirectory = runServer.workingDir.absolutePath
programParameters = runServer.calculateArgs(project).map { '"' + it + '"' }.joinToString(" ")
jvmArgs = runServer.calculateJvmArgs(project).map { '"' + it + '"' }.joinToString(" ") +
' ' + runServer.systemProperties.map { "\"-D" + it.key + '=' + it.value.toString() + '"' }
.joinToString(" ")
}
})
*/
}
"compiler" {
val self = this.delegate as org.jetbrains.gradle.ext.IdeaCompilerConfiguration
afterEvaluate {
self.javac.moduleJavacAdditionalOptions = mapOf(
(project.name + ".main") to
tasks.compileJava.get().options.compilerArgs.map { '"' + it + '"' }.joinToString(" ")
)
}
}
}
}
}
}
tasks.processIdeaSettings.configure {
dependsOn(tasks.injectTags)
}