diff --git a/buildSrc/src/main/kotlin/JvmPublishing.kt b/buildSrc/src/main/kotlin/JvmPublishing.kt index 673bc7b96..488c733e9 100644 --- a/buildSrc/src/main/kotlin/JvmPublishing.kt +++ b/buildSrc/src/main/kotlin/JvmPublishing.kt @@ -20,7 +20,6 @@ import org.gradle.api.tasks.bundling.Jar import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.registering fun Project.configureRemoteRepos() { tasks.register("ensureMavenCentralAvailable") { @@ -73,16 +72,17 @@ fun Project.configureRemoteRepos() { @Suppress("NOTHING_TO_INLINE") inline fun Project.configurePublishing( artifactId: String, - vcs: String = "https://github.com/mamoe/mirai" + vcs: String = "https://github.com/mamoe/mirai", + addProjectComponents: Boolean = true ) { configureRemoteRepos() apply() - val sourcesJar by tasks.registering(Jar::class) { + val sourcesJar = if (!addProjectComponents) null else tasks.maybeCreate("sourcesJar", Jar::class.java).apply { archiveClassifier.set("sources") from(sourceSets["main"].allSource) } - val stubJavadoc = tasks.register("javadocJar", Jar::class) { + val stubJavadoc = if (!addProjectComponents) null else tasks.register("javadocJar", Jar::class) { @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") archiveClassifier.set("javadoc") } @@ -90,7 +90,7 @@ inline fun Project.configurePublishing( publishing { publications { register("mavenJava", MavenPublication::class) { - from(components["java"]) + if (addProjectComponents) from(components["java"]) groupId = rootProject.group.toString() setArtifactId(artifactId) @@ -101,8 +101,8 @@ inline fun Project.configurePublishing( vcs = vcs ) - artifact(sourcesJar.get()) - artifact(stubJavadoc.get()) + sourcesJar?.let { artifact(it) } + stubJavadoc?.get()?.let { artifact(it) } } } configGpgSign(this@configurePublishing) diff --git a/mirai-bom/build.gradle.kts b/mirai-bom/build.gradle.kts index 20a65d5be..fd83a8852 100644 --- a/mirai-bom/build.gradle.kts +++ b/mirai-bom/build.gradle.kts @@ -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/dev/LICENSE + */ + plugins { `java-platform` `maven-publish` @@ -36,3 +45,5 @@ publishing { } } } + +configurePublishing("mirai-bom", addProjectComponents = false) \ No newline at end of file