-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
206 lines (183 loc) · 8.36 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
import net.fabricmc.loom.task.RemapJarTask
import groovy.json.JsonSlurper
import groovy.xml.XmlSlurper
plugins {
id 'fabric-loom' version '1.8-SNAPSHOT'
id "com.modrinth.minotaur" version "2.+"
id 'maven-publish'
}
def CHANGELOG = new File('CHANGELOG.md').exists() ? new File('CHANGELOG.md').text : ""
archivesBaseName = project.archives_base_name
version = "${project.library_version}+${project.mod_version}"
group = project.maven_group
repositories {}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
testImplementation(platform("org.junit:junit-bom:5.9.2"))
testImplementation("org.junit.jupiter:junit-jupiter")
include modApi("com.github.twitch4j:twitch4j:${project.library_version}") {
exclude group: "org.slf4j", module: "slf4j-api"
}
include "com.github.twitch4j:twitch4j-auth:${project.library_version}"
include "com.github.twitch4j:twitch4j-chat:${project.library_version}"
include "com.github.twitch4j:twitch4j-client-websocket:${project.library_version}"
include "com.github.twitch4j:twitch4j-common:${project.library_version}"
include "com.github.twitch4j:twitch4j-eventsub-common:${project.library_version}"
include "com.github.twitch4j:twitch4j-eventsub-websocket:${project.library_version}"
include "com.github.twitch4j:twitch4j-extensions:${project.library_version}"
include "com.github.twitch4j:twitch4j-graphql:${project.library_version}"
include "com.github.twitch4j:twitch4j-helix:${project.library_version}"
include "com.github.twitch4j:twitch4j-kraken:${project.library_version}"
include "com.github.twitch4j:twitch4j-messaginginterface:${project.library_version}"
include "com.github.twitch4j:twitch4j-pubsub:${project.library_version}"
include "com.github.twitch4j:twitch4j-util:${project.library_version}"
var apollo = "2.5.14"
var events4j = "0.12.2"
var jackson = "2.18.1"
var openfeign = "13.5"
var xanthic = "0.6.2"
include "com.apollographql.apollo:apollo-api-jvm:$apollo"
include "com.apollographql.apollo:apollo-http-cache-api:$apollo"
include "com.apollographql.apollo:apollo-normalized-cache-api-jvm:$apollo"
include "com.apollographql.apollo:apollo-normalized-cache-jvm:$apollo"
include "com.apollographql.apollo:apollo-runtime:$apollo"
include "com.benasher44:uuid-jvm:0.2.0"
include "com.bucket4j:bucket4j_jdk8-core:8.10.1"
include "com.fasterxml.jackson.core:jackson-annotations:$jackson"
include "com.fasterxml.jackson.core:jackson-core:$jackson"
include "com.fasterxml.jackson.core:jackson-databind:$jackson"
include "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson"
include "com.github.ben-manes.caffeine:caffeine:2.9.3"
include "com.github.philippheuer.credentialmanager:credentialmanager:0.3.1"
include "com.github.philippheuer.events4j:events4j-api:$events4j"
include "com.github.philippheuer.events4j:events4j-core:$events4j"
include "com.github.philippheuer.events4j:events4j-handler-simple:$events4j"
include "com.github.tony19:named-regexp:1.0.0"
include "com.google.errorprone:error_prone_annotations:2.10.0"
include "com.neovisionaries:nv-websocket-client:2.14"
include "com.netflix.archaius:archaius-core:0.4.1"
include "com.netflix.hystrix:hystrix-core:1.5.18"
include "com.nytimes.android:cache:2.0.2"
include "com.squareup.okhttp3:okhttp:4.12.0"
include "com.squareup.okio:okio-jvm:3.6.0"
include "commons-configuration:commons-configuration:1.10"
include "commons-lang:commons-lang:2.6"
include "io.github.openfeign:feign-core:$openfeign"
include "io.github.openfeign:feign-hystrix:$openfeign"
include "io.github.openfeign:feign-jackson:$openfeign"
include "io.github.openfeign:feign-okhttp:$openfeign"
include "io.github.openfeign:feign-slf4j:$openfeign"
include "io.github.xanthic.cache:cache-api:$xanthic"
include "io.github.xanthic.cache:cache-core:$xanthic"
include "io.github.xanthic.cache:cache-provider-caffeine:$xanthic"
include "io.reactivex:rxjava:1.2.0"
include "net.fabricmc:fabric-language-kotlin:1.10.19+kotlin.1.9.23"
include "org.hdrhistogram:HdrHistogram:2.1.9"
}
processResources {
inputs.property "version", project.version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
def targetJavaVersion = 8
tasks.withType(JavaCompile).configureEach {
// 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
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
}
}
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
archivesBaseName = project.archives_base_name
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = archivesBaseName
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
//mavenLocal()
maven {
url = System.getenv().MAVEN_REPO
credentials(HttpHeaderCredentials) {
name System.getenv().MAVEN_AUTH_HEADER
value System.getenv().MAVEN_AUTH_TOKEN
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
tasks.register('remapMavenJar', RemapJarTask) {
dependsOn jar
input = jar.archiveFile
archiveFileName = "${archivesBaseName}-${project.version}-maven.jar"
addNestedDependencies = false
}
build.dependsOn remapMavenJar
tasks.modrinth.dependsOn(tasks.remapMavenJar)
modrinth {
def json = new URL("https://meta.fabricmc.net/v2/versions/game").text
def versions = new JsonSlurper().parseText(json)
def minecraftVersions = new ArrayList<String>()
for (def version : versions) {
if (version.stable) {
minecraftVersions.add(version.version)
}
}
String projectVersion = project.version.toString()
List<String> projectVersionNumber = projectVersion.split("-", 2)
String projectVersionName = "Release ${projectVersionNumber[0]}"
if (projectVersionNumber.size() == 2) {
List<String> typeNumber = projectVersionNumber[1].split("\\.", 2)
if (projectVersionNumber[1].startsWith("rc")) {
projectVersionName = "${projectVersionNumber[0]} - Release Candidate ${typeNumber[1]}"
versionType = "beta" //Modrinth doesn't have RC so I use beta
} else if (projectVersionNumber[1].startsWith("beta")) {
projectVersionName = "${projectVersionNumber[0]} - Beta ${typeNumber[1]}"
versionType = "beta"
} else if (projectVersionNumber[1].startsWith("alpha")) {
projectVersionName = "${projectVersionNumber[0]} - Alpha ${typeNumber[1]}"
versionType = "alpha"
}
}
token = System.getenv("MODRINTH_TOKEN")
projectId = "CmHD69Pj"
versionName = projectVersionName
changelog = "### The Twitch4J changelog can be seen at https://github.com/twitch4j/twitch4j/releases/tag/v${project.library_version}\n\n" + CHANGELOG
gameVersions = minecraftVersions
loaders = ["fabric", "quilt"]
uploadFile = remapJar
}
tasks.register('checkVersion') {
doFirst {
def xml = new URL("https://maven.awakenedredstone.com/com/github/twitch4j/twitch4j-fabric/maven-metadata.xml").text
def metadata = new XmlSlurper().parseText(xml)
def versions = metadata.versioning.versions.version*.text()
if (versions.contains(version)) {
throw new RuntimeException("${version} has already been released!")
}
}
}
publish.dependsOn checkVersion