-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
206 lines (175 loc) · 6.7 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
plugins {
id 'dev.architectury.loom' version '1.2-SNAPSHOT'
id 'io.github.juuxel.loom-quiltflower' version '1.+'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'com.modrinth.minotaur' version '2.+'
id 'com.matthewprenger.cursegradle' version '1.4.0'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = "${project.archives_base_name}-mc${project.minecraft_version}"
version = project.mod_version + "." + getVersionSuffix()
group = project.maven_group
afterEvaluate {
logger.lifecycle("Version String: ${version}")
logger.lifecycle(com.ishland.vmp.buildscript.ParseGItHubActionChangelog.getChangelog())
}
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 { url 'https://jitpack.io' }
}
loom {
accessWidenerPath = file("src/main/resources/vmp.accesswidener")
forge {
mixinConfig "vmp.mixins.json"
convertAccessWideners.set(true)
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
}
}
configurations {
api.extendsFrom includeApi
shadowInclude
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
forge "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
// modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// shadowInclude("com.github.RelativityMC.raknetify:fabric:${project.raknetify_version}") {
// transitive = false
// }
// modImplementation ("com.github.RelativityMC.raknetify:fabric:${project.raknetify_version}")
//
// shadowInclude implementation("com.github.RelativityMC.raknetify:common:${project.raknetify_version}") {
// transitive = false
// }
shadowInclude forgeRuntimeLibrary(implementation("com.ibm.async:asyncutil:${async_util_version}"))
annotationProcessor "net.fabricmc:sponge-mixin:0.12.5+mixin.0.8.5"
// Fabric API. This is technically optional, but you probably want it anyway.
// modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}
afterEvaluate {
migrateMappings.configure {
outputDir = project.file("src/main/java")
}
}
processResources {
inputs.property "version", project.version
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
}
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()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
shadowJar {
archiveClassifier = "all-dev"
configurations = [ project.configurations.shadowInclude ]
minimize()
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
exclude "/raknetify*"
relocate "com.ishland.raknetify", "com.ishland.vmp.deps.raknetify"
}
//noinspection UnnecessaryQualifiedReference
task("remapShadowJar", type: net.fabricmc.loom.task.RemapJarTask, dependsOn: shadowJar) {
input = shadowJar.archiveFile
archiveFileName = shadowJar.archiveFileName.get().replaceAll("-dev\\.jar\$", ".jar")
addNestedDependencies = true
}
assemble.dependsOn(remapShadowJar)
afterEvaluate {
net.fabricmc.loom.util.aw2at.Aw2At.setup(project, remapShadowJar)
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
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.
}
}
modrinth {
token = System.getenv("MODRINTH_TOKEN") // This is the default. Remember to have the MODRINTH_TOKEN environment variable set or else this will fail, or set it to whatever you want - just make sure it stays private!
projectId = "vmp-forge" // This can be the project ID or the slug. Either will work!
versionNumber = project.version + "+" + project.minecraft_version // You don't need to set this manually. Will fail if Modrinth has this version already
versionName = project.version + " devbuild for " + project.minecraft_version
versionType = "alpha" // This is the default -- can also be `beta` or `alpha`
uploadFile = remapShadowJar // With Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions = [project.minecraft_version] // Must be an array, even with only one version
loaders = ["forge"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
changelog = com.ishland.vmp.buildscript.ParseGItHubActionChangelog.getChangelog()
}
if (System.getenv("CURSEFORGE_TOKEN")) {
curseforge {
apiKey = System.getenv("CURSEFORGE_TOKEN")
project {
id = '892037'
changelogType = "markdown"
changelog = com.ishland.vmp.buildscript.ParseGItHubActionChangelog.getChangelog()
releaseType = 'alpha'
addGameVersion project.minecraft_version
addGameVersion "Forge"
addGameVersion "Java 17"
mainArtifact(remapShadowJar) {
displayName = project.version + " devbuild for " + project.minecraft_version
}
}
options {
forgeGradleIntegration = false
}
}
}
String getVersionSuffix() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--dirty', '--broken'
standardOutput = stdout
}
stdout = stdout.toString().strip()
def suffix = ""
if (stdout.endsWith("-dirty")) {
stdout = stdout.substring(0, stdout.length() - "-dirty".length())
suffix = "-dirty"
}
if (stdout.endsWith("-broken")) {
stdout = stdout.substring(0, stdout.length() - "-broken".length())
suffix = "-broken"
}
if (stdout.indexOf('-') < 0) {
return "0" + suffix;
}
def split = stdout.split('-')
return split[split.length - 2] + suffix
}