-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.gradle
249 lines (225 loc) · 8.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
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
238
239
240
241
242
243
244
245
246
247
248
249
import groovy.json.JsonOutput
plugins {
id 'java'
id 'maven-publish'
id 'signing'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'net.neoforged.gradle.userdev' version '7.0.97'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withSourcesJar()
withJavadocJar()
}
group = 'io.codechicken'
base {
archivesName = 'CBMultipart'
}
sourceSets.main.resources.srcDirs += "src/main/generated"
mod_version = "${mod_version}." + (System.getenv("BUILD_NUMBER") ?: "1")
version = "${mc_version}-${mod_version}"
println "Starting build of ${base.archivesName.get()}, Version: ${mod_version}"
println "Using Forge: ${forge_version}, for Minecraft: ${mc_version}"
minecraft {
accessTransformers.file file("src/main/resources/META-INF/accesstransformer.cfg")
}
runs {
configureEach {
modSource project.sourceSets.main
}
client {
workingDirectory file('run')
}
server {
workingDirectory file('run')
}
data {
workingDirectory file('run')
programArguments.addAll '--mod', 'cb_multipart', '--mod', 'cb_microblock', '--all', '--flat', '--output', file("src/main/generated").absolutePath, '--existing', file("src/main/resources").absolutePath
}
}
configurations {
shadow
implementation.extendsFrom shadow
}
repositories {
mavenLocal()
maven { url = "https://maven.covers1624.net/" }
}
dependencies {
implementation "net.neoforged:neoforge:${forge_version}"
//Mod deps
implementation "io.codechicken:CodeChickenLib:${mc_version}-${ccl_version}"
//Packed into built jar.
shadow("io.codechicken:TraitMixinCompiler:${mixin_version}") { transitive = false }
shadow("io.codechicken:ChickenASM:${chicken_asm_version}") { transitive = false }
}
processResources {
inputs.property 'mod_version', mod_version
inputs.property 'mc_version', mc_version
inputs.property 'ccl_version', ccl_version
filesMatching('META-INF/mods.toml') {
expand 'file': ['jarVersion': mod_version],
'mc_version': mc_version,
'forge_version': forge_version,
'lang_version': forge_version.split('\\.')[0],
'ccl_version_range': "[${ccl_version.replace(".+", "")},${ccl_version_max})"
}
}
def publishingMetadata = project.layout.buildDirectory.file("libs/${base.archivesName.get()}-$version-publishing.json")
def publishingMetadataTask = tasks.register("publishingMetadata") {
outputs.file(publishingMetadata)
doFirst {
publishingMetadata.get().asFile.text = JsonOutput.prettyPrint(JsonOutput.toJson([
[
'displayName' : "CB Multipart ${version}",
'mcVersion' : "${mc_version}",
'version' : "${mod_version}",
'classifier' : null,
'modLoader' : 'neoforge',
'curseforgeId': '258426',
'modrinthId' : 'LmvnWWSV',
'dependencies': [
[
'modId' : 'codechickenlib',
'type' : 'required',
'modrinthId' : '2gq0ALnz',
'curseforgeId': 'codechicken-lib-1-8'
]
]
]
]))
}
}
jar.enabled = false//Disable normal jar, is replaced by ShadowJar.
shadowJar {
finalizedBy 'signShadowJar'
archiveClassifier = ''
manifest {
attributes 'Specification-Title': base.archivesName.get()
attributes 'Specification-Vendor': 'covers1624'
attributes 'Specification-Version': "1"
attributes 'Implementation-Title': base.archivesName.get()
attributes 'Implementation-Vendor': 'covers1624'
attributes 'Implementation-Version': version
attributes 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
attributes 'MixinConfigs': 'mixins.cbmultipart.json'
}
configurations = [project.configurations.shadow]
mergeServiceFiles()
exclude 'module-info.class'
}
build.dependsOn shadowJar
tasks.register("signShadowJar") {
dependsOn("shadowJar")
doFirst {
def args = [:]
args['jar'] = shadowJar.archiveFile.get().asFile
if (System.getenv("KEY_STORE")) {
args['keyStore'] = System.getenv("KEY_STORE")
file(System.getenv("KEY_STORE_PROPS")).withReader {
def props = new Properties()
props.load(it)
args.putAll(props)
}
} else if (project.hasProperty('keyStore')) {
args['keyStore'] = project.getProperty('keyStore')
args['alias'] = project.getProperty('keyStoreAlias')
args['storePass'] = project.getProperty('keyStorePass')
args['keyPass'] = project.getProperty('keyStoreKeyPass')
} else {
println "No signing properties."
state.setOutcome(org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE)
didWork = false
return
}
project.ant.invokeMethod('signjar', args)
}
}
javadoc {
options.addBooleanOption("Xdoclint:none", true)
}
publishing {
repositories {
if (System.getenv('MAVEN_PASS')) {
maven {
url "https://nexus.covers1624.net/repository/maven-releases/"
credentials {
username 'covers1624'
password System.getenv('MAVEN_PASS')
}
}
}
}
publications {
Multipart(MavenPublication) {
groupId project.group
artifactId project.base.archivesName.get()
version project.version
artifact shadowJar
artifact sourcesJar
artifact javadocJar
artifact(publishingMetadata) {
builtBy publishingMetadataTask
classifier 'publishing'
}
pom {
name = base.archivesName.get()
description = base.archivesName.get()
url = "https://github.com/TheCBProject/${base.archivesName.get()}"
scm {
url = "https://github.com/TheCBProject/${base.archivesName.get()}"
connection = "scm:git:git://github.com/TheCBProject/${base.archivesName.get()}.git"
connection = "scm:git:[email protected]:TheCBProject/${base.archivesName.get()}.git"
}
issueManagement {
system = 'github'
url = "https://github.com/TheCBProject/${base.archivesName.get()}/issues"
}
licenses {
license {
name = "GNU Lesser Public License (GPL), Version 2.1"
url = "https://raw.githubusercontent.com/TheCBProject/${base.archivesName.get()}/master/LICENSE.txt"
distribution = 'repo'
}
}
developers {
developer {
id = 'covers1624'
name = 'covers1624'
}
}
developers {
developer {
id = 'mrtjp'
name = 'MrTJP'
}
}
developers {
developer {
id = 'chicken-bones'
name = 'chicken-bones'
}
}
}
}
}
}
signing {
if (System.getenv('GPG_PRIVATE_KEY')) {
useInMemoryPgpKeys(
new File(System.getenv('GPG_PRIVATE_KEY')).text,
System.getenv('GPG_PRIVATE_KEY_PASS')
)
} else if (project.hasProperty('gpgPrivateKey')) {
useInMemoryPgpKeys(
new File(project.getProperty('gpgPrivateKey')).text,
project.getProperty('gpgPrivateKeyPass')
)
} else {
return
}
sign publishing.publications.Multipart
}