[Build] Make K/N backend sources publishing for IDE in a less hacky way

The previous way was too hacky relying on internal API
#KTI-1221 In Progress
This commit is contained in:
Alexander.Likhachev
2023-06-07 18:04:14 +02:00
committed by Space Team
parent 8dd957d371
commit 3affe78ae5
2 changed files with 21 additions and 14 deletions
@@ -249,3 +249,8 @@ publishing {
} }
} }
} }
ArtifactsKt.sourcesJar(project) {
it.from(sourceSets["cli_bc"].allSource)
it.from(sourceSets["compiler"].allSource)
}
@@ -1,4 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.kotlin.dsl.support.serviceOf
plugins { plugins {
kotlin("jvm") kotlin("jvm")
@@ -16,6 +17,15 @@ idePluginDependency {
} }
} }
val embedded by configurations val embedded by configurations
val backendNativeSourcesConfiguration by configurations.creating {
isVisible = false
isCanBeResolved = true
isCanBeConsumed = false
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES))
}
}
dependencies { dependencies {
embedded(project(":kotlin-native:backend.native")) { isTransitive = false } embedded(project(":kotlin-native:backend.native")) { isTransitive = false }
@@ -24,6 +34,7 @@ idePluginDependency {
proguardLibraryJars(project(":kotlin-native:backend.native", "kotlin_stdlib_jar")) proguardLibraryJars(project(":kotlin-native:backend.native", "kotlin_stdlib_jar"))
proguardLibraryJars(project(":kotlin-native:backend.native", "kotlin_reflect_jar")) proguardLibraryJars(project(":kotlin-native:backend.native", "kotlin_reflect_jar"))
proguardLibraryJars(project(":kotlin-native:backend.native", "cli_bcApiElements")) proguardLibraryJars(project(":kotlin-native:backend.native", "cli_bcApiElements"))
backendNativeSourcesConfiguration(project(":kotlin-native:backend.native"))
} }
noDefaultJar() noDefaultJar()
@@ -84,18 +95,9 @@ idePluginDependency {
publish() publish()
// includes more sources than left by proguard sourcesJar {
org.gradle.api.plugins.internal.JvmPluginsHelper.configureDocumentationVariantWithArtifact( val archiveOperations = serviceOf<ArchiveOperations>()
JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME, from(backendNativeSourcesConfiguration.map { archiveOperations.zipTree(it) })
null, dependsOn(backendNativeSourcesConfiguration)
DocsType.SOURCES, }
listOf(),
"sourcesJar",
project(":kotlin-native:backend.native").sourceSets["cli_bc"].allSource +
project(":kotlin-native:backend.native").sourceSets["compiler"].allSource,
components["kotlinLibrary"] as AdhocComponentWithVariants,
configurations,
tasks,
objects
)
} }