forked from railcraft-reborn/railcraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
211 lines (175 loc) · 6.16 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
import se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask
import static org.apache.commons.lang3.StringUtils.repeat
plugins {
id 'eclipse'
id 'idea'
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id 'org.spongepowered.mixin' version '0.7.+'
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.80.0'
id 'me.modmuss50.mod-publish-plugin' version '0.3.4'
}
// Simple name to not have long names when publishing with the CI
version = "$minecraft_version-$mod_version"
group = 'mods.railcraft'
base {
archivesName = 'railcraft-reborn'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
println(repeat('*', 60))
println("Project Version: $version")
println("Java: ${System.getProperty('java.version')}")
println("JVM: ${System.getProperty('java.vm.version')} (${System.getProperty('java.vendor')})")
println("Arch: ${System.getProperty('os.arch')}")
println(repeat('*', 60))
sourceSets {
api {
// API has no resources
resources.srcDirs = []
}
main {
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
resources {
srcDir 'src/generated/resources'
exclude '.cache'
}
}
test {
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
}
}
configurations {
apiImplementation.extendsFrom(implementation)
apiRuntimeOnly.extendsFrom(runtimeOnly)
}
minecraft {
mappings channel: mappings_channel, version: mappings_version
copyIdeResources = true
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
configureEach {
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'railcraft'
// Enables better hot reloading if using the JetBrains Runtime
jvmArgs '-XX:+AllowEnhancedClassRedefinition', '-XX:+IgnoreUnrecognizedVMOptions', '-XX:+AllowRedefinitionToAddDeleteMethods'
args '--mixin', 'railcraft.mixins.json'
mods {
railcraft {
source sourceSets.main
source sourceSets.api
source sourceSets.test
}
}
}
client {
workingDirectory project.file('run/client')
}
server {
workingDirectory project.file('run/server')
}
data {
workingDirectory project.file('run/data')
args '--mod', 'railcraft', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
}
gameTestServer {
workingDirectory project.file('run/test')
}
}
}
repositories {
maven {
name 'sponge'
url 'https://repo.spongepowered.org/repository/maven-public'
}
maven {
name 'JEI'
url 'https://maven.blamejared.com/'
}
}
dependencies {
minecraft group: 'net.neoforged', name: 'forge', version: "$minecraft_version-$neo_version"
annotationProcessor group: 'org.spongepowered', name: 'mixin', version: mixin_version, classifier: 'processor'
testAnnotationProcessor group: 'org.spongepowered', name: 'mixin', version: mixin_version, classifier: 'processor'
compileOnly fg.deobf("mezz.jei:jei-$minecraft_version-common-api:$jei_version")
compileOnly fg.deobf("mezz.jei:jei-$minecraft_version-forge-api:$jei_version")
runtimeOnly fg.deobf("mezz.jei:jei-$minecraft_version-forge:$jei_version")
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
mod_version: mod_version
]
inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
}
tasks.named('jar', Jar).configure {
from([sourceSets.api.output, sourceSets.main.output])
manifest {
attributes([
'Specification-Title' : project.name,
'Specification-Vendor' : 'Sm0keySa1m0n, Edivad99',
'Specification-Version' : '1',
'Implementation-Title' : project.name,
'Implementation-Version' : project.version,
'Implementation-Vendor' : 'Sm0keySa1m0n, Edivad99',
'Implementation-Commit' : 'git rev-parse HEAD'.execute().text.trim(), // this exists if you used git clone else its null.
'Implementation-Timestamp' : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'MixinConfigs' : 'railcraft.mixins.json'
])
}
finalizedBy 'reobfJar'
}
task apiJar(type: Jar, group: 'build') {
from sourceSets.api.output
archiveClassifier = 'api'
manifest.from(jar.manifest)
}
artifacts {
archives jar
archives apiJar
}
mixin {
add sourceSets.main, 'railcraft.refmap.json'
}
tasks.register('makeChangelog', GitChangelogTask) {
fromRepo = projectDir.absolutePath.toString()
fromRevision = 'cbe30d7fab88e74ddf748ddb3dcf0112b7e645d3'
toRevision = 'HEAD'
file = file('CHANGELOG.md')
untaggedName = 'Next release'
templateContent = file('changelog.mustache').text
ignoreCommitsIfMessageMatches = '^.*Merge branch.*$'
}
publishMods {
displayName = "railcraft-reborn-$minecraft_version-$mod_version"
version = mod_version
type = BETA
def changelogFile = file('CHANGELOG.md')
changelog = changelogFile.exists() ? changelogFile.text : 'CHANGELOG.md not found'
modLoaders.add('neoforge')
if (minecraft_version.equals('1.20.1')) {
modLoaders.add('forge')
}
file = jar.archiveFile
additionalFiles.from(apiJar)
curseforge {
projectId = '901491'
accessToken = providers.environmentVariable('CURSEFORGE_TOKEN')
minecraftVersions.add(minecraft_version)
}
modrinth {
projectId = 'rO6kKst6'
accessToken = providers.environmentVariable('MODRINTH_TOKEN')
minecraftVersions.add(minecraft_version)
}
}