This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
121 lines (101 loc) · 2.75 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
import cuchaz.enigma.command.ConvertMappingsCommand
buildscript {
repositories {
maven {
name "Fabric Repository"
url 'https://maven.fabricmc.net'
}
}
dependencies {
classpath "cuchaz:enigma:0.14.2.138"
}
}
plugins {
id 'maven'
id 'maven-publish'
}
static List<String> getPublishedVersions() {
// TODO Make a new Maven repo for this, under the net.ornithemc group ID
def xml = new URL("https://copetan.jfrog.io/artifactory/minecraft-maven/me/copetan/intermediary/maven-metadata.xml").text
def metadata = new XmlSlurper().parseText(xml)
def versions = metadata.versioning.versions.version*.text();
return versions
}
def publishedVersions = getPublishedVersions()
def localMappingsPath = "$buildDir/v2Mappings"
new File(localMappingsPath).mkdirs()
file('mappings').eachFile {
if (!it.name.endsWith(".tiny")) return
def mcVer = it.name.replace(".tiny", "")
if (publishedVersions.contains(mcVer)) {
project.logger.lifecycle("Skipping ${mcVer} as it has already been released")
return
}
File v1MappingFile = it
File v2MappingFile = new File("$localMappingsPath/${it.name}")
def conversionTask = "convert${it.name}ToV2"
tasks.register(conversionTask) {
group = "V2 Conversion"
inputs.file(v1MappingFile)
outputs.file(v2MappingFile)
doLast {
new ConvertMappingsCommand().run(
"tiny",
v1MappingFile.path,
"tinyv2:official:intermediary",
v2MappingFile.path
)
}
}
Jar makeV1Jar = makeJar(mcVer, v1MappingFile, false)
Jar makeV2Jar = makeJar(mcVer, v2MappingFile, true)
build.dependsOn makeV1Jar
build.dependsOn makeV2Jar
makeV2Jar.dependsOn conversionTask
publishing {
publications {
create("${mcVer.replace(" ", "")}_mavenJava", MavenPublication) {
// TODO Make a new Maven repo for this, under the net.ornithemc group ID
groupId 'me.copetan'
artifactId "intermediary"
version mcVer
artifact(makeV1Jar.archiveFile) {
builtBy makeV1Jar
}
artifact(makeV2Jar.archiveFile) {
builtBy makeV2Jar
classifier = "v2"
}
}
}
}
}
def makeJar(String mcVersion, File mappings, boolean v2) {
def jarFilename = "intermediary-" + mcVersion + (v2 ? "-v2" : "")
return task("${mcVersion}_makeJar" + (v2 ? "v2" : ""), type: Jar) {
baseName jarFilename
from(file(mappings)) {
into "mappings"
rename mappings.name, "mappings.tiny"
}
destinationDirectory = file("build/jars")
}
}
def ENV = System.getenv()
publishing {
repositories {
if (ENV.MAVEN_PUBLISH_TOKEN) {
maven {
// TODO Make a new Maven repo for this, under the net.ornithemc group ID
url 'https://copetan.jfrog.io/artifactory/minecraft-maven/'
credentials {
username 'copebot'
password ENV.MAVEN_PUBLISH_TOKEN
}
authentication {
basic(BasicAuthentication)
}
}
}
}
}