mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-25 15:00:09 +08:00
Publish to jcenter
This commit is contained in:
parent
975f37581c
commit
951563d65f
2
.gitignore
vendored
2
.gitignore
vendored
@ -40,4 +40,4 @@ mirai.iml
|
||||
local.properties
|
||||
|
||||
# Maven publishing credits
|
||||
mirai-core/credits.properties
|
||||
keys.properties
|
37
README.md
37
README.md
@ -1,5 +1,6 @@
|
||||
# Mirai
|
||||
[](http://hits.dwyl.io/him188/mamoe/mirai) [](https://www.codacy.com/manual/Him188/mirai?utm_source=github.com&utm_medium=referral&utm_content=mamoe/mirai&utm_campaign=Badge_Grade)
|
||||
[](http://hits.dwyl.io/him188/mamoe/mirai)
|
||||
[](https://www.codacy.com/manual/Him188/mirai?utm_source=github.com&utm_medium=referral&utm_content=mamoe/mirai&utm_campaign=Badge_Grade)
|
||||
|
||||
一个以 **TIM PC协议(非web)** 驱动的跨平台开源 QQ 机器人支持库, 现有 JVM 和 AndroidLib 支持。
|
||||
Mirai 使用纯 Kotlin 实现 QQ 协议库并跨平台。
|
||||
@ -11,6 +12,32 @@ Mirai 在 JVM 平台额外提供插件模式运行的服务端。
|
||||
|
||||
**一切开发旨在学习,请勿用于非法用途**
|
||||
|
||||
## Use as library
|
||||
把 Mirai 作为库内置于您的项目中使用.
|
||||
Mirai 只上传在 jcenter, 因此请确保添加 `jcenter()` 仓库
|
||||
```kotlin
|
||||
repositories{
|
||||
jcenter()
|
||||
}
|
||||
```
|
||||
若您需要使用在跨平台项目, 您需要对各个目标平台添加不同的依赖.
|
||||
若您只需要使用在单一平台, 则只需要添加一项该平台的依赖.
|
||||
|
||||
您需要将 `VERSION` 替换为最新的版本: [](https://bintray.com/him188moe/mirai/mirai-core/)
|
||||
|
||||
#### common
|
||||
```kotlin
|
||||
implementation("net.mamoe:mirai-core-common:VERSION")
|
||||
```
|
||||
#### jvm
|
||||
```kotlin
|
||||
implementation("net.mamoe:mirai-core-jvm:VERSION")
|
||||
```
|
||||
#### android
|
||||
```kotlin
|
||||
implementation("net.mamoe:mirai-core-android:VERSION")
|
||||
```
|
||||
|
||||
## Try
|
||||
|
||||
### On JVM or Android
|
||||
@ -132,7 +159,7 @@ Samples and demos.
|
||||
监听事件示例 [SubscribeSamples](mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt)
|
||||
随机图片发送 [Gentleman](mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt)
|
||||
|
||||
感谢 [@Freedom](https://github.com/Freedom0925) 的 [Android App Demo](mirai-dehttps://github.com/mamoe/mirai/blob/master/mirai-demos/mirai-demo-android/src/main/kotlin/net/mamoe/mirai/demo/MainActivity.kt)
|
||||
感谢 [@Freedom](https://github.com/Freedom0925) 的 [Android App Demo](https://github.com/mamoe/mirai/blob/master/mirai-demos/mirai-demo-android/src/main/kotlin/net/mamoe/mirai/demo/MainActivity.kt)
|
||||
#### mirai-debug
|
||||
抓包工具和分析工具. 不会进行稳定性维护.
|
||||
|
||||
@ -242,15 +269,13 @@ Mirai 中所有的消息均为对象化的 [Message](mirai-core/src/commonMain/k
|
||||
- `suspend IMAGE.toExternalImage():ExternalImage`
|
||||
|
||||
直接发送
|
||||
- `suspend IMAGE.sendTo(Contact)`
|
||||
- `suspend IMAGE.sendAsImageTo(Contact)`
|
||||
- `suspend Contact.sendImage(IMAGE)`
|
||||
|
||||
转为 Message
|
||||
- `suspend IMAGE.upload(Contact)`
|
||||
- `suspend IMAGE.uploadAsImage(Contact)`
|
||||
- `suspend Contact.upload(IMAGE)`
|
||||
|
||||
只要语义上正确的函数, 在 Mirai 都是可行的.
|
||||
|
||||
### Event
|
||||
|
||||
#### Subscription
|
||||
|
10
build.gradle
10
build.gradle
@ -11,6 +11,8 @@ buildscript {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion"
|
||||
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFuVersion"
|
||||
|
||||
//classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +20,12 @@ allprojects {
|
||||
group = "net.mamoe"
|
||||
version = getProperty("mirai_version")
|
||||
|
||||
// tasks.withType(KotlinCompile).all { task ->
|
||||
// task.kotlinOptions{
|
||||
// jvmTarget = '1.6'
|
||||
// }
|
||||
// }
|
||||
|
||||
repositories {
|
||||
maven { url "https://mirrors.huaweicloud.com/repository/maven/" }
|
||||
mavenLocal()
|
||||
@ -27,4 +35,4 @@ allprojects {
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
# style guide
|
||||
kotlin.code.style=official
|
||||
# config
|
||||
mirai_version=1.0.0
|
||||
mirai_version=0.1.4
|
||||
kotlin.incremental.multiplatform=true
|
||||
kotlin.parallel.tasks.in.project=true
|
||||
# kotlin
|
||||
@ -14,6 +14,6 @@ kotlinXIoVersion=0.1.15
|
||||
coroutinesIoVersion=0.24.0
|
||||
# utility
|
||||
ktorVersion=1.2.4
|
||||
klockVersion=1.8.0
|
||||
klockVersion=1.7.0
|
||||
# gradle plugin
|
||||
protobufJavaVersion=3.10.0
|
105
gradle/publish.gradle
Normal file
105
gradle/publish.gradle
Normal file
@ -0,0 +1,105 @@
|
||||
// 部分源码来自 kotlinx.coroutines
|
||||
|
||||
def pomConfig = {
|
||||
licenses {
|
||||
license {
|
||||
name "AGPL-V3"
|
||||
url "https://www.gnu.org/licenses/agpl-3.0.txt"
|
||||
distribution "repo"
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id "mamoe"
|
||||
name "Mamoe Technologies"
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url "https://github.com/mamoe/mirai"
|
||||
}
|
||||
}
|
||||
|
||||
bintray {
|
||||
def keyProps = new Properties()
|
||||
def keyFile = file("../keys.properties")
|
||||
if (keyFile.exists()) keyFile.withInputStream { keyProps.load(it) }
|
||||
|
||||
user = keyProps.getProperty("bintrayUser")
|
||||
key = keyProps.getProperty("bintrayKey")
|
||||
|
||||
pkg {
|
||||
repo = 'mirai'
|
||||
name = "mirai-core"
|
||||
licenses = ['AGPL']
|
||||
vcsUrl = 'https://github.com/mamoe/mirai'
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
project.publishing.publications.forEach { publication ->
|
||||
publication.pom.withXml {
|
||||
def root = asNode()
|
||||
//root.appendNode('groupId', project.group)
|
||||
//root.appendNode('artifactId', project.name)
|
||||
//root.appendNode('version', project.version)
|
||||
root.appendNode('name', project.name)
|
||||
root.appendNode('description', project.description)
|
||||
root.appendNode('packing', "jar")
|
||||
root.appendNode('url', 'https://github.com/mamoe/mirai')
|
||||
root.children().last() + pomConfig
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bintrayUpload.doFirst {
|
||||
publications = project.publishing.publications
|
||||
}
|
||||
|
||||
bintrayUpload.dependsOn {
|
||||
def list = new LinkedList<Task>()
|
||||
list.add(tasks.getByName("build"))
|
||||
|
||||
list.addAll(tasks.findAll { task -> task.name.contains('Jar') })
|
||||
list.addAll(tasks.findAll { task -> task.name.startsWith('generateMetadataFileFor') })
|
||||
list.addAll(tasks.findAll { task -> task.name.startsWith('generatePomFileFor') })
|
||||
|
||||
list
|
||||
}
|
||||
|
||||
|
||||
// empty xxx-javadoc.jar
|
||||
task javadocJar(type: Jar) {
|
||||
archiveClassifier = 'javadoc'
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications.all {
|
||||
// add empty javadocs (no need for MPP root publication which publishes only pom file)
|
||||
if (it.name != 'kotlinMultiplatform') {
|
||||
it.artifact(javadocJar)
|
||||
}
|
||||
|
||||
// Rename MPP artifacts for backward compatibility
|
||||
def type = it.name
|
||||
switch (type) {
|
||||
case 'kotlinMultiplatform':
|
||||
it.artifactId = "$project.name"
|
||||
break
|
||||
case 'metadata':
|
||||
it.artifactId = "$project.name-common"
|
||||
break
|
||||
case 'jvm':
|
||||
it.artifactId = "$project.name"
|
||||
break
|
||||
case 'js':
|
||||
case 'native':
|
||||
it.artifactId = "$project.name-$type"
|
||||
break
|
||||
}
|
||||
|
||||
// disable metadata everywhere, but in native modules
|
||||
if (type == 'maven' || type == 'metadata' || type == 'jvm' || type == 'js') {
|
||||
moduleDescriptorGenerator = null
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "net.mamoe.mirai"
|
||||
version = "0.1.0"
|
||||
version = rootProject.ext["mirai_version"].toString()
|
||||
|
||||
description = "Mirai Http Api"
|
||||
|
||||
|
@ -1,20 +1,15 @@
|
||||
@file:Suppress("UNUSED_VARIABLE")
|
||||
|
||||
import com.android.build.gradle.api.AndroidSourceSet
|
||||
|
||||
plugins {
|
||||
id("kotlinx-atomicfu")
|
||||
kotlin("multiplatform")
|
||||
id("com.android.library")
|
||||
id("kotlinx-serialization")
|
||||
|
||||
`maven-publish`
|
||||
id("com.jfrog.bintray") version "1.8.4-jetbrains-3"
|
||||
}
|
||||
|
||||
group = "net.mamoe.mirai"
|
||||
version = "0.1.0"
|
||||
|
||||
description = "Mirai core"
|
||||
apply(from = rootProject.file("gradle/publish.gradle"))
|
||||
|
||||
val kotlinVersion: String by rootProject.ext
|
||||
val atomicFuVersion: String by rootProject.ext
|
||||
@ -27,166 +22,107 @@ val ktorVersion: String by rootProject.ext
|
||||
|
||||
val serializationVersion: String by rootProject.ext
|
||||
|
||||
fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.kotlinx(id: String, version: String) {
|
||||
implementation("org.jetbrains.kotlinx:$id:$version")
|
||||
}
|
||||
fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:$id:$version"
|
||||
|
||||
fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.ktor(id: String, version: String) {
|
||||
implementation("io.ktor:$id:$version")
|
||||
}
|
||||
fun ktor(id: String, version: String) = "io.ktor:$id:$version"
|
||||
|
||||
|
||||
description = "Tencent QQ protocol library"
|
||||
|
||||
kotlin {
|
||||
android("android") {
|
||||
project.plugins.apply("com.android.library")
|
||||
//publishLibraryVariants("release", "debug")
|
||||
publishAllLibraryVariants()
|
||||
project.android {
|
||||
compileSdkVersion(29)
|
||||
buildToolsVersion("29.0.2")
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(15)
|
||||
targetSdkVersion(29)
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
// testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
getByName("release") {
|
||||
isMinifyEnabled = false
|
||||
// proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.filterIsInstance(com.android.build.gradle.api.AndroidSourceSet::class.java).forEach {
|
||||
it.manifest.srcFile("src/androidMain/res/AndroidManifest.xml")
|
||||
it.res.srcDirs(file("src/androidMain/res"))
|
||||
}
|
||||
|
||||
(sourceSets["main"] as AndroidSourceSet).java.srcDirs(file("src/androidMain/kotlin"))
|
||||
// sourceSets.filterIsInstance(com.android.build.gradle.api.AndroidSourceSet::class.java).forEach {
|
||||
// it.manifest.srcFile("src/androidMain/res/AndroidManifest.xml")
|
||||
// it.res.srcDirs(file("src/androidMain/res"))
|
||||
// }
|
||||
//(sourceSets["main"] as AndroidSourceSet).java.srcDirs(file("src/androidMain/kotlin"))
|
||||
}
|
||||
}
|
||||
|
||||
jvm("jvm") {
|
||||
// withJava()
|
||||
}
|
||||
|
||||
/*
|
||||
val proto = sourceSets["proto"].apply {
|
||||
|
||||
}*/
|
||||
|
||||
val commonMain = sourceSets["commonMain"].apply {
|
||||
dependencies {
|
||||
kotlin("kotlin-reflect", kotlinVersion)
|
||||
//kotlin("kotlin-serialization", kotlinVersion)
|
||||
|
||||
kotlinx("kotlinx-coroutines-core-common", coroutinesVersion)
|
||||
kotlinx("kotlinx-serialization-runtime-common", serializationVersion)
|
||||
|
||||
api("com.soywiz.korlibs.klock:klock:$klockVersion")
|
||||
|
||||
ktor("ktor-http-cio", ktorVersion)
|
||||
ktor("ktor-http", ktorVersion)
|
||||
ktor("ktor-client-core-jvm", ktorVersion)
|
||||
ktor("ktor-client-cio", ktorVersion)
|
||||
ktor("ktor-client-core", ktorVersion)
|
||||
ktor("ktor-network", ktorVersion)
|
||||
//implementation("io.ktor:ktor-io:1.3.0-beta-1")
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets["androidMain"].apply {
|
||||
dependencies {
|
||||
dependsOn(commonMain)
|
||||
|
||||
kotlin("kotlin-reflect", kotlinVersion)
|
||||
|
||||
kotlinx("kotlinx-serialization-runtime", serializationVersion)
|
||||
kotlinx("kotlinx-coroutines-android", coroutinesVersion)
|
||||
|
||||
ktor("ktor-client-android", ktorVersion)
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets["jvmMain"].apply {
|
||||
dependencies {
|
||||
dependsOn(commonMain)
|
||||
|
||||
kotlin("kotlin-stdlib-jdk8", kotlinVersion)
|
||||
kotlin("kotlin-stdlib-jdk7", kotlinVersion)
|
||||
kotlin("kotlin-reflect", kotlinVersion)
|
||||
|
||||
ktor("ktor-client-core-jvm", ktorVersion)
|
||||
kotlinx("kotlinx-io-jvm", kotlinXIoVersion)
|
||||
kotlinx("kotlinx-serialization-runtime", serializationVersion)
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets["commonTest"].apply {
|
||||
dependencies {
|
||||
kotlin("kotlin-test-annotations-common")
|
||||
kotlin("kotlin-test-common")
|
||||
}
|
||||
kotlin.setSrcDirs(listOf("src/$name/kotlin"))
|
||||
}
|
||||
|
||||
sourceSets["jvmTest"].apply {
|
||||
dependencies {
|
||||
kotlin("kotlin-test", kotlinVersion)
|
||||
kotlin("kotlin-test-annotations-common", kotlinVersion)
|
||||
kotlin("kotlin-test-junit5", kotlinVersion)
|
||||
implementation("org.junit.jupiter:junit-jupiter-api:5.5.2")
|
||||
}
|
||||
kotlin.outputDir = file("build/classes/kotlin/jvm/test")
|
||||
kotlin.setSrcDirs(listOf("src/$name/kotlin"))
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.enableLanguageFeature("InlineClasses")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
|
||||
|
||||
dependencies {
|
||||
kotlin("kotlin-stdlib", kotlinVersion)
|
||||
kotlin("kotlin-serialization", kotlinVersion)
|
||||
|
||||
kotlinx("atomicfu", atomicFuVersion)
|
||||
kotlinx("kotlinx-io", kotlinXIoVersion)
|
||||
kotlinx("kotlinx-coroutines-io", coroutinesIoVersion)
|
||||
kotlinx("kotlinx-coroutines-core", coroutinesVersion)
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
getByName("commonMain") {
|
||||
all {
|
||||
languageSettings.enableLanguageFeature("InlineClasses")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("reflect"))
|
||||
api(kotlin("stdlib", kotlinVersion))
|
||||
api(kotlin("serialization", kotlinVersion))
|
||||
|
||||
api(kotlinx("atomicfu", atomicFuVersion))
|
||||
api(kotlinx("kotlinx-io", kotlinXIoVersion))
|
||||
api(kotlinx("kotlinx-coroutines-io", coroutinesIoVersion))
|
||||
api(kotlinx("kotlinx-coroutines-core", coroutinesVersion))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
commonMain {
|
||||
dependencies {
|
||||
api(kotlin("reflect", kotlinVersion))
|
||||
api(kotlin("serialization", kotlinVersion))
|
||||
api(kotlinx("kotlinx-coroutines-core-common", coroutinesVersion))
|
||||
api(kotlinx("kotlinx-serialization-runtime-common", serializationVersion))
|
||||
|
||||
/*
|
||||
publishing {
|
||||
publications.withType<MavenPublication>().apply {
|
||||
val jvm by getting {}
|
||||
val metadata by getting { }
|
||||
}
|
||||
}*/
|
||||
api("com.soywiz.korlibs.klock:klock:$klockVersion")
|
||||
|
||||
/*
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "GitHubPackages"
|
||||
url = uri("https://maven.pkg.github.com/mamoe/mirai")
|
||||
credentials {
|
||||
|
||||
val local = loadProperties("local.properties")
|
||||
username = local["miraiCorePublicationUsername"]?.toString()?:error("Cannot find miraiCorePublicationUsername")
|
||||
password = local["miraiCorePublicationKey"].toString()?:error("Cannot find miraiCorePublicationKey")
|
||||
api(ktor("ktor-http-cio", ktorVersion))
|
||||
api(ktor("ktor-http", ktorVersion))
|
||||
api(ktor("ktor-client-core-jvm", ktorVersion))
|
||||
api(ktor("ktor-client-cio", ktorVersion))
|
||||
api(ktor("ktor-client-core", ktorVersion))
|
||||
api(ktor("ktor-network", ktorVersion))
|
||||
//implementation("io.ktor:ktor-io:1.3.0-beta-1")
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
api(kotlin("test-annotations-common"))
|
||||
api(kotlin("test-common"))
|
||||
}
|
||||
kotlin.setSrcDirs(listOf("src/$name/kotlin"))
|
||||
}
|
||||
|
||||
val androidMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("reflect", kotlinVersion))
|
||||
|
||||
api(kotlinx("kotlinx-serialization-runtime", serializationVersion))
|
||||
api(kotlinx("kotlinx-coroutines-android", coroutinesVersion))
|
||||
|
||||
api(ktor("ktor-client-android", ktorVersion))
|
||||
}
|
||||
}
|
||||
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib-jdk8", kotlinVersion))
|
||||
api(kotlin("stdlib-jdk7", kotlinVersion))
|
||||
api(kotlin("reflect", kotlinVersion))
|
||||
|
||||
api(ktor("ktor-client-core-jvm", ktorVersion))
|
||||
api(kotlinx("kotlinx-io-jvm", kotlinXIoVersion))
|
||||
api(kotlinx("kotlinx-serialization-runtime", serializationVersion))
|
||||
}
|
||||
}
|
||||
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
api(kotlin("test", kotlinVersion))
|
||||
api(kotlin("test-annotations-common", kotlinVersion))
|
||||
api(kotlin("test-junit5", kotlinVersion))
|
||||
api("org.junit.jupiter:junit-jupiter-api:5.5.2")
|
||||
}
|
||||
kotlin.outputDir = file("build/classes/kotlin/jvm/test")
|
||||
kotlin.setSrcDirs(listOf("src/$name/kotlin"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun loadProperties(filename: String): Properties = Properties().apply { load(DataInputStream(rootProject.file(filename).inputStream())) }
|
||||
*/
|
||||
}
|
@ -1,3 +1,23 @@
|
||||
pluginManagement {
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
switch (requested.id.id) {
|
||||
case "org.jetbrains.kotlin.multiplatform": useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}"); break
|
||||
case "com.android.library": useModule("com.android.tools.build:gradle:${requested.version}"); break
|
||||
case "com.jfrog.bintray": useModule("com.jfrog.bintray.gradle:gradle-bintray-plugin:${requested.version}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'mirai'
|
||||
|
||||
include(':mirai-core')
|
||||
|
Loading…
Reference in New Issue
Block a user