-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
155 lines (141 loc) · 4.35 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
plugins {
id "vaf.base-conventions"
id "io.papermc.hangar-publish-plugin" version "0.1.2"
id "com.modrinth.minotaur" version "2.+"
}
base {
archivesName = "ViaAprilFools"
}
configurations {
publishInclude
}
dependencies {
publishInclude project(":viaaprilfools-common")
publishInclude project(":viaaprilfools-bukkit")
publishInclude project(":viaaprilfools-fabric")
publishInclude project(":viaaprilfools-sponge")
publishInclude project(":viaaprilfools-velocity")
}
java {
withSourcesJar()
withJavadocJar()
}
jar {
dependsOn configurations.publishInclude
from {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations.publishInclude.collect {
zipTree(it)
}
} {
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
}
manifest {
attributes(
"paperweight-mappings-namespace": "mojang"
)
}
from("LICENSE") {
rename { "${it}_${project.name ?: rootProject.name}" }
}
}
idea {
module {
["run"].each {
excludeDirs << file("$it")
}
}
}
// -----------------------------------------------------
// Publishing
def latestCommitHash() {
def byteOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = byteOut
}
return byteOut.toString('UTF-8').trim()
}
def latestCommitMessage() {
def byteOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '-1', '--pretty=%B'
standardOutput = byteOut
}
return byteOut.toString('UTF-8').trim()
}
def branchName() {
def byteOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
standardOutput = byteOut
}
return byteOut.toString('UTF-8').trim()
}
def branch = branchName()
def baseVersion = project.maven_version
def isRelease = !baseVersion.contains('-')
if (!isRelease) { // Only publish releases from the main branch
def suffixedVersion = isRelease ? baseVersion : baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER")
def commitHash = latestCommitHash()
def changelogContent = "[${commitHash}](https://github.com/ViaVersion/ViaAprilFools/commit/${commitHash}) ${latestCommitMessage()}"
modrinth {
def mcVersions = project.mcVersions
.split(',')
.collect { it.trim() }
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("viaaprilfools")
versionType.set(isRelease ? "release" : "beta")
versionNumber.set(suffixedVersion)
versionName.set(suffixedVersion)
changelog.set(changelogContent)
uploadFile.set(jar.archiveFile)
gameVersions.set(mcVersions)
loaders.add("fabric")
loaders.add("paper")
loaders.add("folia")
loaders.add("velocity")
autoAddDependsOn.set(false)
detectLoaders.set(false)
dependencies {
required.project("viaversion")
required.project("viabackwards")
optional.project("viafabric")
}
}
hangarPublish {
publications.register("plugin") {
version = suffixedVersion
id = "ViaAprilFools"
channel = isRelease ? "Release" : "Snapshot"
changelog = changelogContent
apiKey = System.getenv("HANGAR_TOKEN")
platforms {
PAPER {
jar = project.jar.archiveFile
platformVersions = [property('mcVersionRange') as String]
dependencies {
hangar("ViaVersion") {
required = true
}
hangar("ViaBackwards") {
required = true
}
}
}
VELOCITY {
jar = project.jar.archiveFile
platformVersions = [property("velocityVersion") as String]
dependencies {
hangar("ViaVersion") {
required = true
}
hangar("ViaBackwards") {
required = true
}
}
}
}
}
}
}