-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
149 lines (131 loc) · 4.66 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
import com.github.breadmoirai.githubreleaseplugin.GithubReleaseExtension
import com.matthewprenger.cursegradle.*
import net.minecraftforge.gradle.user.UserBaseExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("net.minecraftforge.gradle.forge")
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 mcpMappingsVersion: String by project
val jeiVersion: String by project
val jeiMcVersion: String by project
val forgelinVersion: String by project
val jdkVersion: String by project
val curseforgeProjectId: 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.pura-magio"
description = modDescription
java {
sourceCompatibility = JavaVersion.toVersion(jdkVersion)
}
repositories {
maven { url = uri("https://maven.shadowfacts.net/") } // Forgelin
maven { url = uri("http://dvs1.progwml6.com/files/maven") } // JEI
}
dependencies {
"runtime"("mezz.jei:jei_$jeiMcVersion:$jeiVersion")
"compile"("net.shadowfacts:Forgelin:$forgelinVersion")
"compile"("net.pearx.craftlin:craftlin-$minecraftVersion:+")
}
configure<UserBaseExtension> {
version = "$minecraftVersion-$forgeVersion"
runDir = "run"
mappings = mcpMappingsVersion
replace("VERSION = \"\"", "VERSION = \"$modVersion\"")
replace("DESCRIPTION = \"\"", "DESCRIPTION = \"$modDescription\"")
replace("ACCEPTED_MINECRAFT_VERSIONS = \"\"", "ACCEPTED_MINECRAFT_VERSIONS = \"$modAcceptedMcVersions\"")
replace("DEPENDENCIES = \"\"", "DEPENDENCIES = \"$modDependencies\"")
replaceIn("Reference.kt")
}
publishing {
repositories {
fun AuthenticationSupported.pearxCredentials() {
credentials {
username = pearxRepoUsername
password = pearxRepoPassword
}
}
maven {
pearxCredentials()
name = "develop"
url = uri("https://repo.pearx.net/maven2/develop/")
}
maven {
pearxCredentials()
name = "release"
url = uri("https://repo.pearx.net/maven2/release/")
}
}
publications {
register<MavenPublication>("maven") {
artifact(tasks.getByName<Jar>("jar"))
}
}
}
configure<CurseExtension> {
apiKey = curseforgeApiKey ?: "0"
project(closureOf<CurseProject> {
id = curseforgeProjectId
releaseType = "release"
changelog = modChangelog
relations(closureOf<CurseRelation> {
requiredDependency("shadowfacts-forgelin")
})
mainArtifact(tasks.named("jar").get(), closureOf<CurseArtifact> {
displayName = "[$minecraftVersion] Pura Magio $version"
})
options(closureOf<Options> {
detectNewerJava = true
})
addGameVersion("Java 10") // hack
})
}
configure<GithubReleaseExtension> {
setToken(githubAccessToken)
setOwner("pearxteam")
setRepo("pura-magio")
setTargetCommitish(githubReleaseBranch)
setBody(modChangelog)
setReleaseAssets((publishing.publications["maven"] as MavenPublication).artifacts.map { it.file })
}
tasks {
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.$jdkVersion"
kotlinOptions.freeCompilerArgs = listOf("-Xno-param-assertions")
}
withType<Jar> {
manifest {
attributes(mapOf("FMLAT" to "puramagio_at.cfg"))
}
}
register("publishDevelop") {
group = "publishing"
dependsOn(withType<PublishToMavenRepository>().matching { it.repository == publishing.repositories["develop"] })
}
register("publishRelease") {
group = "publishing"
dependsOn(withType<PublishToMavenRepository>().matching { it.repository == publishing.repositories["release"] })
dependsOn(named("curseforge"))
dependsOn(named("githubRelease"))
}
for (ws in arrayOf("Decomp", "Ci", "Dev")) {
named<Task>("setup${ws}Workspace") { dependsOn(gradle.includedBuild("craftlin-$minecraftVersion").task(":setup${ws}Workspace")) }
}
}