-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
182 lines (152 loc) · 5.01 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
plugins {
id 'java-library'
id 'net.neoforged.moddev' version '1.0.21'
id "com.modrinth.minotaur" version "2.+"
id 'net.darkhax.curseforgegradle' version '1.1.+'
}
tasks.named('wrapper', Wrapper).configure {
distributionType = Wrapper.DistributionType.BIN
}
version = project.mod_version
group = 'terrails.xnetgases'
base {
archivesName = "xnetgases-${project.minecraft_version}"
}
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
neoForge {
version = project.neoforge_version
parchment {
minecraftVersion = project.minecraft_version
mappingsVersion = project.parchment_version
}
runs {
client {
client()
programArgument '--width=1280'
programArgument '--height=720'
}
server {
server()
programArgument '--nogui'
}
configureEach {
gameDirectory = layout.projectDir.dir("run/$name")
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'neoforge.enabledGameTestNamespaces', 'xnetgases'
logLevel = org.slf4j.event.Level.DEBUG
}
}
mods {
xnetgases {
sourceSet(sourceSets.main)
}
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
maven { url 'https://modmaven.dev/' }
exclusiveContent {
forRepository {
maven {
url "https://cursemaven.com"
}
}
filter {
includeGroup "curse.maven"
}
}
}
dependencies {
// XNet
implementation "curse.maven:xnet-260912:${project.xnet_fileId}"
implementation "curse.maven:rftools-base-326041:${project.rftoolsbase_fileId}"
implementation "curse.maven:mcjtylib-233105:${project.mcjtylib_fileId}"
// Mekanism
implementation "mekanism:Mekanism:${project.mekanism_version}"
}
java {
withSourcesJar()
}
artifacts {
archives sourcesJar
}
tasks.named('jar', Jar).configure {
manifest.attributes([
"Specification-Title" : "xnetgases",
"Specification-Vendor" : "Terrails",
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : project.mod_version,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
tasks.register('printChangelog') {
doLast {
println(fetchChangelog())
}
}
ext.fetchChangelog = {
def branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
if (branch.isBlank() || branch == "HEAD") {
throw new GradleException("Branch name could not be fetched.")
}
def repoUrl = "https://github.com/Terrails/xnet-gases"
def changes = new StringBuilder("Latest changes ([See all](${repoUrl}/commits/${branch}))\n---")
def log = "git log --max-count=30 --no-merges --pretty=format:\"* %s ([%h](${repoUrl}/commit/%H))\"".execute()
log.in.eachLine { line ->
if (!line.startsWithIgnoreCase("* bump")) { // version change commits should be ignored
changes << "\n${line}"
}
}
if (log.waitFor() == 0) {
return changes.toString()
} else {
throw new GradleException("Received an error while executing git log.")
}
}
tasks.build.mustRunAfter(tasks.clean)
tasks.register('publishProduction') {
dependsOn([tasks.clean, tasks.build])
finalizedBy([tasks.modrinth, tasks.publishCurseForge])
}
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = "${rootProject.modrinth_id}"
versionNumber = "${project.version}"
versionName = "${rootProject.minecraft_version}-v${project.version}"
uploadFile = tasks.jar.getArchiveFile().get()
gameVersions = [rootProject.minecraft_version]
loaders = ["neoforge"]
dependencies {
required.project "xnet"
required.project "mekanism"
}
changelog = fetchChangelog()
additionalFiles = [tasks.sourcesJar.getArchiveFile().get()]
}
import net.darkhax.curseforgegradle.TaskPublishCurseForge
tasks.register('publishCurseForge', TaskPublishCurseForge) {
apiToken = System.getenv("CURSEFORGE_TOKEN")
disableVersionDetection()
def mainFile = upload(rootProject.curseforge_id, tasks.jar.getArchiveFile().get())
mainFile.displayName = "${rootProject.minecraft_version}-v${project.version}"
mainFile.releaseType = "release"
mainFile.changelog = fetchChangelog()
mainFile.changelogType = "markdown"
mainFile.addGameVersion(rootProject.minecraft_version)
mainFile.addModLoader("neoforge")
mainFile.addRequirement("xnet", "mekanism")
mainFile.withAdditionalFile(tasks.sourcesJar.getArchiveFile().get())
}