[K/N][publish] Publish kotlin-native-compiler-embeddable.jar
Add an ability to publish kotlin-native-compiler-embeddable.jar and sources to maven. Adds necessary for that sourcesJar and javadocJar tasks. Note that Native distribution uses this jar without a version postfix. Also cleaned up the obsolete backend.native publication and renamed project to match its name. Merge-request: KT-MR-12974 Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
5562c95155
commit
9f9b4d1981
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.tools.NativePluginKt
|
||||
|
||||
buildscript {
|
||||
apply from: "../../kotlin-native/gradle/kotlinGradlePlugin.gradle"
|
||||
apply plugin: 'project-report'
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
@@ -238,23 +237,9 @@ tasks.register("debugCompiler", JavaExec) {
|
||||
args = findProperty("konan.debug.args").toString().tokenize() ?: []
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven { url = "$buildDir/repo" }
|
||||
}
|
||||
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = 'org.jetbrains.kotlin'
|
||||
artifactId = 'backend.native'
|
||||
version = kotlinVersion
|
||||
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RepoArtifacts.sourcesJar(project) {
|
||||
it.from(sourceSets["cli_bc"].allSource)
|
||||
it.from(sourceSets["compiler"].allSource)
|
||||
}
|
||||
|
||||
RepoArtifacts.javadocJar(project)
|
||||
|
||||
@@ -149,6 +149,11 @@ configurations {
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, CppUsage.LLVM_BITCODE))
|
||||
}
|
||||
}
|
||||
|
||||
embeddableJar {
|
||||
canBeConsumed = false
|
||||
canBeResolved = true
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: CompilationDatabasePlugin
|
||||
@@ -170,6 +175,7 @@ dependencies {
|
||||
compilationDatabase project(":kotlin-native:common")
|
||||
compilationDatabase project(":kotlin-native:runtime")
|
||||
runtimeBitcode project(":kotlin-native:runtime")
|
||||
embeddableJar project(path: ':kotlin-native:prepare:kotlin-native-compiler-embeddable', configuration: 'runtimeElements')
|
||||
}
|
||||
|
||||
apply plugin: GitClangFormatPlugin
|
||||
@@ -246,7 +252,7 @@ tasks.register("distCompiler", Copy) {
|
||||
enabled = false
|
||||
} else {
|
||||
dependsOn ':kotlin-native:shadowJar'
|
||||
dependsOn ":kotlin-native-compiler-embeddable:kotlin-native-compiler-embeddable"
|
||||
dependsOn configurations.embeddableJar
|
||||
}
|
||||
|
||||
destinationDir distDir
|
||||
@@ -259,7 +265,10 @@ tasks.register("distCompiler", Copy) {
|
||||
into('konan/lib')
|
||||
}
|
||||
|
||||
from(project(":kotlin-native-compiler-embeddable").file("build/libs")) {
|
||||
from(configurations.embeddableJar) {
|
||||
rename {
|
||||
"kotlin-native-compiler-embeddable.jar"
|
||||
}
|
||||
into("konan/lib")
|
||||
}
|
||||
|
||||
|
||||
+52
-31
@@ -1,3 +1,4 @@
|
||||
import org.gradle.kotlin.dsl.support.serviceOf
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.kotlinNativeDist
|
||||
|
||||
@@ -5,38 +6,37 @@ plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
val testCompilationClasspath by configurations.creating
|
||||
val testCompilerClasspath by configurations.creating {
|
||||
isCanBeConsumed = false
|
||||
extendsFrom(configurations["runtimeElements"])
|
||||
attributes {
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
|
||||
}
|
||||
}
|
||||
description = "Embeddable JAR of Kotlin/Native compiler"
|
||||
group = "org.jetbrains.kotlin"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
val kotlinNativeEmbedded by configurations.creating
|
||||
val testPlugin by configurations.creating
|
||||
val testPluginRuntime by configurations.creating
|
||||
val kotlinNativeEmbedded by configurations.creating {
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
}
|
||||
|
||||
fun DependencyHandlerScope.testPluginRuntime(any: Any) {
|
||||
val notation = any as? String ?: return add(testPluginRuntime.name, any) {}
|
||||
val (group, artifact, version) = notation.split(":")
|
||||
val platformName = HostManager.host.name
|
||||
val gradlePlatformName = platformName.replace("_", "")
|
||||
return add(testPluginRuntime.name, "$group:$artifact-$gradlePlatformName:$version") {
|
||||
isTransitive = false
|
||||
attributes {
|
||||
attribute(Attribute.of("artifactType", String::class.java), "org.jetbrains.kotlin.klib")
|
||||
attribute(Attribute.of("org.gradle.status", String::class.java), "release")
|
||||
attribute(Attribute.of("org.jetbrains.kotlin.native.target", String::class.java), platformName)
|
||||
attribute(Attribute.of("org.jetbrains.kotlin.platform.type", String::class.java), "native")
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named("kotlin-api"))
|
||||
}
|
||||
val kotlinNativeSources by configurations.creating {
|
||||
isVisible = false
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
|
||||
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES))
|
||||
}
|
||||
}
|
||||
|
||||
val kotlinNativeJavadoc by configurations.creating {
|
||||
isVisible = false
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
|
||||
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.JAVADOC))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,16 +51,16 @@ dependencies {
|
||||
kotlinNativeEmbedded(project(":kotlin-native:klib"))
|
||||
kotlinNativeEmbedded(project(":kotlin-native:endorsedLibraries:kotlinx.cli", "jvmRuntimeElements"))
|
||||
kotlinNativeEmbedded(project(":kotlin-compiler")) { isTransitive = false }
|
||||
|
||||
kotlinNativeSources(project(":kotlin-native:backend.native"))
|
||||
kotlinNativeJavadoc(project(":kotlin-native:backend.native"))
|
||||
|
||||
testImplementation(libs.junit4)
|
||||
testImplementation(project(":kotlin-test:kotlin-test-junit"))
|
||||
}
|
||||
|
||||
val compiler = embeddableCompiler("kotlin-native-compiler-embeddable") {
|
||||
from(kotlinNativeEmbedded)
|
||||
/**
|
||||
* this jar distributed through kotlin-native distribution, but not with maven.
|
||||
*/
|
||||
archiveVersion.set("")
|
||||
mergeServiceFiles()
|
||||
}
|
||||
|
||||
@@ -69,9 +69,30 @@ val runtimeJar = runtimeJar(compiler) {
|
||||
mergeServiceFiles()
|
||||
}
|
||||
|
||||
val archiveZipper = serviceOf<ArchiveOperations>()::zipTree
|
||||
|
||||
kotlin.sourceSets["test"].kotlin.srcDir("tests/kotlin")
|
||||
val sourcesJar = sourcesJar {
|
||||
dependsOn(kotlinNativeSources)
|
||||
from { kotlinNativeSources.map { archiveZipper(it) } }
|
||||
}
|
||||
|
||||
val javadocJar = javadocJar {
|
||||
dependsOn(kotlinNativeJavadoc)
|
||||
from { kotlinNativeJavadoc.map { archiveZipper(it) } }
|
||||
}
|
||||
|
||||
publish {
|
||||
setArtifacts(listOf(runtimeJar, sourcesJar, javadocJar))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" {}
|
||||
"test" {
|
||||
kotlin {
|
||||
srcDir("tests/kotlin")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
projectTest {
|
||||
/**
|
||||
+20
@@ -70,6 +70,15 @@ class EmbeddableContentsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test jars have no jna`() {
|
||||
konanHomeJars.filterNot {
|
||||
it.name.startsWith("trove")
|
||||
}.forEach {
|
||||
it.checkJarDoesntContain("com/sun/jna")
|
||||
}
|
||||
}
|
||||
|
||||
private fun File.checkJarContains(string: String) {
|
||||
JarFile(this).use { jar ->
|
||||
assert(jar.entries()
|
||||
@@ -80,4 +89,15 @@ class EmbeddableContentsTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun File.checkJarDoesntContain(string: String) {
|
||||
JarFile(this).use { jar ->
|
||||
assert(jar.entries()
|
||||
.asSequence()
|
||||
.none { it.name.contains(string) }
|
||||
) {
|
||||
"Jar file ${jar.name} contains element: $string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ fun Project.nativeTest(
|
||||
|
||||
val kotlinNativeCompilerEmbeddable = if (customNativeHome == null)
|
||||
configurations.detachedConfiguration(
|
||||
dependencies.project(":kotlin-native-compiler-embeddable"),
|
||||
dependencies.project(":kotlin-native:prepare:kotlin-native-compiler-embeddable"),
|
||||
dependencies.module(commonDependency("org.jetbrains.intellij.deps:trove4j"))
|
||||
).also { dependsOn(it) }
|
||||
else
|
||||
|
||||
+1
-2
@@ -850,6 +850,5 @@ if (buildProperties.isKotlinNativeEnabled) {
|
||||
include ':kotlin-native:platformLibs'
|
||||
include ':kotlin-native:libclangext'
|
||||
include ':kotlin-native:backend.native:tests'
|
||||
include ":kotlin-native-compiler-embeddable"
|
||||
project(":kotlin-native-compiler-embeddable").projectDir = "$rootDir/kotlin-native/prepare/kotlin-native-embeddable-compiler" as File
|
||||
include ":kotlin-native:prepare:kotlin-native-compiler-embeddable"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user