-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.gradle
113 lines (96 loc) · 2.72 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
buildscript {
repositories {
maven {
name "Fabric Repository"
url 'https://maven.fabricmc.net'
}
}
dependencies {
classpath "net.fabricmc:mapping-io:0.3.0"
}
}
plugins {
id 'maven-publish'
}
import net.fabricmc.mappingio.MappingReader
import net.fabricmc.mappingio.MappingWriter
import net.fabricmc.mappingio.format.MappingFormat
import net.fabricmc.mappingio.adapter.MappingNsCompleter
tasks.register("build")
def ENV = System.getenv()
def localMappingsPath = "$buildDir/v2Mappings"
new File(localMappingsPath).mkdirs()
file('mappings').eachFile {
if (!it.name.endsWith(".tiny")) return
def mcVer = it.name.replace(".tiny", "")
File v1MappingFile = it
File v2MappingFile = new File("$localMappingsPath/${it.name}")
def conversionTask = tasks.register("convert${it.name}ToV2") {
group = "V2 Conversion"
inputs.file(v1MappingFile)
outputs.file(v2MappingFile)
doLast {
MappingWriter.create(v2MappingFile.toPath(), MappingFormat.TINY_2).withCloseable {
def visitor = new MappingNsCompleter(it, ["intermediary": "official"], true)
MappingReader.read(v1MappingFile.toPath(), visitor)
}
}
}
def makeV1Jar = makeJar(mcVer, v1MappingFile, false)
def makeV2Jar = makeJar(mcVer, v2MappingFile, true)
makeV2Jar.configure {
dependsOn conversionTask
}
project.logger.lifecycle("Publishing ${mcVer}")
build.dependsOn makeV1Jar
build.dependsOn makeV2Jar
publishing {
publications {
create("${mcVer.replace(" ", "")}_mavenJava", MavenPublication) {
groupId "net.legacyfabric.v$project.intermediaryVersion"
artifactId "intermediary"
version mcVer
artifact(makeV1Jar.get().archiveFile) {
builtBy makeV1Jar
}
artifact(makeV2Jar.get().archiveFile) {
builtBy makeV2Jar
classifier = "v2"
}
}
}
}
}
def makeJar(String mcVersion, File mappings, boolean v2) {
def jarFilename = "intermediary-" + mcVersion + (v2 ? "-v2" : "") + ".jar"
return tasks.register("${mcVersion}_makeJar" + (v2 ? "v2" : ""), Jar) {
archiveFileName = jarFilename
group = "jar"
from(file(mappings)) {
into "mappings"
rename mappings.name, "mappings.tiny"
}
destinationDirectory = file("build/jars")
manifest {
attributes(
"Intermediary-Version": project.intermediaryVersion,
)
}
}
}
publishing {
repositories {
if (ENV.MAVEN_PUBLISH_CREDENTIALS) {
maven {
url "https://repo.legacyfabric.net/repository/legacyfabric"
credentials {
username ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[0]
password ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[1]
}
authentication {
basic(BasicAuthentication)
}
}
}
}
}