This repository has been archived by the owner on Jul 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle
285 lines (243 loc) · 7.87 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
plugins {
id 'fabric-loom'
id 'maven-publish'
id 'signing'
id "com.jfrog.bintray"
id "com.github.fudge.forgedflowerloom" version "2.0.0"
}
def total_version = "$mod_version+$minecraft_version"
def githubUrl = "https://github.com/$github_repo"
archivesBaseName = mod_id
version = total_version
group = project.maven_group
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
// maven { url "https://minecraft.curseforge.com/api/maven/" }
// maven { url 'http://maven.sargunv.s3-website-us-west-2.amazonaws.com/' }
}
minecraft {
}
sourceSets {
testmod {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
test {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modApi "net.fabricmc:fabric-loader:${project.loader_version}"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
testImplementation "org.junit.jupiter:junit-jupiter-params:5.4.2"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.4.2"
testmodImplementation sourceSets.main.output
modRuntime("net.fabricmc.fabric-api:fabric-api:$fabric_version")
// modRuntime "io.github.prospector.modmenu:ModMenu:1.6.2-92"
// modRuntime "foamfix-for-minecraft:foamfix:0.12.1"
// modRuntime "me.shedaniel:RoughlyEnoughItems:2.9.4+build.129"
// modRuntime "me.sargunvohra.mcmods:auto-config:1.1.2+mc1.14.1"
// modRuntime "informed-load-fabric:informedload:2.1.0:1.14"
}
test { useJUnitPlatform() }
processResources {
inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand "version": project.version
}
}
tasks.withType(JavaCompile) { options.encoding = "UTF-8" }
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
jar { from "LICENSE" }
def pomConfig = {
licenses {
license {
name project.license
}
}
developers {
developer {
id "fudge"
name "natan"
email "[email protected]"
}
}
scm {
url githubUrl
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
jar {
from "LICENSE"
}
String tryProp(String key) {
return project.hasProperty(key) ? project.property(key) : ""
}
//bintray {
// user = tryProp('bintray_user')
// key = tryProp('bintray_api_key')
// publications = ["MavenPublication"]
// publish = true //[Default: false] Whether version should be auto published after an upload
// pkg {
// repo = "libs"
// name = mod_id
// desc = mod_description
// websiteUrl = githubUrl
// issueTrackerUrl = "$githubUrl/issues"
// githubRepo = github_repo //Optional Github repository
// githubReleaseNotesFile = 'README.md' //Optional Github readme file
// licenses = [license]
// vcsUrl = githubUrl
// version {
// name = total_version
// released = new Date()
// }
// }
//
//}
afterEvaluate {
artifacts {
archives remapJar
archives remapSourcesJar.output
}
signing {
sign configurations.archives
}
publishing {
publications {
mavenJava(MavenPublication) {
customizePom(pom)
groupId maven_group
artifactId mod_id
version total_version
artifact(remapJar)
artifact(sourcesJar) {
classifier = "sources"
builtBy remapSourcesJar
}
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
}
}
// println(project.tasks.signArchives.signatureFiles.files())
// create the signed artifacts
project.tasks.signArchives.signatureFiles.filter { f ->
String name = f.getName()
!name.endsWith("-dev.jar.asc")
}.each {
artifact(it) {
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/
if (matcher.find()) {
classifier = matcher.group(1)
} else {
classifier = null
}
extension = 'jar.asc'
}
}
}
}
repositories {
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username tryProp("nexusUsername")
password tryProp("nexusPassword")
}
}
}
}
}
def customizePom(pom) {
pom.withXml {
def root = asNode()
// eliminate test-scoped dependencies (no need in maven central POMs)
root.dependencies.removeAll { dep ->
dep.scope == "test"
}
// add all items necessary for maven central publication
root.children().last() + {
def githubUrl = "https://github.com/$github_repo"
resolveStrategy = Closure.DELEGATE_FIRST
description mod_description
name mod_id
url githubUrl
organization {
name maven_group
url githubUrl
}
issueManagement {
system 'GitHub'
url "${githubUrl}/issues"
}
licenses {
license {
name license
url 'https://opensource.org/licenses/MIT'
distribution 'repo'
}
}
scm {
url "https://github.com/${github_repo}"
connection "scm:git:git://github.com/${github_repo}.git"
developerConnection "scm:git:ssh://[email protected]:${github_repo}.git"
}
developers {
developer {
name 'Fudge'
}
developer {
name 'OliviaTheVampire'
}
}
}
}
}
model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
}
tasks.publishMavenJavaPublicationToMavenLocal {
dependsOn project.tasks.signArchives
}
tasks.publishMavenJavaPublicationToMavenRepository {
dependsOn project.tasks.signArchives
}
}
Properties properties = new Properties()
properties.put("total_version", total_version)
task updateTemplate(type: Copy) {
group = "template"
description = "Switches out variables like \$total_version in .template.md files, and copies the results into .md files."
from(rootDir)
include("**/*.template.md")
filesMatching("**/*.template.md") {
def extensionLength = ".template.md".length()
name = sourceName.substring(0, sourceName.length() - extensionLength) + ".md"
expand(properties)
}
destinationDir = rootDir
}
publish.dependsOn updateTemplate
//bintrayUpload.dependsOn updateTemplate
//bintrayUpload.dependsOn build
//bintrayUpload.dependsOn generatePomFileForMavenPublicationPublication