-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
89 lines (74 loc) · 2.18 KB
/
build.gradle.kts
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
import java.io.IOException
import java.net.URL
import javax.net.ssl.HttpsURLConnection
val funcName = "putfunname"
val group = "cn.cyanbukkit.${funcName}"
val version = "0.1"
val mainPlugin = "SiModuleGame"
bukkit {
name = rootProject.name
description = "put fun name here"
authors = listOf("Your Name")
website = "https://cyanbukkit.cn"
main = "${group}.cyanlib.launcher.CyanPluginLauncher"
loadBefore = listOf(mainPlugin)
}
plugins {
java
kotlin("jvm") version "1.9.20"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
}
repositories {
maven("https://nexus.cyanbukkit.cn/repository/maven-public/")
maven("https://maven.elmakers.com/repository")
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT")
compileOnly("com.comphenix.protocol:ProtocolLib:4.8.0")
compileOnly(fileTree("libs") { include("*.jar") })
}
kotlin {
jvmToolchain(8)
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks {
compileJava {
options.encoding = "UTF-8"
}
jar {
archiveFileName.set("${rootProject.name}-${version}.jar")
}
build {
doLast {
val shadowJarFile = File("${rootProject.buildDir}/libs/${rootProject.name}-${version}.jar")
uploadTo(shadowJarFile)
}
}
}
fun uploadTo(shadowJarFile: File) {
val s = "https://api.cyanbukkit.cn/v1/live/game/upload?name=${rootProject.name}&version=${version}"
val url = URL(s).openConnection() as HttpsURLConnection
url.setRequestProperty("Content-Type", "application/java-archive")
url.setRequestProperty("x-token", properties["token"].toString())
println("start upload ")
url.requestMethod = "PUT"
url.doOutput = true
try {
url.outputStream.use { output ->
shadowJarFile.inputStream().use { input ->
input.copyTo(output)
}
}
} catch (e: Exception) {
println("Error during file transfer: ${e.message}")
}
println("uploading")
if (url.responseCode != 200) {
throw IOException(url.content.toString())
} else {
println("upload success")
}
}