-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
98 lines (86 loc) · 2.89 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
plugins {
id 'de.undercouch.download'
id 'maven-publish'
id 'net.neoforged.gradleutils' version '3.0.0-alpha.13'
}
repositories {
mavenCentral()
}
import groovy.json.JsonSlurper
import net.neoforged.minecraftdependencies.*
if (!project.hasProperty("minecraftVersion")) {
throw new GradleException("Please set a minecraftVersion Gradle property")
}
version = project.minecraftVersion
tasks.register('downloadVersionManifest', Download) {
src 'https://piston-meta.mojang.com/mc/game/version_manifest_v2.json'
dest layout.buildDirectory.file('manifest/version_manifest_v2.json')
useETag 'all'
onlyIfModified true
quiet true
}
tasks.register('downloadJson', DownloadWithVersion) {
dependsOn tasks.downloadVersionManifest
def moduleVersion = it.moduleVersion
def manifest = tasks.downloadVersionManifest.dest
inputs.file manifest
src {
new JsonSlurper().parse(manifest).versions.find{ it.id == moduleVersion.get() }.url
}
dest layout.buildDirectory.file(moduleVersion.map { "versions/$it/version.json"})
useETag 'all'
onlyIfModified true
quiet true
}
tasks.register('downloadServerJar', DownloadWithVersion) {
dependsOn tasks.downloadJson
def versionJson = tasks.downloadJson.dest
inputs.file versionJson
src {
new JsonSlurper().parse(versionJson).downloads.server.url
}
dest layout.buildDirectory.file(moduleVersion.map { "versions/$it/server.jar"})
useETag 'all'
onlyIfModified true
quiet true
}
tasks.register('makeModuleMetadata', GenerateModuleMetadata) {
dependsOn tasks.downloadJson
dependsOn tasks.downloadServerJar
meta = tasks.downloadJson.dest
serverJar = tasks.downloadServerJar.dest
moduleGroup = project.group
moduleName = project.name
outputFile = layout.buildDirectory.file("publications/metadata.module")
}
configurations {
moduleMetadata
}
def moduleMetadataArtifact = artifacts.add('moduleMetadata', tasks.makeModuleMetadata.outputFile) {
type = "module"
builtBy tasks.makeModuleMetadata
}
import net.neoforged.gradleutils.GradleUtils
publishing {
publications {
timed(MavenPublication) {
artifactId rootProject.name
artifact moduleMetadataArtifact
pom {
withXml {
def elem = asElement()
def comment = elem.getOwnerDocument().createComment(' do_not_remove: published-with-gradle-metadata ')
elem.insertBefore(comment, elem.getFirstChild())
}
}
repositories {
maven(GradleUtils.setupSnapshotCompatiblePublishing(
project.providers.provider { project.version },
'https://maven.neoforged.net/mojang-meta/',
file('repo'),
file('snapshot')
))
}
}
}
}