forked from CaelTheColher/Capes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
186 lines (154 loc) · 5.19 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
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
buildscript {
dependencies {
classpath("org.kohsuke:github-api:1.313")
}
}
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "org.jetbrains.kotlin.jvm"
id "org.ajoberstar.grgit"
id "com.matthewprenger.cursegradle"
id "com.modrinth.minotaur"
}
architectury {
platformSetupLoomIde()
fabric()
}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
}
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${rootProject.fabric_kotlin_version}"
modImplementation "com.terraformersmc:modmenu:${rootProject.modmenu_version}"
modImplementation "com.ptsmods:devlogin:3.5"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
shadowJar {
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
archiveClassifier.set "dev-shadow"
}
remapJar {
injectAccessWidener = true
input.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set "fabric"
from rootProject.file("LICENSE")
}
jar {
archiveClassifier.set "dev"
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}
def DISPLAY_NAME = "[Fabric ${minecraft_version}] Capes ${mod_version.split('\\+')[0]}"
static def getChangeLog() {
return "A changelog can be found at https://github.com/CaelTheColher/Capes"
}
curseforge {
String token = System.getenv("CURSEFORGE_API_KEY")
apiKey = token == null || token.isEmpty() ? "unset" : token
project {
id = curseforge_id
changelog = getChangeLog()
releaseType = "release"
addGameVersion("Fabric")
addGameVersion(minecraft_version)
relations {
requiredDependency("fabric-api")
requiredDependency("fabric-language-kotlin")
optionalDependency("modmenu")
}
mainArtifact(tasks.remapJar.archiveFile.get().getAsFile()) {
displayName = DISPLAY_NAME
}
afterEvaluate {
uploadTask.dependsOn(remapJar)
}
}
curseGradleOptions.forgeGradleIntegration = false
}
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = modrinth_id
versionNumber = mod_version
versionName = DISPLAY_NAME
uploadFile = remapJar
gameVersions = [minecraft_version]
loaders = ['fabric']
versionType = "release"
changelog = getChangeLog()
dependencies {
required.project("fabric-api")
required.project("fabric-language-kotlin")
optional.project("modmenu")
}
}
def getBranch() {
def env = System.getenv()
if (env.GITHUB_REF) {
def branch = env.GITHUB_REF
return branch.substring(branch.lastIndexOf("/") + 1)
}
if (grgit == null) {
return "unknown"
}
def branch = grgit.branch.current().name
return branch.substring(branch.lastIndexOf("/") + 1)
}
import org.kohsuke.github.GHReleaseBuilder
import org.kohsuke.github.GitHub
tasks.register('github') {
dependsOn remapJar
def env = System.getenv()
onlyIf {
env.GITHUB_TOKEN
}
doLast {
def github = GitHub.connectUsingOAuth(env.GITHUB_TOKEN as String)
def repository = github.getRepository(env.GITHUB_REPOSITORY)
def releaseBuilder = new GHReleaseBuilder(repository, "fabric-" + version as String)
releaseBuilder.name(DISPLAY_NAME)
releaseBuilder.body(getChangeLog())
releaseBuilder.commitish(getBranch())
def ghRelease = releaseBuilder.create()
ghRelease.uploadAsset(tasks.remapJar.archiveFile.get().getAsFile(), "application/java-archive")
}
}
tasks.named("curseforge").get().dependsOn tasks.named("remapJar").get()
tasks.named("modrinth").get().dependsOn tasks.named("remapJar").get()
rootProject.tasks.named("fabricPublish").get().dependsOn tasks.named("curseforge").get()
rootProject.tasks.named("fabricPublish").get().dependsOn tasks.named("modrinth").get()
rootProject.tasks.named("fabricPublish").get().dependsOn tasks.named("github").get()