Add mirai-core-all

This commit is contained in:
Him188 2020-09-22 18:56:27 +08:00
parent 72a478f712
commit 780598d6fa
10 changed files with 237 additions and 6 deletions

View File

@ -32,6 +32,8 @@ jobs:
run: ./gradlew :mirai-core:publish -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
- name: Gradle :mirai-core-qqandroid:publish
run: ./gradlew :mirai-core-qqandroid:publish -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
- name: Gradle :mirai-core-all:publish
run: ./gradlew :mirai-core-all:publish -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
# - name: Upload artifact
# uses: actions/upload-artifact@v1.0.0

View File

@ -17,7 +17,6 @@ buildscript {
}
dependencies {
classpath("com.github.jengelman.gradle.plugins:shadow:6.0.0")
classpath("com.android.tools.build:gradle:${Versions.Android.androidGradlePlugin}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Kotlin.compiler}")
classpath("org.jetbrains.kotlin:kotlin-serialization:${Versions.Kotlin.compiler}")
@ -29,7 +28,7 @@ buildscript {
plugins {
id("org.jetbrains.dokka") version Versions.Kotlin.dokka apply false
id("net.mamoe.kotlin-jvm-blocking-bridge") version Versions.blockingBridge apply false
// id("com.jfrog.bintray") version Versions.Publishing.bintray apply false
id("com.jfrog.bintray") version Versions.Publishing.bintray
}
// https://github.com/kotlin/binary-compatibility-validator
@ -77,6 +76,9 @@ subprojects {
}
afterEvaluate {
if (name == "mirai-core-all") {
return@afterEvaluate
}
apply(plugin = "com.github.johnrengelman.shadow")
val kotlin =

View File

@ -25,4 +25,6 @@ dependencies {
api(ktor("client-core", "1.3.2"))
api(ktor("client-cio", "1.3.2"))
api(ktor("client-json", "1.3.2"))
compileOnly("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
api("com.github.jengelman.gradle.plugins:shadow:6.0.0")
}

View File

@ -0,0 +1,164 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "NOTHING_TO_INLINE", "RemoveRedundantBackticks")
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import upload.Bintray
import java.io.File
import java.util.*
import kotlin.reflect.KProperty
/*
* 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 via the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
/**
* Configures the [bintray][com.jfrog.bintray.gradle.BintrayExtension] extension.
*/
@PublishedApi
internal fun org.gradle.api.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?,
property: KProperty<*>
) = ExistingDomainObjectDelegate.of(
delegateProvider.register(property.name, type.java, action)
)
@PublishedApi
internal val org.gradle.api.Project.`sourceSets`: org.gradle.api.tasks.SourceSetContainer
get() =
(this as org.gradle.api.plugins.ExtensionAware).extensions.getByName("sourceSets") as org.gradle.api.tasks.SourceSetContainer
@PublishedApi
internal operator fun <T> ExistingDomainObjectDelegate<out T>.getValue(receiver: Any?, property: KProperty<*>): T =
delegate
/**
* Configures the [publishing][org.gradle.api.publish.PublishingExtension] extension.
*/
@PublishedApi
internal fun org.gradle.api.Project.`publishing`(configure: org.gradle.api.publish.PublishingExtension.() -> Unit): Unit =
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("publishing", configure)
inline fun Project.setupPublishing(
artifactId: String,
bintrayRepo: String = "mirai",
bintrayPkgName: String = artifactId,
addPrefixAll: Boolean = true,
vcs: String = "https://github.com/mamoe/mirai"
) {
tasks.register("ensureBintrayAvailable") {
doLast {
if (!Bintray.isBintrayAvailable(project)) {
error("bintray isn't available. ")
}
}
}
apply<ShadowPlugin>()
// afterEvaluate {
val shadowJar = tasks.filterIsInstance<ShadowJar>().firstOrNull() ?: return//@afterEvaluate
tasks.register("shadowJarMd5") {
dependsOn(shadowJar)
val outFiles = shadowJar.outputs.files.associateWith { file ->
File(file.parentFile, file.name.removeSuffix(".jar").removeSuffix("-all") + "-all.jar.md5")
}
outFiles.forEach { (_, output) ->
output.createNewFile()
outputs.files(output)
}
doLast {
for ((origin, output) in outFiles) {
output
.writeText(origin.inputStream().md5().toUHexString().trim(Char::isWhitespace))
}
}
tasks.getByName("publish").dependsOn(this)
tasks.getByName("bintrayUpload").dependsOn(this)
}
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)
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"])
afterEvaluate {
for (file in tasks.getByName("shadowJarMd5").outputs.files) {
artifact(provider { file })
}
}
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")
//}
}

View File

@ -9,7 +9,7 @@
object Versions {
object Mirai {
const val version = "1.3.2-dev-5"
const val version = "1.3.1"
}
object Kotlin {

View File

@ -0,0 +1,60 @@
@file:Suppress("UnusedImport")
plugins {
kotlin("jvm")
kotlin("plugin.serialization")
id("java")
`maven-publish`
id("com.jfrog.bintray")
id("net.mamoe.kotlin-jvm-blocking-bridge")
}
version = Versions.Mirai.version
description = "Mirai core shadowed"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile::class.java) {
options.encoding = "UTF8"
}
kotlin {
explicitApiWarning()
sourceSets.all {
target.compilations.all {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
//useIR = true
}
}
languageSettings.apply {
enableLanguageFeature("InlineClasses")
progressiveMode = true
useExperimentalAnnotation("kotlin.Experimental")
useExperimentalAnnotation("kotlin.RequiresOptIn")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
useExperimentalAnnotation("net.mamoe.mirai.console.ConsoleFrontEndImplementation")
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleExperimentalApi")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleInternalApi")
}
}
}
dependencies {
api(project(":mirai-core"))
api(project(":mirai-core-qqandroid"))
}
setupPublishing("mirai-core-all")

View File

@ -6,7 +6,7 @@ plugins {
kotlin("plugin.serialization")
id("net.mamoe.kotlin-jvm-blocking-bridge")
`maven-publish`
id("com.jfrog.bintray") version Versions.Publishing.bintray
id("com.jfrog.bintray")
}
description = "Mirai Protocol implementation for QQ Android"

View File

@ -7,7 +7,7 @@ plugins {
id("signing")
id("net.mamoe.kotlin-jvm-blocking-bridge")
`maven-publish`
id("com.jfrog.bintray") version Versions.Publishing.bintray
id("com.jfrog.bintray")
}
description = "Mirai API module"

View File

@ -6,7 +6,7 @@ plugins {
kotlin("plugin.serialization")
id("signing")
`maven-publish`
id("com.jfrog.bintray") version Versions.Publishing.bintray
id("com.jfrog.bintray")
}
description = "Mirai serialization module"

View File

@ -26,6 +26,7 @@ rootProject.name = 'mirai'
include(':mirai-core')
include(':mirai-core-qqandroid')
include(':mirai-serialization')
include(':mirai-core-all')
include(':java-test')
//include(':compatibility-validator') // THIS WILL CAUSE A DEPENDENCY RESOLUTION BUG