forked from ModFest/scattered-shards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
237 lines (208 loc) · 7.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
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
import groovy.xml.XmlSlurper
//file:noinspection GroovyAssignabilityCheck
//file:noinspection GroovyAccessibility
plugins {
id "maven-publish"
id 'dev.architectury.loom' version '1.7-SNAPSHOT'
alias libs.plugins.minotaur
}
version = "$baseVersion+$branch"
archivesBaseName = project.slug
repositories {
maven { url 'https://maven.neoforged.net/releases' }
maven { url "https://server.bbkr.space/artifactory/libs-release" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://repo.sleeping.town/" }
maven { url "https://maven.su5ed.dev/releases" }
}
dependencies {
// implementation libs.kaleidoConfig
// include libs.kaleidoConfig
// forgeRuntimeLibrary libs.kaleidoConfig
minecraft libs.mc
mappings loom.layered {
it.mappings(variantOf(libs.yarn) { classifier "v2" })
it.mappings(libs.yarnpatch)
}
neoForge libs.nf
// modImplementation libs.fl
// modImplementation libs.fapi
// It somehow doesn't remap correctly in arch loom?
// modImplementation libs.libgui
// modImplementation libs.fpapi
// include libs.libgui
// include libs.fpapi
implementation 'io.lettuce:lettuce-core:6.2.3.RELEASE'
include 'io.lettuce:lettuce-core:6.2.3.RELEASE'
forgeRuntimeLibrary 'io.lettuce:lettuce-core:6.2.3.RELEASE'
modApi libs.archapi
// Fetch the version of the fabric-api modules from the pom file
def moduleVer = [:]
ArtifactResolutionQuery query = dependencies.createArtifactResolutionQuery()
.forModule("org.sinytra.forgified-fabric-api", "forgified-fabric-api", libs.versions.fapi.get())
.withArtifacts(MavenModule, MavenPomArtifact)
ArtifactResolutionResult result = query.execute()
for (component in result.resolvedComponents) {
Set<ArtifactResult> mavenPomArtifacts = component.getArtifacts(MavenPomArtifact)
for (artifact in mavenPomArtifacts) {
def pom = new XmlSlurper().parse(artifact.file)
for (dependency in pom.dependencies.dependency) {
moduleVer.put(dependency.artifactId.toString(), dependency.version.toString())
}
}
}
modImplementation include("org.sinytra.forgified-fabric-api:fabric-api-base:${moduleVer['fabric-api-base']}")
modImplementation include("org.sinytra.forgified-fabric-api:fabric-lifecycle-events-v1:${moduleVer['fabric-lifecycle-events-v1']}")
modImplementation include("org.sinytra.forgified-fabric-api:fabric-resource-loader-v0:${moduleVer['fabric-resource-loader-v0']}")
modImplementation include("org.sinytra.forgified-fabric-api:fabric-rendering-v1:${moduleVer['fabric-rendering-v1']}")
modImplementation include("org.sinytra.forgified-fabric-api:fabric-command-api-v2:${moduleVer['fabric-command-api-v2']}")
modImplementation include("org.sinytra:fabric-loader:${libs.versions.fl.get()}")
}
loom {
accessWidenerPath = file("src/main/resources/${modId}.accesswidener")
}
processResources {
final Map<String, String> meta = [
version : version,
modId : modId,
modName : modName,
modDescription: modDescription,
homepage : "https://modrinth.com/mod/${slug}",
issues : "https://github.com/${user}/${slug}/issues",
sources : "https://github.com/${user}/${slug}",
license : license,
authors : authors.split(", ").join("\",\n \""),
contributors : contributors.split(", ").join("\",\n \""),
members : "${authors}. Contributions by ${contributors}",
mc : compatibleVersions.split(", ")[0],
fl : libs.versions.fl.get(),
fapi : libs.versions.fapi.get(),
libgui : libs.versions.libgui.get(),
fpapi : libs.versions.fpapi.get()
]
inputs.properties meta
filesMatching("*.mod.json") { expand(meta) }
filesMatching("META-INF/*mods.toml") { expand(meta) }
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 21
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
jar {
from("LICENSE") {
rename { "${it}_${archivesBaseName}" }
}
}
remapJar {
atAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
modrinth {
token = "$System.env.MODRINTH_TOKEN"
projectId = slug
versionNumber = project.version
uploadFile = remapJar
gameVersions = compatibleVersions.split(", ").toList()
loaders = compatibleLoaders.split(", ").toList()
changelog = "$System.env.CHANGELOG"
syncBodyFrom = "<!--DO NOT EDIT MANUALLY: synced from gh readme-->\n" + rootProject.file("README.md").text
dependencies {
required.version "fabric-api", libs.versions.fapi.get()
embedded.version "fabric-permissions-api", libs.versions.fpapi.get()
}
}
publishing {
publications {
// Modified by TeaCon
register('release', MavenPublication) {
// noinspection GroovyAssignabilityCheck
from components.java
version = rootProject.version
groupId = rootProject.group
artifactId = "$mod_github_repo-NeoForge-$rootProject.compatibleVersions"
pom {
name = mod_github_repo
url = "https://github.com/$mod_github_owner/$mod_github_repo"
licenses {
license {
name = mod_license
url = "https://github.com/$mod_github_owner/$mod_github_repo/blob/HEAD/LICENSE"
}
}
organization {
name = 'TeaConMC'
url = 'https://github.com/teaconmc'
}
developers {
for (mod_author in "$mod_authors".split(',')) {
developer { id = mod_author.trim(); name = mod_author.trim() }
}
}
issueManagement {
system = 'GitHub Issues'
url = "https://github.com/$mod_github_owner/$mod_github_repo/issues"
}
scm {
url = "https://github.com/$mod_github_owner/$mod_github_repo"
connection = "scm:git:git://github.com/$mod_github_owner/${mod_github_repo}.git"
developerConnection = "scm:git:[email protected]:$mod_github_owner/${mod_github_repo}.git"
}
}
}
}
repositories {
// Modified by TeaCon
maven {
name "teacon"
url "s3://maven/"
credentials(AwsCredentials) {
accessKey = System.env.ARCHIVE_ACCESS_KEY
secretKey = System.env.ARCHIVE_SECRET_KEY
}
}
}
}
// Added by TeaCon
tasks.withType(PublishToMavenRepository).configureEach {
if (repository && repository.name == "archive") {
it.onlyIf {
System.env.MAVEN_USERNAME && System.env.MAVEN_PASSWORD
}
}
}
abstract class TeaConDumpPathToGitHub extends DefaultTask {
@Input
abstract Property<String> getPublishName()
@InputFile
abstract RegularFileProperty getTargetFile()
@TaskAction
void dump() {
if (System.env.GITHUB_ACTIONS) {
File theFile = targetFile.getAsFile().get()
def outputFile = new File(System.env.GITHUB_OUTPUT)
// Use the env-specific line separator for maximally possible compatibility
def newLine = System.getProperty('line.separator')
// Write out new env variable for later usage
outputFile << newLine << "artifact_name=${theFile.getName()}"
outputFile << newLine << "artifact_publish_name=${publishName.get()}"
outputFile << newLine << "artifact_path=${theFile.absolutePath}"
}
}
}
// Added by TeaCon
tasks.register("githubActionOutput", TeaConDumpPathToGitHub) { task ->
task.onlyIf { System.env.GITHUB_ACTIONS }
task.getTargetFile().set(jar.archiveFile)
task.getPublishName().set("${jar.archiveBaseName.get()}-${version}.jar")
}