diff --git a/.github/workflows/bintray.yml b/.github/workflows/bintray.yml index b3fcd50a9..83072f5d7 100644 --- a/.github/workflows/bintray.yml +++ b/.github/workflows/bintray.yml @@ -28,13 +28,10 @@ jobs: run: ./gradlew build # if test's failed, don't publish - name: Check keys run: ./gradlew :mirai-core:ensureBintrayAvailable :mirai-core-qqandroid:ensureBintrayAvailable -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }} - - name: Gradle :mirai-core:bintrayUpload - run: ./gradlew :mirai-core:bintrayUpload -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:bintrayUpload - run: ./gradlew :mirai-core-qqandroid:bintrayUpload -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }} - - name: Gradle :mirai-serialization:bintrayUpload - run: ./gradlew :mirai-serialization:bintrayUpload -Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }} -Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }} - + - name: Gradle :mirai-core:publish + 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: Upload artifact # uses: actions/upload-artifact@v1.0.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 575984171..abe4ae21f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ mirai 欢迎一切形式的代码贡献。你可以通过以下几种途径向 m ### 注意事项 - 尽量不要引用新的库 - 遵守 Kotlin 官方代码规范(提交前使用 IDE 格式化代码 (commit 时勾选 'Reformat code')) -- 不要手动拆解数据包. 请一定使用 `kotlinx.serialization` 拆解 ProtoBuf, 使用 [`jcekt`](https://github.com/him188/jcekt) 拆解 Tars 数据包, 使用 `kotlinx.serialization` 拆解 Json 数据. +- 不要手动拆解数据包. 请一定使用 `kotlinx.serialization` 拆解 ProtoBuf, 使用 `net.mamoe.mirai.qqandroid.utils.io.serialization.Tars` 拆解 Tars 数据包, 使用 `kotlinx.serialization` 拆解 Json 数据. ## 社区 diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index c3736c931..2e51664d2 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -13,11 +13,11 @@ object Versions { } object Kotlin { - const val compiler = "1.4.0-rc" - const val stdlib = "1.4.0-rc" - const val coroutines = "1.3.8-1.4.0-rc" - const val atomicFU = "0.14.3-1.4.0-rc" - const val serialization = "1.0-M1-1.4.0-rc" + const val compiler = "1.4.0" + const val stdlib = "1.4.0" + const val coroutines = "1.3.9" + const val atomicFU = "0.14.4" + const val serialization = "1.0.0-RC" const val ktor = "1.3.2-1.4.0-rc" const val binaryValidator = "0.2.3" @@ -26,8 +26,6 @@ object Versions { const val dokka = "0.10.1" } - const val jcekt = "2.0.0-1.4.0-rc-4" - object Android { const val androidGradlePlugin = "3.5.3" } diff --git a/docs/mirai.md b/docs/mirai.md index f9c5a0f32..3b2ec87f5 100644 --- a/docs/mirai.md +++ b/docs/mirai.md @@ -121,15 +121,15 @@ Mirai 通过某种方式同时生成了桥梁方法 `public void sendMessage(Mes 在 `1.0.0` 及更新版本, mirai-core 通过 gradle 依赖的 `api` 方式暴露了如下依赖库: -- `kotlin-stdlib`: Kotlin 标准库, 版本至少为 1.3.72 -- `kotlin-reflect`: Kotlin 反射, 版本至少为 1.3.72 -- `kotlinx-coroutines-core`: Kotlin 协程, 版本至少为 1.3.7 -- `kotlinx-serialization-runtime`: Kotlin 序列化运行时, 和 JSON 序列化, 版本至少为 0.20.0 -- `kotlinx-serialization-protobuf`: Kotlin ProtocolBuffers 序列化, 版本至少为 0.20.0 +- `kotlin-stdlib`: Kotlin 标准库, 版本 1.4.0 +- `kotlin-reflect`: Kotlin 反射, 版本 1.4.0 +- `kotlinx-coroutines-core`: Kotlin 协程, 版本 1.3.9 +- `kotlinx-serialization-core`: Kotlin 序列化运行时, 和 JSON 序列化, 版本 1.0.0-RC (此库不稳定, 请不要用新版本覆盖) +- `kotlinx-serialization-protobuf`: Kotlin ProtocolBuffers 序列化, 版本 1.0.0-RC (此库不稳定, 请不要用新版本覆盖) - `kotlinx-io`: Kotlin IO, 版本至少为 0.1.16 (此库非常不稳定, 不建议使用它) - `kotlinx-coroutines-io`: Kotlin 异步 IO, 版本至少为 0.1.16 (此库非常不稳定, 不建议使用它) -- `kotlinx-atomicfu`: Kotlin 原子操作, 版本至少为 0.14.2 -- `ktor-client-core`, `ktor-network`, `ktor-client-cio`: Ktor HTTP, 版本至少为 1.3.2 +- `kotlinx-atomicfu`: Kotlin 原子操作, 版本至少为 0.14.4 +- `ktor-client-core`, `ktor-network`, `ktor-client-cio`: Ktor HTTP, 版本至少为 1.3.2-1.4.0-rc 在 JVM, mirai 使用 `"org.bouncycastle:bcprov-jdk15on:1.64"` 进行密匙计算. diff --git a/gradle.properties b/gradle.properties index 7d006b978..e76c9a8d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,6 @@ kotlin.parallel.tasks.in.project=true org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8 org.gradle.parallel=true -#kotlin.mpp.enableGranularSourceSetsMetadata=true \ No newline at end of file +#kotlin.mpp.enableGranularSourceSetsMetadata=true + +systemProp.org.gradle.internal.publish.checksums.insecure=true \ No newline at end of file diff --git a/gradle/bintray.gradle b/gradle/bintray.gradle new file mode 100644 index 000000000..8a73daf7a --- /dev/null +++ b/gradle/bintray.gradle @@ -0,0 +1,12 @@ +publishing { + repositories { + maven { + url = "https://api.bintray.com/maven/mamoe/mirai/mirai-core/;publish=0" + + credentials { + username = upload.Bintray.getUser(project) + password = upload.Bintray.getKey(project) + } + } + } +} \ No newline at end of file diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 001960256..5ce9b910d 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -1,87 +1,42 @@ -import upload.Bintray - // 部分源码来自 kotlinx.coroutines // Source code from kotlinx.coroutines -task ensureBintrayAvailable() { +tasks.register("ensureBintrayAvailable") { doLast { - if (!Bintray.isBintrayAvailable(project)) { + if (!upload.Bintray.isBintrayAvailable(project)) { throw new IllegalStateException("bintray isn't available. ") } } } -if (!Bintray.isBintrayAvailable(project)) { - println("bintray isn't available. NO PUBLICATIONS WILL BE SET") - return -} +def vcs = "https://github.com/mamoe/mirai" -def miraiGitHubUrl = "https://github.com/mamoe/mirai" - -bintray { - user = Bintray.getUser(project) - key = Bintray.getKey(project) - - pkg { - repo = 'mirai' - name = "mirai-core" - licenses = ['AGPL'] - vcsUrl = miraiGitHubUrl - websiteUrl = miraiGitHubUrl - githubRepo = miraiGitHubUrl - issueTrackerUrl = "$miraiGitHubUrl/issues" - /* version { - name = project.version - }*/ - } -} - -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('url', miraiGitHubUrl) - root.children().last() + { - licenses { - license { - name "AGPL-V3" - url "https://www.gnu.org/licenses/agpl-3.0.txt" - distribution "repo" - } - } - developers { - developer { - id "mamoe" - name "Mamoe Technologies" - email "support@mamoe.net" - } - } - scm { - url miraiGitHubUrl - } - } +def pomConfig = { + licenses { + license { + name "AGPLv3 with Mamoe Exceptions" + url "https://github.com/mamoe/mirai/blob/master/LICENSE" + distribution "repo" } } + developers { + developer { + id "mamoe" + name "Mamoe Technologies" + email "support@mamoe.net" + } + } + scm { + url vcs + } } -bintrayUpload.doFirst { - publications = project.publishing.publications -} - -bintrayUpload.dependsOn { - def list = new LinkedList() - 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 +project.ext.configureMavenCentralMetadata = { pom -> + def root = asNode() + root.appendNode('name', project.name) + root.appendNode('description', project.description) + root.appendNode('url', vcs) + root.children().last() + pomConfig } try { @@ -90,40 +45,117 @@ try { task javadocJar(type: Jar) { archiveClassifier = 'javadoc' } - } catch (Exception ignored) { } -publishing { - publications.all { - // add empty javadocs (no need for MPP root publication which publishes only pom file) - if (it.name != 'kotlinMultiplatform') { - it.artifact(javadocJar) + +try { + task stubJavadoc(type: Jar) { + archiveClassifier = 'javadoc' + } +}catch (Exception ignored) { + +} + +/** + * Publish the platform JAR and POM so that consumers who depend on this module and can't read Gradle module + * metadata can still get the platform artifact and transitive dependencies from the POM + * (see details in https://youtrack.jetbrains.com/issue/KT-39184#focus=streamItem-27-4115233.0-0) + */ +project.ext.publishPlatformArtifactsInRootModule = { platformPublication -> + afterEvaluate { + def platformPomBuilder = null + + platformPublication.pom.withXml { platformPomBuilder = asString() } + + publishing.publications.kotlinMultiplatform { + platformPublication.artifacts.forEach { + artifact(it) + } + + pom.withXml { + def pomStringBuilder = asString() + pomStringBuilder.setLength(0) + // The platform POM needs its artifact ID replaced with the artifact ID of the root module: + def platformPomString = platformPomBuilder.toString() + platformPomString.eachLine { line -> + if (!line.contains("