-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
170 lines (140 loc) · 4.98 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
import org.jetbrains.changelog.Changelog
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.8.1"
id 'org.jetbrains.changelog' version '2.+'
}
subprojects {
apply plugin: "dev.architectury.loom"
loom {
silentMojangMappingsLicense()
accessWidenerPath.set(project(":common").file("src/main/resources/antixray.accesswidener"))
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft}"
mappings loom.officialMojangMappings()
compileOnly("com.moandjiezana.toml:toml4j:${project.toml_version}")
// Mixin Extras
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${project.mixin_extras}"))
}
}
allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
var formattedVersion = "${mod_version}+${minecraft}"
archivesBaseName = project.archives_base_name
version = formattedVersion
group = project.maven_group
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.release.set(21)
}
tasks.withType(org.gradle.jvm.tasks.Jar).configureEach {
archiveVersion.set(formattedVersion)
}
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
}
publishMods {
changelog = fetchChangelog()
type = STABLE
def nameFormat = "AntiXray %s ${version.get()}"
def fabric = findProject(':fabric')
def forge = findProject(':forge')
def neoforge = findProject(':neoforge')
def curseforgeOpts = curseforgeOptions {
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
minecraftVersions.add(project.curseforge_minecraft)
}
def modrinthOpts = modrinthOptions {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
minecraftVersions.add(project.minecraft)
projectId = "sml2FMaA"
}
def githubFiles = []
if (fabric != null) {
def fabricJar = fabric.remapJar.archiveFile
githubFiles.add(fabricJar)
curseforge("CurseForge - Fabric") {
from curseforgeOpts
projectId = "511697"
file = fabricJar
modLoaders.add("fabric")
modLoaders.add("quilt")
displayName = nameFormat.formatted("Fabric")
}
modrinth("Modrinth - Fabric") {
from modrinthOpts
file = fabricJar
modLoaders.add("fabric")
modLoaders.add("quilt")
displayName = nameFormat.formatted("Fabric")
}
}
if (forge != null) {
def forgeJar = forge.remapJar.archiveFile
githubFiles.add(forgeJar)
curseforge("CurseForge - Forge") {
from curseforgeOpts
projectId = "560511"
file = forgeJar
modLoaders.add("forge")
displayName = nameFormat.formatted("Forge")
}
modrinth("Modrinth - Forge") {
from modrinthOpts
file = forgeJar
modLoaders.add("forge")
displayName = nameFormat.formatted("Forge")
}
}
if (neoforge != null) {
def neoforgeJar = neoforge.remapJar.archiveFile
githubFiles.add(neoforgeJar)
curseforge("CurseForge - NeoForge") {
from curseforgeOpts
projectId = "560511"
file = neoforgeJar
modLoaders.add("neoforge")
displayName = nameFormat.formatted("NeoForge")
}
modrinth("Modrinth - NeoForge") {
from modrinthOpts
file = neoforgeJar
modLoaders.add("neoforge")
displayName = nameFormat.formatted("NeoForge")
}
}
github {
accessToken = providers.environmentVariable("GITHUB_TOKEN")
repository = providers.environmentVariable("GITHUB_REPOSITORY").getOrElse("DrexHD/dryrun")
commitish = providers.environmentVariable("GITHUB_REF_NAME").getOrElse("dryrun")
// Workaround for https://github.com/modmuss50/mod-publish-plugin/issues/29
githubFiles.each {
if (it != null) {
if (!file.isPresent()) {
file.set(it)
} else {
additionalFiles.from(it)
}
}
}
}
dryRun = githubFiles.isEmpty() || curseforgeOpts.get().accessToken.getOrNull() == null || modrinthOpts.get().accessToken.getOrNull() == null || curseforgeOpts.get().accessToken.getOrNull() == null
}
private String fetchChangelog() {
def log = getChangelog.changelog.get()
if (log.has(project.mod_version)) {
return log.renderItem(
log.get(project.mod_version).withHeader(false),
Changelog.OutputType.MARKDOWN
)
} else {
return ""
}
}