mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 22:30:47 +08:00
Remove bintray
This commit is contained in:
parent
7cb2000035
commit
829078f97e
@ -18,7 +18,6 @@ Mirai 是一个在全平台下运行,提供 QQ 协议支持的高效率机器
|
||||
高效率 QQ 机器人框架,机器人核心来自 [mirai](https://github.com/mamoe/mirai)
|
||||
|
||||
![Gradle CI](https://github.com/mamoe/mirai-console/workflows/Gradle%20CI/badge.svg?branch=master)
|
||||
[![Download](https://api.bintray.com/packages/him188moe/mirai/mirai-console/images/download.svg)](https://bintray.com/him188moe/mirai/mirai-console/)
|
||||
[![Gitter](https://badges.gitter.im/mamoe/mirai.svg)](https://gitter.im/mamoe/mirai?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
|
||||
## 使用
|
||||
|
@ -17,7 +17,6 @@ plugins {
|
||||
kotlin("plugin.serialization")
|
||||
id("java")
|
||||
`maven-publish`
|
||||
id("com.jfrog.bintray")
|
||||
id("net.mamoe.kotlin-jvm-blocking-bridge")
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
plugins {
|
||||
kotlin("jvm") version Versions.kotlinCompiler
|
||||
kotlin("plugin.serialization") version Versions.kotlinCompiler
|
||||
id("com.jfrog.bintray") version Versions.bintray apply false
|
||||
id("net.mamoe.kotlin-jvm-blocking-bridge") version Versions.blockingBridge apply false
|
||||
id("com.gradle.plugin-publish") version "0.12.0" apply false
|
||||
//id("com.bmuschko.nexus") version "2.3.1" apply false
|
||||
@ -32,7 +31,6 @@ allprojects {
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
@ -5,7 +14,6 @@ plugins {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
@ -31,6 +39,5 @@ dependencies {
|
||||
|
||||
compileOnly(gradleApi())
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0")
|
||||
compileOnly("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
|
||||
api("com.github.jengelman.gradle.plugins:shadow:6.0.0")
|
||||
}
|
@ -28,13 +28,6 @@ import kotlin.reflect.KProperty
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configures the [bintray][com.jfrog.bintray.gradle.BintrayExtension] extension.
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun Project.`bintray`(configure: com.jfrog.bintray.gradle.BintrayExtension.() -> Unit): Unit =
|
||||
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("bintray", configure)
|
||||
|
||||
@PublishedApi
|
||||
internal operator fun <U : Task> RegisteringDomainObjectDelegateProviderWithTypeAndAction<out TaskContainer, U>.provideDelegate(
|
||||
receiver: Any?,
|
||||
@ -62,78 +55,7 @@ internal fun Project.`publishing`(configure: org.gradle.api.publish.PublishingEx
|
||||
|
||||
inline fun Project.configurePublishing(
|
||||
artifactId: String,
|
||||
bintrayRepo: String = "mirai",
|
||||
bintrayPkgName: String = artifactId,
|
||||
vcs: String = "https://github.com/mamoe/mirai-console"
|
||||
) {
|
||||
|
||||
tasks.register("ensureBintrayAvailable") {
|
||||
doLast {
|
||||
if (!Bintray.isBintrayAvailable(project)) {
|
||||
error("bintray isn't available. ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Bintray.isBintrayAvailable(project)) {
|
||||
bintray {
|
||||
val keyProps = Properties()
|
||||
val keyFile = file("../keys.properties")
|
||||
if (keyFile.exists()) keyFile.inputStream().use { keyProps.load(it) }
|
||||
if (keyFile.exists()) keyFile.inputStream().use { keyProps.load(it) }
|
||||
|
||||
user = Bintray.getUser(project)
|
||||
key = Bintray.getKey(project)
|
||||
|
||||
publish = true
|
||||
override = true
|
||||
|
||||
setPublications("mavenJava")
|
||||
setConfigurations("archives")
|
||||
|
||||
pkg.apply {
|
||||
repo = bintrayRepo
|
||||
name = bintrayPkgName
|
||||
setLicenses("AGPLv3")
|
||||
publicDownloadNumbers = true
|
||||
vcsUrl = vcs
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val sourcesJar by tasks.registering(Jar::class) {
|
||||
classifier = "sources"
|
||||
from(sourceSets["main"].allSource)
|
||||
}
|
||||
|
||||
publishing {
|
||||
/*
|
||||
repositories {
|
||||
maven {
|
||||
// change to point to your repo, e.g. http://my.org/repo
|
||||
url = uri("$buildDir/repo")
|
||||
}
|
||||
}*/
|
||||
publications {
|
||||
register("mavenJava", MavenPublication::class) {
|
||||
from(components["java"])
|
||||
|
||||
groupId = rootProject.group.toString()
|
||||
this.artifactId = artifactId
|
||||
version = version
|
||||
|
||||
pom.withXml {
|
||||
val root = asNode()
|
||||
root.appendNode("description", description)
|
||||
root.appendNode("name", project.name)
|
||||
root.appendNode("url", vcs)
|
||||
root.children().last()
|
||||
}
|
||||
|
||||
artifact(sourcesJar.get())
|
||||
}
|
||||
}
|
||||
}
|
||||
} else println("bintray isn't available. NO PUBLICATIONS WILL BE SET")
|
||||
|
||||
// stub
|
||||
}
|
@ -31,8 +31,6 @@ object Versions {
|
||||
|
||||
const val androidGradle = "3.6.2"
|
||||
|
||||
const val bintray = "1.8.5"
|
||||
|
||||
const val blockingBridge = "1.6.0"
|
||||
|
||||
const val junit = "5.4.2"
|
||||
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("DuplicatedCode")
|
||||
|
||||
package upload
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
import java.io.File
|
||||
|
||||
object Bintray {
|
||||
|
||||
@JvmStatic
|
||||
fun isBintrayAvailable(project: Project): Boolean {
|
||||
return kotlin.runCatching {
|
||||
getUser(project)
|
||||
getKey(project)
|
||||
}.isSuccess
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getUser(project: Project): String {
|
||||
kotlin.runCatching {
|
||||
@Suppress("UNUSED_VARIABLE", "LocalVariableName")
|
||||
val bintray_user: String by project
|
||||
return bintray_user
|
||||
}
|
||||
|
||||
kotlin.runCatching {
|
||||
@Suppress("UNUSED_VARIABLE", "LocalVariableName")
|
||||
val bintray_user: String by project.rootProject
|
||||
return bintray_user
|
||||
}
|
||||
|
||||
System.getProperty("bintray_user", null)?.let {
|
||||
return it.trim()
|
||||
}
|
||||
|
||||
File(File(System.getProperty("user.dir")).parent, "/bintray.user.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
File(File(System.getProperty("user.dir")), "/bintray.user.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
project.file("bintray.user.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
project.rootProject.file("bintray.user.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
error(
|
||||
"Cannot find bintray user, " +
|
||||
"please specify by creating a file bintray.user.txt in project dir, " +
|
||||
"or by providing JVM parameter 'bintray_user'"
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getKey(project: Project): String {
|
||||
kotlin.runCatching {
|
||||
@Suppress("UNUSED_VARIABLE", "LocalVariableName")
|
||||
val bintray_key: String by project
|
||||
return bintray_key
|
||||
}
|
||||
|
||||
kotlin.runCatching {
|
||||
@Suppress("UNUSED_VARIABLE", "LocalVariableName")
|
||||
val bintray_key: String by project.rootProject
|
||||
return bintray_key
|
||||
}
|
||||
|
||||
System.getProperty("bintray_key", null)?.let {
|
||||
return it.trim()
|
||||
}
|
||||
|
||||
File(File(System.getProperty("user.dir")).parent, "/bintray.key.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
File(File(System.getProperty("user.dir")), "/bintray.key.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
project.file("bintray.key.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
project.rootProject.file("bintray.key.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
error(
|
||||
"Cannot find bintray key, " +
|
||||
"please specify by creating a file bintray.key.txt in project dir, " +
|
||||
"or by providing JVM parameter 'bintray_key'"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package upload
|
||||
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.request.forms.*
|
||||
import io.ktor.client.statement.*
|
||||
import io.ktor.http.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
object CuiCloud {
|
||||
private fun getUrl(project: Project): String {
|
||||
kotlin.runCatching {
|
||||
@Suppress("UNUSED_VARIABLE", "LocalVariableName")
|
||||
val cui_cloud_url: String by project
|
||||
return cui_cloud_url
|
||||
}
|
||||
|
||||
System.getProperty("cui_cloud_url", null)?.let {
|
||||
return it.trim()
|
||||
}
|
||||
File(File(System.getProperty("user.dir")).parent, "/cuiUrl.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
File(File(System.getProperty("user.dir")), "/cuiUrl.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
error("cannot find url for CuiCloud")
|
||||
}
|
||||
|
||||
private fun getKey(project: Project): String {
|
||||
kotlin.runCatching {
|
||||
@Suppress("UNUSED_VARIABLE", "LocalVariableName")
|
||||
val cui_cloud_key: String by project
|
||||
return cui_cloud_key
|
||||
}
|
||||
|
||||
System.getProperty("cui_cloud_key", null)?.let {
|
||||
return it.trim()
|
||||
}
|
||||
File(File(System.getProperty("user.dir")).parent, "/cuiToken.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
File(File(System.getProperty("user.dir")), "/cuiToken.txt").let { local ->
|
||||
if (local.exists()) {
|
||||
return local.readText().trim()
|
||||
}
|
||||
}
|
||||
|
||||
error("cannot find key for CuiCloud")
|
||||
}
|
||||
|
||||
fun upload(file: File, project: Project) {
|
||||
val cuiCloudUrl = getUrl(project)
|
||||
val key = getKey(project)
|
||||
|
||||
|
||||
val bytes = file.readBytes()
|
||||
|
||||
runBlocking {
|
||||
var first = true
|
||||
retryCatching(1000) {
|
||||
if (!first) {
|
||||
println()
|
||||
println()
|
||||
println("Upload failed. Waiting 15s")
|
||||
delay(15_000)
|
||||
}
|
||||
first = false
|
||||
uploadToCuiCloud(
|
||||
cuiCloudUrl,
|
||||
key,
|
||||
"/mirai/${project.name}/${file.nameWithoutExtension}.mp4",
|
||||
bytes
|
||||
)
|
||||
}.getOrThrow()
|
||||
}
|
||||
}
|
||||
|
||||
@UseExperimental(ExperimentalStdlibApi::class)
|
||||
private suspend fun uploadToCuiCloud(
|
||||
cuiCloudUrl: String,
|
||||
cuiToken: String,
|
||||
filePath: String,
|
||||
content: ByteArray
|
||||
) {
|
||||
println("filePath=$filePath")
|
||||
println("content=${content.size / 1024 / 1024} MB")
|
||||
|
||||
val response = withContext(Dispatchers.IO) {
|
||||
Http.post<HttpResponse>(cuiCloudUrl) {
|
||||
body = MultiPartFormDataContent(
|
||||
formData {
|
||||
append("base64", Base64.getEncoder().encodeToString(content))
|
||||
append("filePath", filePath)
|
||||
append("large", "true")
|
||||
append("key", cuiToken)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
println(response.status)
|
||||
|
||||
val buffer = ByteArray(4096)
|
||||
val resp = buildList<Byte> {
|
||||
while (true) {
|
||||
val read = response.content.readAvailable(buffer, 0, buffer.size)
|
||||
if (read == -1) {
|
||||
break
|
||||
}
|
||||
addAll(buffer.toList().take(read))
|
||||
}
|
||||
}
|
||||
println(String(resp.toByteArray()))
|
||||
|
||||
if (!response.status.isSuccess()) {
|
||||
error("Cui cloud response: ${response.status}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RESULT_CLASS_IN_RETURN_TYPE")
|
||||
@kotlin.internal.InlineOnly
|
||||
internal inline fun <R> retryCatching(n: Int, onFailure: (Throwable) -> Unit = {}, block: () -> R): Result<R> {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
|
||||
}
|
||||
require(n >= 0) { "param n for retryCatching must not be negative" }
|
||||
var exception: Throwable? = null
|
||||
repeat(n) {
|
||||
try {
|
||||
return Result.success(block())
|
||||
} catch (e: Throwable) {
|
||||
try {
|
||||
exception?.addSuppressed(e)
|
||||
} catch (e: Throwable) {
|
||||
}
|
||||
exception = e
|
||||
onFailure(e)
|
||||
}
|
||||
}
|
||||
return Result.failure(exception!!)
|
||||
}
|
||||
inline fun <E> buildList(builderAction: MutableList<E>.() -> Unit): List<E> {
|
||||
return ArrayList<E>().apply(builderAction)
|
||||
}
|
@ -75,8 +75,6 @@ PluginManager.INSTANCE.enablePlugin(Plugin.INSTANCE)
|
||||
|
||||
#### 从 JCenter 下载模块
|
||||
|
||||
mirai 在版本发布时会将发布的构建存放于 [mirai-bintray-repo]。
|
||||
|
||||
- mirai-core 会提供 [mirai-core-all]
|
||||
- mirai-console 与其各个模块都会提供 `-all` 的 Shadowed 构建
|
||||
|
||||
@ -134,5 +132,4 @@ java -cp "./libs/*" net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader
|
||||
使用 `./start-mirai-console --help` 查看 mirai-console-terminal 支持的启动参数。
|
||||
|
||||
[mirai-repo]: https://github.com/project-mirai/mirai-repo/tree/master/shadow
|
||||
[mirai-bintray-repo]: https://bintray.com/him188moe/mirai
|
||||
[mirai-core-all]: https://bintray.com/him188moe/mirai/mirai-core-all
|
||||
[mirai-core-all]: https://repo.maven.apache.org/maven2/net/mamoe/mirai-core-all/
|
||||
|
@ -1,9 +1,17 @@
|
||||
/*
|
||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("kotlinx-serialization")
|
||||
id("org.openjfx.javafxplugin") version "0.0.8"
|
||||
id("kotlin")
|
||||
id("java")
|
||||
id("com.jfrog.bintray")
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ plugins {
|
||||
kotlin("plugin.serialization")
|
||||
id("java")
|
||||
`maven-publish`
|
||||
id("com.jfrog.bintray")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -31,6 +30,6 @@ version = Versions.consoleTerminal
|
||||
|
||||
description = "Console Terminal CLI frontend for mirai"
|
||||
|
||||
configurePublishing("mirai-console-terminal", bintrayPkgName = "mirai-console-terminal")
|
||||
configurePublishing("mirai-console-terminal")
|
||||
|
||||
// endregion
|
@ -13,7 +13,6 @@ pluginManagement {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
jcenter()
|
||||
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ plugins {
|
||||
kotlin("jvm")
|
||||
id("java")
|
||||
`maven-publish`
|
||||
id("com.jfrog.bintray")
|
||||
}
|
||||
|
||||
version = Versions.console
|
||||
|
@ -13,7 +13,6 @@ plugins {
|
||||
kotlin("jvm")
|
||||
id("java")
|
||||
`maven-publish`
|
||||
id("com.jfrog.bintray")
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -17,7 +17,6 @@ plugins {
|
||||
id("java")
|
||||
//signing
|
||||
`maven-publish`
|
||||
id("com.jfrog.bintray")
|
||||
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
@ -40,7 +39,7 @@ dependencies {
|
||||
|
||||
api("com.github.jengelman.gradle.plugins:shadow:6.0.0")
|
||||
api(`jetbrains-annotations`)
|
||||
api("com.jfrog.bintray.gradle:gradle-bintray-plugin:${Versions.bintray}")
|
||||
api("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
|
||||
|
||||
|
||||
testApi(kotlin("test-junit5"))
|
||||
|
@ -10,6 +10,6 @@
|
||||
package net.mamoe.mirai.console.gradle
|
||||
|
||||
internal object VersionConstants {
|
||||
const val CONSOLE_VERSION = "2.6.2" // value is written here automatically during build
|
||||
const val CORE_VERSION = "2.6.2" // value is written here automatically during build
|
||||
const val CONSOLE_VERSION = "2.6.4" // value is written here automatically during build
|
||||
const val CORE_VERSION = "2.6.4" // value is written here automatically during build
|
||||
}
|
@ -13,7 +13,6 @@ plugins {
|
||||
kotlin("jvm")
|
||||
id("java")
|
||||
`maven-publish`
|
||||
id("com.jfrog.bintray")
|
||||
|
||||
id("org.jetbrains.intellij") version Versions.intellijGradlePlugin
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user