-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
195 lines (167 loc) · 6.1 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
import com.github.breadmoirai.githubreleaseplugin.GithubReleaseExtension
import com.matthewprenger.cursegradle.*
import net.minecraftforge.gradle.common.util.MinecraftExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.OffsetDateTime
plugins {
id("net.minecraftforge.gradle")
id("com.matthewprenger.cursegradle")
id("com.github.breadmoirai.github-release")
id("org.jetbrains.kotlin.jvm")
`maven-publish`
}
val modVersion: String by project
val modReleaseType: String by project
val modDescription: String by project
val modChangelog: String by project
val modDependencies: String by project
val modAcceptedMcVersions: String by project
val forgeVersion: String by project
val minecraftVersion: String by project
val mcpMappingsChannel: String by project
val mcpMappingsVersion: String by project
val jeiVersion: String by project
val jeiMcVersion: String by project
val kotlinForForgeVersion: String by project
val projectEFileId: String by project
val kotlinxCoroutinesVersion: String by project
val jdkVersion: String by project
val curseforgeProjectId: String by project
val curseforgeReleaseType: String by project
val githubReleaseBranch: String by project
val pearxRepoUsername: String? by project
val pearxRepoPassword: String? by project
val curseforgeApiKey: String? by project
val devBuildNumber: String? by project
val githubAccessToken: String? by project
version = if (devBuildNumber != null) "$modVersion-dev-$devBuildNumber" else modVersion
group = "net.pearx.craftdumper"
description = modDescription
java {
sourceCompatibility = JavaVersion.toVersion(jdkVersion)
}
repositories {
maven { url = uri("https://files.minecraftforge.net/maven") }
maven { url = uri("https://www.cursemaven.com") }
maven { url = uri("https://dvs1.progwml6.com/files/maven") } // JEI
maven { url = uri("https://thedarkcolour.github.io/KotlinForForge/") } // Kotlin for Forge
}
dependencies {
"minecraft"("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
"implementation"(kotlin("stdlib-jdk$jdkVersion"))
"implementation"(kotlin("reflect"))
"implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-jdk$jdkVersion:$kotlinxCoroutinesVersion")
"implementation"("thedarkcolour:kotlinforforge:$kotlinForForgeVersion")
"runtimeOnly"(fg.deobf("mezz.jei:jei-$jeiMcVersion:$jeiVersion"))
"implementation"(fg.deobf("curse.maven:projecte-226410:$projectEFileId"))
}
configure<MinecraftExtension> {
mappings(mcpMappingsChannel, mcpMappingsVersion)
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
runs {
create("client")
create("server")
create("data") {
args("--mod", "craftdumper", "-all", "--output", file("src/generated/resources"))
}
configureEach {
workingDirectory(project.file("run/$name"))
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
property("forge.logging.console.level", "debug")
mods {
create("craftdumper") {
source(sourceSets["main"])
}
}
}
}
}
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
artifacts {
archives(sourcesJar)
}
publishing {
repositories {
maven {
credentials {
username = "pearxteam"
password = githubAccessToken
}
name = "github"
url = uri("https://maven.pkg.github.com/pearxteam/craftdumper")
}
}
publications {
register<MavenPublication>("maven") {
from(components["java"])
artifact(sourcesJar.get())
}
}
}
configure<CurseExtension> {
apiKey = curseforgeApiKey ?: "0"
project(closureOf<CurseProject> {
id = curseforgeProjectId
releaseType = curseforgeReleaseType
changelog = modChangelog
relations(closureOf<CurseRelation> {
requiredDependency("kotlin-for-forge")
})
val arts = (publishing.publications["maven"] as MavenPublication).artifacts
val mainArt = arts.first { it.classifier == null }
val additionalArts = arts.filter { it.classifier != null }
mainArtifact(mainArt.file, closureOf<CurseArtifact> {
displayName = "[$minecraftVersion] CraftDumper $version"
})
additionalArts.forEach { addArtifact(it.file) }
options(closureOf<Options> {
detectNewerJava = true
})
addGameVersion("Java 10") // hack
})
}
configure<GithubReleaseExtension> {
setToken(githubAccessToken)
setOwner("pearxteam")
setRepo("craftdumper")
setTargetCommitish(githubReleaseBranch)
setBody(modChangelog)
setReleaseAssets((publishing.publications["maven"] as MavenPublication).artifacts.map { it.file })
}
tasks {
jar {
finalizedBy("reobfJar")
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.$jdkVersion"
kotlinOptions.freeCompilerArgs = listOf("-Xno-param-assertions")
}
withType<Jar> {
manifest {
attributes(
mapOf(
"Specification-Title" to "CraftDumper",
"Specification-Vendor" to "PearX Team",
"Specification-Version" to modVersion,
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "PearX Team",
"Implementation-Timestamp" to OffsetDateTime.now().toString()
)
)
}
}
register("publishDevelop") {
group = "publishing"
dependsOn(withType<PublishToMavenRepository>().matching { it.repository == publishing.repositories["github"] })
}
register("publishRelease") {
group = "publishing"
dependsOn(withType<PublishToMavenRepository>().matching { it.repository == publishing.repositories["github"] })
dependsOn(named("curseforge"))
dependsOn(named("githubRelease"))
}
}