Publish Gradle metadata for kotlin-stdlib-common, KT-60911

This makes it depend on kotlin-stdlib in all targets
and have no artifacts from Gradle's point of view
This commit is contained in:
Ilya Gorbunov
2023-08-08 17:18:54 +02:00
committed by Space Team
parent e8289181e6
commit 3e4cbd6dd2
3 changed files with 61 additions and 3 deletions
+43 -2
View File
@@ -1,11 +1,10 @@
plugins {
id("kotlin-platform-common")
id("maven-publish")
}
description = 'Kotlin Common Standard Library'
RepoArtifacts.publish(project)
JvmToolchain.updateJvmTarget(project, "1.8")
def commonSrcDir = "../src"
@@ -76,3 +75,45 @@ RepoArtifacts.javadocJar(project)
tasks.named("sourcesJar").configure { it.dependsOn(":prepare:build.version:writeStdlibVersion") }
classes.setDependsOn(classes.dependsOn.findAll { it != "compileJava" })
def stdlibCommonElements = configurations.create("stdlibCommonElements") {
canBeResolved = false
canBeConsumed = true
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
}
}
dependencies {
add(stdlibCommonElements.name, project(":kotlin-stdlib"))
}
class ComponentsFactoryAccess {
SoftwareComponentFactory factory
@javax.inject.Inject
ComponentsFactoryAccess(SoftwareComponentFactory factory) {
this.factory = factory
}
}
SoftwareComponentFactory componentFactory = objects.newInstance(ComponentsFactoryAccess).factory
def rootComponent = componentFactory.adhoc("root")
rootComponent.addVariantsFromConfiguration(stdlibCommonElements) {
mapToOptional()
}
plugins.KotlinBuildPublishingPluginKt.configureDefaultPublishing(project)
publishing {
publications {
def mainPublication = register("main", MavenPublication) {
from(rootComponent)
artifact(jar)
artifact(sourcesJar)
artifact(javadocJar)
plugins.KotlinBuildPublishingPluginKt.configureKotlinPomAttributes(it, project, "Kotlin Common Standard Library (legacy, use kotlin-stdlib instead)", "jar")
}
SbomKt.configureSbom(project, "Main", "kotlin-stdlib-common", ["compileClasspath"], mainPublication)
}
}
@@ -1,11 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- This module was also published with a richer model, Gradle metadata, -->
<!-- which should be used instead. Do not delete the following line which -->
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
<!-- that they should prefer consuming it instead. -->
<!-- do_not_remove: published-with-gradle-metadata -->
<modelVersion>4.0.0</modelVersion>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-common</artifactId>
<version>ArtifactsTest.version</version>
<name>Kotlin Stdlib Common</name>
<description>Kotlin Common Standard Library</description>
<description>Kotlin Common Standard Library (legacy, use kotlin-stdlib instead)</description>
<url>https://kotlinlang.org/</url>
<licenses>
<license>
@@ -25,4 +30,13 @@
<developerConnection>scm:git:https://github.com/JetBrains/kotlin.git</developerConnection>
<url>https://github.com/JetBrains/kotlin</url>
</scm>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>ArtifactsTest.version</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>
@@ -135,6 +135,9 @@ val Project.signLibraryPublication: Boolean
?: project.providers.gradleProperty("isSonatypeRelease").orNull?.toBoolean()
?: false
// overload for Groovy
fun Project.configureDefaultPublishing() = configureDefaultPublishing(signingRequired = signLibraryPublication)
fun Project.configureDefaultPublishing(
signingRequired: Boolean = signLibraryPublication
) {