KMA-413 Publish AC KMM's backend.native dependency with Kotlin-for-IDE
AppCode KMM uses parts of `backend.native` for its Kotlin-ObjC cross-resolve. Thus, this IDE dependency needs to be kept up-to-date with the other Kotlin compiler for IDE artifacts. This commit integrates a stripped down version into the existing `ide-plugin-dependencies` build infrastructure to make it easier to keep them in sync. Implementation details: * Proguard-based removal of code irrelevant for IDE for smaller jar size * Publication of non-stripped-down sources for better IDE experience
This commit is contained in:
+2
-1
@@ -274,7 +274,7 @@ extra["compilerModulesForJps"] = listOf(
|
||||
":compiler:compiler.version"
|
||||
)
|
||||
|
||||
extra["compilerArtifactsForIde"] = listOf(
|
||||
extra["compilerArtifactsForIde"] = listOfNotNull(
|
||||
":prepare:ide-plugin-dependencies:android-extensions-compiler-plugin-for-ide",
|
||||
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-for-ide",
|
||||
":prepare:ide-plugin-dependencies:incremental-compilation-impl-tests-for-ide",
|
||||
@@ -292,6 +292,7 @@ extra["compilerArtifactsForIde"] = listOf(
|
||||
":prepare:ide-plugin-dependencies:compiler-components-for-jps",
|
||||
":prepare:ide-plugin-dependencies:parcelize-compiler-plugin-for-ide",
|
||||
":prepare:ide-plugin-dependencies:lombok-compiler-plugin-for-ide",
|
||||
":prepare:ide-plugin-dependencies:kotlin-backend-native-for-ide".takeIf { kotlinBuildProperties.isKotlinNativeEnabled },
|
||||
":prepare:ide-plugin-dependencies:kotlin-compiler-tests-for-ide",
|
||||
":prepare:ide-plugin-dependencies:kotlin-compiler-testdata-for-ide",
|
||||
":prepare:ide-plugin-dependencies:kotlin-stdlib-minimal-for-test-for-ide",
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
-target 11
|
||||
-dontoptimize
|
||||
-dontobfuscate
|
||||
|
||||
-keepdirectories META-INF/**
|
||||
|
||||
-dontnote **
|
||||
-dontwarn llvm.**
|
||||
-dontwarn kotlin.reflect.full.KClasses
|
||||
|
||||
-keep public class !org.jetbrains.kotlin.backend.konan.objcexport.ObjCExport,org.jetbrains.kotlin.backend.konan.objcexport.** { public *; }
|
||||
-keep public class org.jetbrains.kotlin.backend.konan.ObjCInteropKt { public *; }
|
||||
-keep public class org.jetbrains.kotlin.backend.konan.ObjCOverridabilityCondition { public *; }
|
||||
-keep public class org.jetbrains.kotlin.cli.bc.K2NativeCompilerArguments* { public *; }
|
||||
-keep public class org.jetbrains.kotlin.cli.bc.K2NativeKt { public ** parse*; }
|
||||
-keep public class org.jetbrains.kotlin.cli.bc.BinaryOptionWithValue { public *; }
|
||||
-keep public class org.jetbrains.kotlin.backend.konan.BinaryOptions { public *; }
|
||||
@@ -0,0 +1,102 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
idePluginDependency {
|
||||
if (!kotlinBuildProperties.isKotlinNativeEnabled) return@idePluginDependency
|
||||
|
||||
description = "Stripped down variant of Kotlin Backend Native for IDE (AppCode KMM)"
|
||||
val jarBaseName = property("archivesBaseName") as String
|
||||
|
||||
val proguardLibraryJars by configurations.creating {
|
||||
attributes {
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_API))
|
||||
}
|
||||
}
|
||||
val embedded by configurations
|
||||
|
||||
dependencies {
|
||||
embedded(project(":kotlin-native:backend.native")) { isTransitive = false }
|
||||
|
||||
proguardLibraryJars(project(":kotlin-native:backend.native", "kotlin_stdlib_jar"))
|
||||
proguardLibraryJars(project(":kotlin-native:backend.native", "kotlin_reflect_jar"))
|
||||
proguardLibraryJars(project(":kotlin-native:backend.native", "cli_bcApiElements"))
|
||||
}
|
||||
|
||||
noDefaultJar()
|
||||
|
||||
val shadowJar by task<ShadowJar> {
|
||||
configurations = listOf(embedded)
|
||||
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||
destinationDirectory.set(File(buildDir, "libs"))
|
||||
archiveClassifier.set("shadow")
|
||||
}
|
||||
|
||||
val proguard by task<CacheableProguardTask> {
|
||||
dependsOn(shadowJar)
|
||||
|
||||
configuration(fileFrom(projectDir, "backend-native-for-ide.pro"))
|
||||
injars(mapOf("filter" to "!META-INF/versions/**"), shadowJar.get().outputs.files)
|
||||
outjars(fileFrom(buildDir, "libs", "$jarBaseName-$version-after-proguard.jar"))
|
||||
|
||||
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_8))
|
||||
|
||||
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars)
|
||||
libraryjars(
|
||||
files(
|
||||
javaLauncher.map {
|
||||
firstFromJavaHomeThatExists(
|
||||
"jre/lib/rt.jar",
|
||||
"../Classes/classes.jar",
|
||||
jdkHome = it.metadata.installationPath.asFile
|
||||
)
|
||||
},
|
||||
javaLauncher.map {
|
||||
firstFromJavaHomeThatExists(
|
||||
"jre/lib/jsse.jar",
|
||||
"../Classes/jsse.jar",
|
||||
jdkHome = it.metadata.installationPath.asFile
|
||||
)
|
||||
},
|
||||
javaLauncher.map {
|
||||
org.gradle.internal.jvm.Jvm.forHome(it.metadata.installationPath.asFile).toolsJar
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val resultJar by task<Jar> {
|
||||
dependsOn(proguard)
|
||||
manifest.attributes.apply {
|
||||
put("Implementation-Vendor", "JetBrains")
|
||||
put("Implementation-Title", jarBaseName)
|
||||
put("Implementation-Version", version)
|
||||
}
|
||||
from {
|
||||
zipTree(proguard.get().singleOutputFile())
|
||||
}
|
||||
}
|
||||
|
||||
addArtifact("runtime", resultJar)
|
||||
addArtifact("runtimeElements", resultJar)
|
||||
addArtifact("archives", resultJar)
|
||||
|
||||
publish()
|
||||
|
||||
// includes more sources than left by proguard
|
||||
org.gradle.api.plugins.internal.JvmPluginsHelper.configureDocumentationVariantWithArtifact(
|
||||
JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME,
|
||||
null,
|
||||
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
|
||||
)
|
||||
}
|
||||
@@ -358,6 +358,7 @@ if (!buildProperties.inJpsBuildIdeaSync) {
|
||||
":prepare:ide-plugin-dependencies:sam-with-receiver-compiler-plugin-for-ide",
|
||||
":prepare:ide-plugin-dependencies:parcelize-compiler-plugin-for-ide",
|
||||
":prepare:ide-plugin-dependencies:lombok-compiler-plugin-for-ide",
|
||||
":prepare:ide-plugin-dependencies:kotlin-backend-native-for-ide",
|
||||
":prepare:ide-plugin-dependencies:tests-common-tests-for-ide",
|
||||
":prepare:ide-plugin-dependencies:compiler-components-for-jps",
|
||||
":prepare:ide-plugin-dependencies:kotlin-compiler-testdata-for-ide",
|
||||
|
||||
Reference in New Issue
Block a user