-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
220 lines (184 loc) · 6.42 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
plugins {
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
id 'com.gradleup.shadow' version '8.3.0'
id "dev.kikugie.j52j" version "1.0"
id "me.modmuss50.mod-publish-plugin" version "0.7.4"
}
def mcVersion = stonecutter.current.version
def fullVersion = mod_version + "+" + mcVersion
version = fullVersion
group = property("mod_group").toString()
def id = property("mod_id").toString()
def mod_name = property("mod_name").toString()
def mod_version = property("mod_version").toString()
def yacl = property("deps.yacl_version").toString()
def fabric_api = property("deps.fabric_api").toString()
def modmenu = property("deps.modmenu_version").toString()
def javaVersion = (stonecutter.eval(mcVersion, ">=1.20.5")) ? JavaVersion.VERSION_21 : JavaVersion.VERSION_17
stonecutter.dependency("java", javaVersion.toString())
base {
archivesName = property("mod_id").toString()
}
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
name 'Xander Maven'
url 'https://maven.isxander.dev/releases'
}
maven {
name = "Terraformers"
url = "https://maven.terraformersmc.com/"
}
}
loom {
splitEnvironmentSourceSets()
mods {
"autocut" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
runConfigs.all {
ideConfigGenerated true // Run configurations are not created for subprojects by default
runDir "../../run" // Use a shared run folder and just create separate worlds
}
}
fabricApi {
configureDataGeneration()
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${property('deps.minecraft')}"
mappings "net.fabricmc:yarn:${property('deps.yarn_mappings')}:v2"
modImplementation "net.fabricmc:fabric-loader:${property('deps.fabric_loader')}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${property('deps.fabric_api')}"
shadow implementation("io.obs-websocket.community:client:${property('deps.obs_websocket_version')}") {
exclude group: 'org.slf4j', module: 'slf4j-simple'
}
include implementation("org.xerial:sqlite-jdbc:${property('deps.sqlite_jdbc_version')}")
shadow implementation("net.bramp.ffmpeg:ffmpeg:${property('deps.ffmpeg_cli_wrapper_version')}")
modImplementation("dev.isxander:yet-another-config-lib:${property('deps.yacl_version')}")
modCompileOnly("com.terraformersmc:modmenu:${property('deps.modmenu_version')}")
modRuntimeOnly("com.terraformersmc:modmenu:${property('deps.modmenu_version')}")
}
shadowJar {
from sourceSets.main.output
from sourceSets.client.output
configurations = [project.configurations.shadow]
//exclude("META-INF")
minimize()
}
remapJar {
dependsOn(shadowJar)
mustRunAfter(shadowJar)
inputFile = file(shadowJar.archivePath)
}
processResources { // I don't know gradle enough to get the ModData class working. I tried defining it, but then property is in the wrong scope.
inputs.property("id", id)
inputs.property("name", mod_name)
inputs.property("version", fullVersion)
inputs.property("earliest_minecraft", earliest_minecraft)
inputs.property("latest_minecraft", latest_minecraft)
inputs.property("yacl_version", yacl)
inputs.property("fabric_api_version", fabric_api)
inputs.property("modmenu_version", modmenu)
inputs.property("java_version", javaVersion)
def map = [
"id": id,
"name": mod_name,
"version": fullVersion,
"earliest_minecraft": earliest_minecraft,
"latest_minecraft": latest_minecraft,
"yacl_version": yacl,
"fabric_api_version": fabric_api,
"modmenu_version": modmenu,
"java_version": javaVersion
]
filesMatching("fabric.mod.json") {
expand(map)
}
}
tasks.withType(JavaCompile).configureEach {
it.options.release = stonecutter.eval(mcVersion, ">=1.20.5") ? 21 : 17
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
}
}
// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = property("mod_id").toString()
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.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
if (stonecutter.current.isActive) {
rootProject.tasks.register("buildActive") {
group = "project"
dependsOn(tasks.named("build"))
}
}
tasks.register('buildAndCollect', Copy) {
group = "build"
from(tasks.remapJar.archiveFile)
into(rootProject.layout.buildDirectory.file("libs/${mod_version}"))
}
publishMods {
file = remapJar.archiveFile
modLoaders.add("fabric")
changelog = rootProject.file("CHANGELOG.md").text
type = STABLE
displayName = "${mod_name} v${mod_version} for Minecraft ${mcVersion}"
dryRun = providers.environmentVariable("DRY_RUN").getOrElse("false") == "true"
github {
accessToken = providers.environmentVariable("GITHUB_TOKEN")
repository = "skycatminepokie/autocut"
commitish = providers.environmentVariable("GITHUB_REF_NAME").getOrElse("master")
}
modrinth {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "DZJzhD8k"
minecraftVersionRange {
start = earliest_minecraft
end = latest_minecraft
}
projectDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText
requires("yacl")
requires("fabric-api")
optional("modmenu")
announcementTitle = "Download version ${fullVersion} from Modrinth"
}
discord {
username = "Mod Updates"
avatarUrl = "https://cataas.com/cat?type=square"
webhookUrl = providers.environmentVariable("DISCORD_WEBHOOK")
dryRunWebhookUrl = providers.environmentVariable("DISCORD_WEBHOOK_DRY_RUN")
content = changelog.map {
"# A new version of Autocut is out! \n" + it
}
}
}