-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
227 lines (196 loc) · 7.11 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
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath "gradle.plugin.se.bjurr.gitchangelog:git-changelog-gradle-plugin:1.71.8"
classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0'
classpath 'org.ajoberstar.grgit:grgit-gradle:4.1.1'
}
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.ajoberstar.grgit'
apply plugin: 'se.bjurr.gitchangelog.git-changelog-gradle-plugin'
apply plugin: 'com.matthewprenger.cursegradle'
def branch = grgit.branch.current()
println "On branch: ${branch.fullName}"
println "Pipeline branch: " + (System.getenv('CI_COMMIT_BRANCH') ?: 'NONE')
group = 'com.github.percivalalb'
archivesBaseName = "MapMakingTools-${project.target_mc_version}"
version = (grgit.describe(longDescr: true, tags: true) ?: '0-0-0').split('-').with { it -> "${it[0]}.${it[1]}" }
println "Version: ${version}"
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
sourceSets {
api
main {
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
resources.srcDirs += 'src/generated/resources'
}
test {
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
}
}
configurations {
apiImplementation.extendsFrom(implementation)
apiRuntimeOnly.extendsFrom(runtimeOnly)
}
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
repositories {
maven {
url "https://dvs1.progwml6.com/files/maven"
content { includeGroup "mezz.jei" }
}
maven {
url "https://modmaven.k-4u.nl"
content { includeGroup "mezz.jei" }
}
}
minecraft {
mappings channel: project.mcp_channel, version: project.mcp_mappings
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
taskName 'mapmakingtools_client'
workingDirectory file('run')
property 'forge.logging.console.level', 'debug'
mods {
mapmakingtools.sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
server {
taskName 'mapmakingtools_server'
workingDirectory file('run-server')
property 'forge.logging.console.level', 'debug'
mods {
mapmakingtools.sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
data {
taskName 'mapmakingtools_data'
workingDirectory file('run')
property 'forge.logging.console.level', 'debug'
args '--mod', 'mapmakingtools', '--all', '--output', '"' + file('src/generated/resources/') + '"', '--existing', '"' + sourceSets.main.resources.srcDirs[0] + '"'
mods {
mapmakingtools.sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
}
}
dependencies {
minecraft "net.minecraftforge:forge:${project.forge_version}"
compileOnly fg.deobf("mezz.jei:jei-${jei_version}:api")
runtimeOnly fg.deobf("mezz.jei:jei-${jei_version}")
}
task sourcesJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier = "sources"
from sourceSets.main.allJava
from sourceSets.api.allJava
}
task apiJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier = "api"
from sourceSets.api.output
from sourceSets.api.allJava
}
artifacts {
archives sourcesJar
archives apiJar
}
def replaceResources = tasks.register('replaceResources', Copy) {
it.outputs.upToDateWhen { false }
it.from(sourceSets.main.resources) {
include 'META-INF/mods.toml'
expand([
'version': project.version,
'minecraft_version_range': project.minecraft_version_range,
'forge_version_range': project.forge_version_range,
'fml_version_range': project.fml_version_range,
])
}
it.into "$buildDir/resources/main/"
}
def generateGBLangFile = tasks.register('generateGBLangFile',) {
def inputFile = file('src/main/resources/assets/mapmakingtools/lang/en_us.json');
def outputFile = file("$buildDir/resources/main/assets/mapmakingtools/lang/en_gb.json")
inputs.files inputFile
outputs.files outputFile
doLast {
def json = new groovy.json.JsonSlurper().parseText(inputFile.text)
json.replaceAll { key, value ->
value = value.replaceAll("(?i)(c)olor", "\$1olour");
value = value.replaceAll("(?i)(a)rmor", "\$1rmour");
return value;
}
def dataGB = groovy.json.JsonOutput.toJson(json)
dataGB = groovy.json.JsonOutput.prettyPrint(dataGB)
outputFile.write(dataGB + System.getProperty("line.separator"));
}
}
processResources {
duplicatesStrategy(DuplicatesStrategy.FAIL)
exclude('META-INF/mods.toml')
configure {
finalizedBy(replaceResources)
finalizedBy(generateGBLangFile)
}
}
classes.configure {
dependsOn(replaceResources)
dependsOn(generateGBLangFile)
}
jar {
from sourceSets.main.output
from sourceSets.api.output
manifest {
attributes([
"Specification-Title": "Map Making Tools",
"Specification-Vendor": "percivalalb",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": project.version,
"Implementation-Vendor" :"percivalalb",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
file = file("$buildDir/changelog.html")
untaggedName = "Current release ${project.version}"
fromCommit = 'd43c7a6c50572d1f8088158a70b45a2ee9dde0a2'
toRef = 'HEAD'
templateContent = file('changelog.mustache').getText('UTF-8')
}
curseforge {
apiKey = findProperty('curseforge_api_key') ?: 0
project {
id = project.curseforge_project_id
changelog = file("$buildDir/changelog.html")
changelogType = 'html'
releaseType = 'beta'
addGameVersion project.target_mc_version
for (String v : project.additional_mc_versions.split(',')) {
if (v) {
addGameVersion v
}
}
addArtifact apiJar
}
options {
detectNewerJava = true
debug = !(System.getenv('CI') && !version.endsWith('SNAPSHOT'))
}
}
// Must be done in afterEvaluate as the specific curseforge$id
// task is generated lazily
afterEvaluate {
tasks.named("curseforge${project.curseforge_project_id}").get().dependsOn makeChangelog
}