From 652f0736c57be7997312f37380bb2801a051ae33 Mon Sep 17 00:00:00 2001 From: Tadeas Kriz Date: Sat, 24 Feb 2024 22:27:08 -0500 Subject: [PATCH] Get rid of dynamic loading of the SKIE Gradle Plugin. --- .../gradle-plugin.gradle.kts} | 66 +++--- .../skie/gradle/KotlinCompilerVersion.kt | 0 .../skie/gradle/KotlinToolingVersion.kt | 0 .../touchlab/skie/plugin/SkieGradlePlugin.kt} | 195 +++++++++++------- .../skie/plugin/SkieInternalExtension.kt | 0 .../touchlab/skie/plugin/SkieLoaderPlugin.kt | 38 ++++ .../analytics/GradleAnalyticsManager.kt | 34 ++- .../analytics/SkieUploadAnalyticsTask.kt | 0 .../environment/GradleEnvironmentAnalytics.kt | 10 +- .../skie/plugin/analytics/git/GitAnalytics.kt | 12 +- .../analytics/hardware/HardwareAnalytics.kt | 0 .../performance/GradlePerformanceAnalytics.kt | 0 .../analytics/project/ProjectAnalytics.kt | 8 +- .../CreateSkieConfigurationTask.kt | 2 +- .../configuration/Project.skieExtension.kt | 0 .../SkieAnalyticsConfiguration.kt | 0 .../configuration/SkieBuildConfiguration.kt | 0 .../configuration/SkieDebugConfiguration.kt | 0 .../plugin/configuration/SkieExtension.kt | 0 .../configuration/SkieFeatureConfiguration.kt | 0 .../SkieMigrationConfiguration.kt | 0 .../util/BooleanProperty.takeIf.kt | 0 .../util/GradleSkieConfiguration.kt | 0 .../coroutines/AddDependencyOnSkieRuntime.kt | 4 +- .../coroutines/ConfigureMinOsVersions.kt | 53 +++++ .../coroutines/IsCoroutinesInteropEnabled.kt | 0 .../DisableCachingForDefaultArguments.kt | 0 .../SkieCompilerPluginDependencyProvider.kt | 9 +- .../directory/SkieDirectoriesManager.kt | 0 .../fatframework/FatFrameworkConfigurator.kt | 0 .../plugin/subplugin/SkieSubPluginManager.kt | 0 .../skie/plugin/subplugin/SkieSubplugin.kt | 0 .../switflink/SwiftLinkingConfigurator.kt | 0 .../touchlab/skie/plugin/util/BaseSkieTask.kt | 0 .../touchlab/skie/plugin/util/DarwinTarget.kt | 0 .../co/touchlab/skie/plugin/util/KonanHome.kt | 0 .../co/touchlab/skie/plugin/util/KotlinDsl.kt | 0 .../plugin/util/KotlinPluginExtensions.kt | 0 .../SkiePluginOptionToCompilerPluginOption.kt | 0 .../touchlab/skie/plugin/util/SkieTarget.kt | 0 .../co/touchlab/skie/plugin/util/StringMap.kt | 0 .../touchlab/skie/plugin/util/TargetTriple.kt | 0 .../skie/plugin/util/TaskDoOptimized.kt | 0 .../touchlab/skie/plugin/util/toPrettyJson.kt | 0 .../skie/plugin/SkieGradlePluginTest.kt | 0 SKIE/settings.gradle.kts | 6 +- .../plugin-api/gradle-plugin-api.gradle.kts | 20 -- .../plugin/gradle-plugin.gradle.kts | 94 --------- .../kotlin-compiler-attribute-local | 1 - .../touchlab/skie/plugin/SkieGradlePlugin.kt | 129 ------------ .../coroutines/ConfigureMinOsVersionTask.kt | 94 --------- .../coroutines/ConfigureMinOsVersions.kt | 18 -- .../src/main/kotlin-compiler-attribute-local | 2 +- .../buildsetup/plugins/DevAcceptanceTests.kt | 3 +- .../architecture/MacOsCpuArchitecture.kt | 29 ++- .../gradle/util/KotlinNativeCompilerHome.kt | 3 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- dev-support/build.gradle.kts | 2 +- .../pure-compiler/framework/build.gradle.kts | 7 +- dev-support/settings.gradle.kts | 13 +- .../skie/ios/framework/build.gradle.kts | 4 +- .../skie/mac/framework/build.gradle.kts | 7 +- dev-support/skie/mac/swift/build.gradle.kts | 3 +- 63 files changed, 356 insertions(+), 512 deletions(-) rename SKIE/{skie-gradle/plugin-loader/gradle-plugin-loader.gradle.kts => gradle-plugin/gradle-plugin.gradle.kts} (56%) rename SKIE/{skie-gradle/plugin-loader => gradle-plugin}/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinCompilerVersion.kt (100%) rename SKIE/{skie-gradle/plugin-loader => gradle-plugin}/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinToolingVersion.kt (100%) rename SKIE/{skie-gradle/plugin-loader/src/main/kotlin/co/touchlab/skie/plugin/SkieLoaderPlugin.kt => gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieGradlePlugin.kt} (52%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/SkieInternalExtension.kt (100%) create mode 100644 SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieLoaderPlugin.kt rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/analytics/GradleAnalyticsManager.kt (70%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/analytics/SkieUploadAnalyticsTask.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/analytics/environment/GradleEnvironmentAnalytics.kt (79%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/analytics/git/GitAnalytics.kt (81%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/analytics/hardware/HardwareAnalytics.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/analytics/performance/GradlePerformanceAnalytics.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/analytics/project/ProjectAnalytics.kt (70%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/CreateSkieConfigurationTask.kt (95%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/Project.skieExtension.kt (100%) rename SKIE/{skie-gradle/plugin-api/src/common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/SkieAnalyticsConfiguration.kt (100%) rename SKIE/{skie-gradle/plugin-api/src/common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/SkieBuildConfiguration.kt (100%) rename SKIE/{skie-gradle/plugin-api/src/common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/SkieDebugConfiguration.kt (100%) rename SKIE/{skie-gradle/plugin-api/src/common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/SkieExtension.kt (100%) rename SKIE/{skie-gradle/plugin-api/src/common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/SkieFeatureConfiguration.kt (100%) rename SKIE/{skie-gradle/plugin-api/src/common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/SkieMigrationConfiguration.kt (100%) rename SKIE/{skie-gradle/plugin-api/src/common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/util/BooleanProperty.takeIf.kt (100%) rename SKIE/{skie-gradle/plugin-api/src/common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/configuration/util/GradleSkieConfiguration.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt (95%) create mode 100644 SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersions.kt rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/coroutines/IsCoroutinesInteropEnabled.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/defaultarguments/DisableCachingForDefaultArguments.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/dependencies/SkieCompilerPluginDependencyProvider.kt (75%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/directory/SkieDirectoriesManager.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/fatframework/FatFrameworkConfigurator.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubPluginManager.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubplugin.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/switflink/SwiftLinkingConfigurator.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/BaseSkieTask.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/DarwinTarget.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/KonanHome.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/KotlinDsl.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/KotlinPluginExtensions.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/SkiePluginOptionToCompilerPluginOption.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/SkieTarget.kt (100%) rename SKIE/{skie-gradle/plugin-loader => gradle-plugin}/src/main/kotlin/co/touchlab/skie/plugin/util/StringMap.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/TargetTriple.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/TaskDoOptimized.kt (100%) rename SKIE/{skie-gradle/plugin/src/kgp_common/gradle_common => gradle-plugin/src/main}/kotlin/co/touchlab/skie/plugin/util/toPrettyJson.kt (100%) rename SKIE/{skie-gradle/plugin-loader => gradle-plugin}/src/test/kotlin/co/touchlab/skie/plugin/SkieGradlePluginTest.kt (100%) delete mode 100644 SKIE/skie-gradle/plugin-api/gradle-plugin-api.gradle.kts delete mode 100644 SKIE/skie-gradle/plugin/gradle-plugin.gradle.kts delete mode 120000 SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin-compiler-attribute-local delete mode 100644 SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/SkieGradlePlugin.kt delete mode 100644 SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersionTask.kt delete mode 100644 SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersions.kt diff --git a/SKIE/skie-gradle/plugin-loader/gradle-plugin-loader.gradle.kts b/SKIE/gradle-plugin/gradle-plugin.gradle.kts similarity index 56% rename from SKIE/skie-gradle/plugin-loader/gradle-plugin-loader.gradle.kts rename to SKIE/gradle-plugin/gradle-plugin.gradle.kts index 8471b60a3..75ac340cc 100644 --- a/SKIE/skie-gradle/plugin-loader/gradle-plugin-loader.gradle.kts +++ b/SKIE/gradle-plugin/gradle-plugin.gradle.kts @@ -1,8 +1,6 @@ import co.touchlab.skie.gradle.KotlinCompilerVersion import co.touchlab.skie.gradle.publish.dependencyName import co.touchlab.skie.gradle.util.enquoted -import co.touchlab.skie.gradle.util.stringListProperty -import co.touchlab.skie.gradle.version.KotlinToolingVersionComponent import co.touchlab.skie.gradle.version.gradleApiVersionDimension import co.touchlab.skie.gradle.version.kotlinToolingVersionDimension @@ -13,12 +11,12 @@ plugins { } skiePublishing { - name = "SKIE Gradle Plugin Loader" - description = "Gradle plugin that loads the correct SKIE version based on Kotlin and Gradle versions." + name = "SKIE Gradle Plugin" + description = "Gradle plugin for configuring SKIE compiler plugin." } buildConfig { - val gradlePlugin = projects.gradle.gradlePlugin.dependencyProject + val gradlePlugin = projects.gradlePlugin.dependencyProject buildConfigField("String", "SKIE_GRADLE_PLUGIN", "\"${gradlePlugin.dependencyName}\"") val kotlinToSkieKgpVersion = project.kotlinToolingVersionDimension().components @@ -34,6 +32,22 @@ buildConfig { buildConfigField("co.touchlab.skie.plugin.util.StringMap", "KOTLIN_TO_SKIE_KGP_VERSION", "mapOf($kotlinToSkieKgpVersion)") buildConfigField("String", "SKIE_VERSION", "\"${project.version}\"") + + + val kotlinPlugin = project.provider { projects.compiler.kotlinPlugin.dependencyProject } + buildConfigField("String", "KOTLIN_PLUGIN_GROUP", kotlinPlugin.map { it.group.toString().enquoted() }) + buildConfigField("String", "KOTLIN_PLUGIN_NAME", kotlinPlugin.map { it.name.enquoted() }) + buildConfigField("String", "KOTLIN_PLUGIN_VERSION", kotlinPlugin.map { it.version.toString().enquoted() }) + + val runtime = project.provider { projects.runtime.runtimeKotlin.dependencyProject } + buildConfigField("String", "RUNTIME_DEPENDENCY_GROUP", runtime.map { it.group.toString().enquoted() }) + buildConfigField("String", "RUNTIME_DEPENDENCY_NAME", runtime.map { it.name.enquoted() }) + buildConfigField("String", "RUNTIME_DEPENDENCY_VERSION", runtime.map { it.version.toString().enquoted() }) + + val pluginId: String by properties + buildConfigField("String", "KOTLIN_PLUGIN_ID", pluginId.enquoted()) + + buildConfigField("String", "MIXPANEL_PROJECT_TOKEN", "\"a4c9352b6713103c0f8621757a35b8c9\"") } kotlin { @@ -48,43 +62,27 @@ kotlin { configurations.configureEach { attributes { - @Suppress("UnstableApiUsage") - attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named(gradleApiVersionDimension().components.min().value)) + attribute( + GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, + objects.named(gradleApiVersionDimension().components.min().value), + ) } } dependencies { - api(projects.gradle.gradlePluginApi) api(projects.common.configuration.configurationDeclaration) compileOnly("dev.gradleplugins:gradle-api:${gradleApiVersionDimension().components.min().value}") compileOnly(libs.plugin.kotlin.gradle.api) + compileOnly(libs.plugin.kotlin.gradle) - testImplementation(kotlin("test")) -} + implementation(libs.ci.info) + implementation(libs.jgit) + implementation(libs.mixpanel) -tasks.named("compileKotlin").configure { - val gradleApiVersions = project.gradleApiVersionDimension() - val kotlinToolingVersions = project.kotlinToolingVersionDimension() - - gradleApiVersions.components.forEach { gradleApiVersion -> - kotlinToolingVersions.components.forEach { kotlinToolingVersion -> - val shimConfiguration = configurations.detachedConfiguration( - projects.gradle.gradlePlugin, - ).apply { - attributes { - attribute( - KotlinCompilerVersion.attribute, - objects.named(KotlinCompilerVersion::class.java, kotlinToolingVersion.value), - ) - attribute( - GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, - objects.named(GradlePluginApiVersion::class.java, gradleApiVersion.value), - ) - } - } - dependsOn(shimConfiguration) - } - } + implementation(projects.common.analytics) + implementation(projects.common.util) + + testImplementation(kotlin("test")) } gradlePlugin { @@ -95,7 +93,7 @@ gradlePlugin { create("co.touchlab.skie") { id = "co.touchlab.skie" displayName = "Swift and Kotlin, unified" - implementationClass = "co.touchlab.skie.plugin.SkieLoaderPlugin" + implementationClass = "co.touchlab.skie.plugin.SkieGradlePlugin" version = project.version description = "A Gradle plugin to add Swift into Kotlin/Native framework." diff --git a/SKIE/skie-gradle/plugin-loader/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinCompilerVersion.kt b/SKIE/gradle-plugin/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinCompilerVersion.kt similarity index 100% rename from SKIE/skie-gradle/plugin-loader/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinCompilerVersion.kt rename to SKIE/gradle-plugin/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinCompilerVersion.kt diff --git a/SKIE/skie-gradle/plugin-loader/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinToolingVersion.kt b/SKIE/gradle-plugin/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinToolingVersion.kt similarity index 100% rename from SKIE/skie-gradle/plugin-loader/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinToolingVersion.kt rename to SKIE/gradle-plugin/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinToolingVersion.kt diff --git a/SKIE/skie-gradle/plugin-loader/src/main/kotlin/co/touchlab/skie/plugin/SkieLoaderPlugin.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieGradlePlugin.kt similarity index 52% rename from SKIE/skie-gradle/plugin-loader/src/main/kotlin/co/touchlab/skie/plugin/SkieLoaderPlugin.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieGradlePlugin.kt index 4b09e455c..c1ad564e0 100644 --- a/SKIE/skie-gradle/plugin-loader/src/main/kotlin/co/touchlab/skie/plugin/SkieLoaderPlugin.kt +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieGradlePlugin.kt @@ -1,34 +1,49 @@ package co.touchlab.skie.plugin -import co.touchlab.skie.gradle.KotlinCompilerVersion -import co.touchlab.skie.gradle_plugin_loader.BuildConfig +import co.touchlab.skie.gradle_plugin.BuildConfig +import co.touchlab.skie.plugin.analytics.GradleAnalyticsManager +import co.touchlab.skie.plugin.configuration.CreateSkieConfigurationTask import co.touchlab.skie.plugin.configuration.SkieExtension +import co.touchlab.skie.plugin.configuration.SkieExtension.Companion.createExtension +import co.touchlab.skie.plugin.configuration.skieExtension +import co.touchlab.skie.plugin.coroutines.addDependencyOnSkieRuntime +import co.touchlab.skie.plugin.coroutines.configureMinOsVersionIfNeeded +import co.touchlab.skie.plugin.defaultarguments.disableCachingIfNeeded +import co.touchlab.skie.plugin.dependencies.SkieCompilerPluginDependencyProvider +import co.touchlab.skie.plugin.directory.SkieDirectoriesManager +import co.touchlab.skie.plugin.fatframework.FatFrameworkConfigurator +import co.touchlab.skie.plugin.subplugin.SkieSubPluginManager +import co.touchlab.skie.plugin.switflink.SwiftLinkingConfigurator +import co.touchlab.skie.plugin.util.* +import co.touchlab.skie.util.plugin.SkiePlugin import org.gradle.api.Named import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.attributes.Category -import org.gradle.api.attributes.LibraryElements -import org.gradle.api.attributes.Usage -import org.gradle.api.attributes.plugin.GradlePluginApiVersion import org.gradle.api.model.ObjectFactory -import org.gradle.configurationcache.extensions.serviceOf -import org.gradle.internal.classloader.HashingClassLoaderFactory -import org.gradle.internal.classpath.DefaultClassPath -import org.gradle.util.GradleVersion +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinNativeArtifact import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin +import org.jetbrains.kotlin.gradle.plugin.mpp.Framework +import org.jetbrains.kotlin.gradle.targets.native.tasks.artifact.kotlinArtifactsExtension +import org.jetbrains.kotlin.konan.target.HostManager -@Suppress("unused") -abstract class SkieLoaderPlugin : Plugin { +abstract class SkieGradlePlugin : Plugin { override fun apply(project: Project) { - // We need to register the extension here, so that Gradle knows the type of it in the build script. with(SkieExtension) { project.createExtension() } val kotlinVersion = project.getValidKotlinVersion() ?: return - project.loadSkieGradlePlugin(kotlinVersion) + project.extensions.create("skieInternal", SkieInternalExtension::class.java) + + project.configureSkieGradlePlugin() + + project.afterEvaluate { + project.configureRuntimeVariantFallback() + project.configureSkieCompilerPlugin(kotlinVersion) + } } private fun Project.getValidKotlinVersion(): String? { @@ -89,65 +104,6 @@ abstract class SkieLoaderPlugin : Plugin { private fun Project.getKotlinVersionString(): String? = (project.kotlinGradlePluginVersionOverride ?: project.kotlinGradlePluginVersion ?: project.rootProject.kotlinGradlePluginVersion) - private fun Project.loadSkieGradlePlugin(kotlinVersion: String) { - val gradleVersion = GradleVersion.current().version - logger.info("Resolving SKIE gradle plugin for Kotlin plugin version $kotlinVersion and Gradle version $gradleVersion") - - KotlinCompilerVersion.registerIn(project.dependencies, kotlinVersion) - KotlinCompilerVersion.registerIn(buildscript.dependencies, kotlinVersion) - val skieGradleConfiguration = buildscript.configurations.detachedConfiguration( - buildscript.dependencies.create(BuildConfig.SKIE_GRADLE_PLUGIN), - ).apply { - this.isCanBeConsumed = false - this.isCanBeResolved = true - - exclude( - mapOf( - "group" to "org.jetbrains.kotlin", - ), - ) - - attributes { - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY)) - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) - attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR)) - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) - attribute(KotlinCompilerVersion.attribute, objects.named(kotlinVersion)) - if (GradleVersion.current() >= GradleVersion.version("7.0")) { - attribute( - GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, - objects.named(GradleVersion.current().version), - ) - } - } - } - - skieGradleConfiguration.resolvedConfiguration.rethrowFailure() - - val classLoaderFactory = serviceOf() - val skieGradleClassLoader = classLoaderFactory.createChildClassLoader( - "skieGradleClassLoader", - buildscript.classLoader, - DefaultClassPath.of(skieGradleConfiguration.resolve()), - null, - ) - - val probablySkiePluginClass = skieGradleClassLoader.loadClass("co.touchlab.skie.plugin.SkieGradlePlugin") - if (!Plugin::class.java.isAssignableFrom(probablySkiePluginClass)) { - reportSkieLoaderError( - """ - Loaded class ${probablySkiePluginClass.name} does not implement ${Plugin::class.java.name}! - This is a bug in SKIE - please report it to the SKIE developers. - """.trimIndent(), - ) - return - } - - @Suppress("UNCHECKED_CAST") - val shimPlugin: Class> = probablySkiePluginClass as Class> - plugins.apply(shimPlugin) - } - private val Project.kotlinGradlePluginVersion: String? get() = kotlinGradlePluginVersionFromPlugin() ?: kotlinGradlePluginVersionFromClasspathConfiguration() @@ -176,4 +132,97 @@ abstract class SkieLoaderPlugin : Plugin { private inline fun ObjectFactory.named(name: String): T = named(T::class.java, name) + + private fun Project.configureSkieGradlePlugin() { + SkieSubPluginManager.configureDependenciesForSubPlugins(project) + } + + private fun Project.configureRuntimeVariantFallback() { + if (!skieInternal.runtimeVariantFallback.isPresent) { + val extraPropertiesKey = "skieRuntimeVariantFallback" + skieInternal.runtimeVariantFallback.set( + project.properties[extraPropertiesKey]?.toString().toBoolean() + ) + } + } + + private fun Project.configureSkieCompilerPlugin(kotlinToolingVersion: String) { + if (!isSkieEnabled) { + return + } + + warnOnEmptyFrameworks() + + FatFrameworkConfigurator.configureSkieForFatFrameworks(project) + + kotlinMultiplatformExtension?.appleTargets?.all { + val target = this + binaries.withType().all { + val binary = this + skieInternal.targets.add( + SkieTarget.TargetBinary( + project = project, + target = target, + binary = binary, + ) + ) + } + } + + kotlinArtifactsExtension.artifacts.withType().all { + skieInternal.targets.addAll(skieTargetsOf(this)) + } + + skieInternal.targets.all { + configureSkie(kotlinToolingVersion) + } + } + + private fun SkieTarget.configureSkie(kotlinToolingVersion: String) { + SkieDirectoriesManager.configureCreateSkieBuildDirectoryTask(this) + + GradleAnalyticsManager(project).configureAnalytics(this) + + configureMinOsVersionIfNeeded() + + CreateSkieConfigurationTask.registerTask(this) + + SwiftLinkingConfigurator.configureCustomSwiftLinking(this) + + disableCachingIfNeeded() + + addDependencyOnSkieRuntime(kotlinToolingVersion) + + SkieSubPluginManager.registerSubPlugins(this) + + configureKotlinCompiler(kotlinToolingVersion) + } + + private fun SkieTarget.configureKotlinCompiler(kotlinToolingVersion: String) { + addPluginArgument( + SkiePlugin.id, + SkiePlugin.Options.skieDirectories.subpluginOption(skieDirectories.get()), + ) + + addToCompilerClasspath( + SkieCompilerPluginDependencyProvider.getOrCreateDependencyConfiguration(project, kotlinToolingVersion) + ) + } } + +internal fun Project.warnOnEmptyFrameworks() { + gradle.taskGraph.whenReady { + if (skieInternal.targets.isEmpty()) { + logger.warn("w: No Apple frameworks configured in module ${this@warnOnEmptyFrameworks.path}. Make sure you applied SKIE plugin in the correct module.") + } + } +} + +private val Project.isSkieEnabled: Boolean + get() = project.skieExtension.isEnabled.get() && HostManager.hostIsMac + +internal val Project.kotlinMultiplatformExtension: KotlinMultiplatformExtension? + get() = project.extensions.findByType(KotlinMultiplatformExtension::class.java) + +internal val Project.skieInternal: SkieInternalExtension + get() = project.extensions.getByType(SkieInternalExtension::class.java) diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/SkieInternalExtension.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieInternalExtension.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/SkieInternalExtension.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieInternalExtension.kt diff --git a/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieLoaderPlugin.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieLoaderPlugin.kt new file mode 100644 index 000000000..4457c3a23 --- /dev/null +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/SkieLoaderPlugin.kt @@ -0,0 +1,38 @@ +package co.touchlab.skie.plugin + +import co.touchlab.skie.gradle.KotlinCompilerVersion +import co.touchlab.skie.gradle_plugin.BuildConfig +import co.touchlab.skie.plugin.configuration.SkieExtension +import org.gradle.api.Named +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.attributes.Category +import org.gradle.api.attributes.LibraryElements +import org.gradle.api.attributes.Usage +import org.gradle.api.attributes.plugin.GradlePluginApiVersion +import org.gradle.api.model.ObjectFactory +import org.gradle.configurationcache.extensions.serviceOf +import org.gradle.internal.classloader.HashingClassLoaderFactory +import org.gradle.internal.classpath.DefaultClassPath +import org.gradle.util.GradleVersion +import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin + +// @Suppress("unused") +// abstract class SkieLoaderPlugin : Plugin { +// +// override fun apply(project: Project) { +// // We need to register the extension here, so that Gradle knows the type of it in the build script. +// +// +// project.loadSkieGradlePlugin(kotlinVersion) +// } +// +// +// private fun Project.loadSkieGradlePlugin(kotlinVersion: String) { +// val gradleVersion = GradleVersion.current().version +// logger.info("Resolving SKIE gradle plugin for Kotlin plugin version $kotlinVersion and Gradle version $gradleVersion") +// +// plugins.apply(SkieGradlePlugin::class.java) +// } +// +// } diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/GradleAnalyticsManager.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/GradleAnalyticsManager.kt similarity index 70% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/GradleAnalyticsManager.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/GradleAnalyticsManager.kt index 1e5e22d77..c130b9782 100644 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/GradleAnalyticsManager.kt +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/GradleAnalyticsManager.kt @@ -3,6 +3,7 @@ package co.touchlab.skie.plugin.analytics import co.touchlab.skie.plugin.util.SkieTarget import co.touchlab.skie.plugin.analytics.environment.GradleEnvironmentAnalytics import co.touchlab.skie.plugin.analytics.git.GitAnalytics +import co.touchlab.skie.plugin.analytics.git.getGitRoot import co.touchlab.skie.plugin.analytics.hardware.HardwareAnalytics import co.touchlab.skie.plugin.analytics.performance.GradlePerformanceAnalytics import co.touchlab.skie.plugin.analytics.project.ProjectAnalytics @@ -13,7 +14,9 @@ import co.touchlab.skie.plugin.util.* import co.touchlab.skie.plugin.util.registerSkieTargetBasedTask import org.gradle.api.Project import org.gradle.api.provider.Provider +import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion import java.time.Duration +import java.util.concurrent.atomic.AtomicLong internal class GradleAnalyticsManager( private val project: Project, @@ -39,8 +42,9 @@ internal class GradleAnalyticsManager( dependsOn(target.createSkieBuildDirectoryTask) + val skieExtension = project.skieExtension onlyIf { - val analyticsConfiguration = project.skieExtension.analytics + val analyticsConfiguration = skieExtension.analytics analyticsConfiguration.enabled.get() && !analyticsConfiguration.disableUpload.get() } @@ -55,15 +59,30 @@ internal class GradleAnalyticsManager( target: SkieTarget, analyticsCollectorProvider: Provider, ) { + val gradleVersion = project.provider { project.gradle.gradleVersion } + val kotlinPluginVersion = project.provider { project.getKotlinPluginVersion() } + val gitRoot = project.getGitRoot() + val rootProjectName = project.rootProject.name + val projectPath = project.path + val projectGroup = project.group target.task.configureDoFirstOptimized { analyticsCollectorProvider.get().collectAsync( - GradleEnvironmentAnalytics.Producer(project), + GradleEnvironmentAnalytics.Producer( + gradleVersion = gradleVersion, + kotlinPluginVersion = kotlinPluginVersion, + ), - GitAnalytics.Producer(project), + GitAnalytics.Producer( + gitRoot = gitRoot, + ), HardwareAnalytics.Producer, - ProjectAnalytics.Producer(project), + ProjectAnalytics.Producer( + rootProjectName = rootProjectName, + projectPath = projectPath, + projectGroup = projectGroup, + ), ) } @@ -74,14 +93,13 @@ internal class GradleAnalyticsManager( target: SkieTarget, analyticsCollectorProvider: Provider, ) { - var start: Long = 0 - + val start = AtomicLong(0) target.task.configureDoFirstOptimized { - start = System.currentTimeMillis() + start.set(System.currentTimeMillis()) } target.task.configureDoLastOptimized { - val linkTaskDuration = Duration.ofMillis(System.currentTimeMillis() - start) + val linkTaskDuration = Duration.ofMillis(System.currentTimeMillis() - start.get()) analyticsCollectorProvider.get().collectSynchronously( GradlePerformanceAnalytics.Producer(linkTaskDuration), diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/SkieUploadAnalyticsTask.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/SkieUploadAnalyticsTask.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/SkieUploadAnalyticsTask.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/SkieUploadAnalyticsTask.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/environment/GradleEnvironmentAnalytics.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/environment/GradleEnvironmentAnalytics.kt similarity index 79% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/environment/GradleEnvironmentAnalytics.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/environment/GradleEnvironmentAnalytics.kt index 0139236bc..4f4729109 100644 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/environment/GradleEnvironmentAnalytics.kt +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/environment/GradleEnvironmentAnalytics.kt @@ -6,6 +6,7 @@ import co.touchlab.skie.plugin.util.toPrettyJson import co.touchlab.skie.util.BuildConfig import io.cloudflight.ci.info.CI import org.gradle.api.Project +import org.gradle.api.provider.Provider import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion internal data class GradleEnvironmentAnalytics( @@ -18,7 +19,10 @@ internal data class GradleEnvironmentAnalytics( val timestampInMs: Long, ) { - class Producer(private val project: Project) : AnalyticsProducer { + class Producer( + private val gradleVersion: Provider, + private val kotlinPluginVersion: Provider, + ) : AnalyticsProducer { override val name: String = "gradle-environment" @@ -28,8 +32,8 @@ internal data class GradleEnvironmentAnalytics( GradleEnvironmentAnalytics( jvmVersion = Runtime.version().toString(), skieVersion = BuildConfig.SKIE_VERSION, - gradleVersion = project.gradle.gradleVersion, - kotlinVersion = project.getKotlinPluginVersion(), + gradleVersion = gradleVersion.get(), + kotlinVersion = kotlinPluginVersion.get(), macOSVersion = System.getProperty("os.version"), ci = CI.server?.serverName, timestampInMs = System.currentTimeMillis(), diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/git/GitAnalytics.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/git/GitAnalytics.kt similarity index 81% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/git/GitAnalytics.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/git/GitAnalytics.kt index 89db3e597..c4a330330 100644 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/git/GitAnalytics.kt +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/git/GitAnalytics.kt @@ -7,6 +7,7 @@ import org.eclipse.jgit.api.Git import org.eclipse.jgit.api.ListBranchCommand import org.eclipse.jgit.lib.PersonIdent import org.gradle.api.Project +import org.gradle.api.provider.Provider import java.io.File import java.text.Normalizer @@ -17,14 +18,16 @@ internal data class GitAnalytics( val numberOfTags: Int, ) { - class Producer(private val project: Project) : AnalyticsProducer { + class Producer( + private val gitRoot: Provider, + ) : AnalyticsProducer { override val configurationFlag: SkieConfigurationFlag = SkieConfigurationFlag.Analytics_Git override val name: String = "git" override fun produce(): String { - val git = project.getGit() ?: return """{ "error": "git not found" }""" + val git = gitRoot.get()?.let { Git.open(it) } ?: return """{ "error": "git not found" }""" return GitAnalytics( numberOfContributors = git.log().all().call().map { it.authorIdent.normalizedName }.distinct().size, @@ -39,8 +42,9 @@ internal data class GitAnalytics( private val PersonIdent.normalizedName: String get() = Normalizer.normalize(name, Normalizer.Form.NFC) -private fun Project.getGit(): Git? = - projectDir.findGitRoot()?.let { Git.open(it) } +internal fun Project.getGitRoot(): Provider = provider { + projectDir.findGitRoot() +} private tailrec fun File.findGitRoot(): File? = if (resolve(".git").exists()) this else parentFile?.findGitRoot() diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/hardware/HardwareAnalytics.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/hardware/HardwareAnalytics.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/hardware/HardwareAnalytics.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/hardware/HardwareAnalytics.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/performance/GradlePerformanceAnalytics.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/performance/GradlePerformanceAnalytics.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/performance/GradlePerformanceAnalytics.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/performance/GradlePerformanceAnalytics.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/project/ProjectAnalytics.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/project/ProjectAnalytics.kt similarity index 70% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/project/ProjectAnalytics.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/project/ProjectAnalytics.kt index d6b88b4a7..fb30b354f 100644 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/analytics/project/ProjectAnalytics.kt +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/analytics/project/ProjectAnalytics.kt @@ -10,7 +10,11 @@ internal data class ProjectAnalytics( val projectId: String, ) { - class Producer(private val project: Project) : AnalyticsProducer { + class Producer( + private val rootProjectName: String, + private val projectPath: String, + private val projectGroup: Any, + ) : AnalyticsProducer { override val configurationFlag: SkieConfigurationFlag = SkieConfigurationFlag.Analytics_Project @@ -18,7 +22,7 @@ internal data class ProjectAnalytics( override fun produce(): String = ProjectAnalytics( - projectId = "${project.rootProject.name}${project.path}${project.group}".hashed(), + projectId = "${rootProjectName}${projectPath}${projectGroup}".hashed(), ).toPrettyJson() } } diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/configuration/CreateSkieConfigurationTask.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/CreateSkieConfigurationTask.kt similarity index 95% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/configuration/CreateSkieConfigurationTask.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/CreateSkieConfigurationTask.kt index 9b64e9975..b8fa6b065 100644 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/configuration/CreateSkieConfigurationTask.kt +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/CreateSkieConfigurationTask.kt @@ -44,7 +44,7 @@ internal abstract class CreateSkieConfigurationTask : DefaultTask() { } target.task.configure { - inputs.files(createConfiguration.map { it.outputs }) + // inputs.files(createConfiguration.map { it.outputs }) } } } diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/configuration/Project.skieExtension.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/Project.skieExtension.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/configuration/Project.skieExtension.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/Project.skieExtension.kt diff --git a/SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieAnalyticsConfiguration.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieAnalyticsConfiguration.kt similarity index 100% rename from SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieAnalyticsConfiguration.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieAnalyticsConfiguration.kt diff --git a/SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieBuildConfiguration.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieBuildConfiguration.kt similarity index 100% rename from SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieBuildConfiguration.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieBuildConfiguration.kt diff --git a/SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieDebugConfiguration.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieDebugConfiguration.kt similarity index 100% rename from SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieDebugConfiguration.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieDebugConfiguration.kt diff --git a/SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieExtension.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieExtension.kt similarity index 100% rename from SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieExtension.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieExtension.kt diff --git a/SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieFeatureConfiguration.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieFeatureConfiguration.kt similarity index 100% rename from SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieFeatureConfiguration.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieFeatureConfiguration.kt diff --git a/SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieMigrationConfiguration.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieMigrationConfiguration.kt similarity index 100% rename from SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieMigrationConfiguration.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/SkieMigrationConfiguration.kt diff --git a/SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/util/BooleanProperty.takeIf.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/util/BooleanProperty.takeIf.kt similarity index 100% rename from SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/util/BooleanProperty.takeIf.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/util/BooleanProperty.takeIf.kt diff --git a/SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/util/GradleSkieConfiguration.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/util/GradleSkieConfiguration.kt similarity index 100% rename from SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/util/GradleSkieConfiguration.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/configuration/util/GradleSkieConfiguration.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt similarity index 95% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt index a28eabbd0..a6a0ba34a 100644 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/coroutines/AddDependencyOnSkieRuntime.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractNativeLibrary import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.konan.target.presetName -internal fun SkieTarget.addDependencyOnSkieRuntime() { +internal fun SkieTarget.addDependencyOnSkieRuntime(kotlinToolingVersion: String) { if (!project.isCoroutinesInteropEnabled) { return } @@ -32,7 +32,7 @@ internal fun SkieTarget.addDependencyOnSkieRuntime() { val dependency = if (project.skieInternal.runtimeVariantFallback.get()) { BuildConfig.DEFAULT_RUNTIME_DEPENDENCY } else { - BuildConfig.SPECIFIC_RUNTIME_DEPENDENCY(konanTarget, BuildConfig.KOTLIN_TOOLING_VERSION) + BuildConfig.SPECIFIC_RUNTIME_DEPENDENCY(konanTarget, kotlinToolingVersion) } configurationNames.forEach { configurationName -> project.dependencies.add(configurationName, dependency) diff --git a/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersions.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersions.kt new file mode 100644 index 000000000..bdc30990c --- /dev/null +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersions.kt @@ -0,0 +1,53 @@ +package co.touchlab.skie.plugin.coroutines + +import co.touchlab.skie.plugin.util.SkieTarget +import co.touchlab.skie.plugin.util.getKonanHome +import co.touchlab.skie.plugin.util.registerSkieTargetBasedTask +import co.touchlab.skie.util.version.getMinRequiredOsVersionForSwiftAsync +import co.touchlab.skie.util.version.isLowerVersionThan +import org.gradle.api.provider.Provider +import org.jetbrains.kotlin.konan.properties.resolvablePropertyString +import org.jetbrains.kotlin.konan.target.Distribution +import org.jetbrains.kotlin.konan.target.KonanTarget +import java.util.* + +internal fun SkieTarget.configureMinOsVersionIfNeeded() { + if (!project.isCoroutinesInteropEnabled) { + return + } + + val distribution = distribution.get() + + fun overrideVersion(name: String) { + val currentMinVersion = distribution.properties.targetString(name, konanTarget) + val minRequiredVersion = getMinRequiredOsVersionForSwiftAsync(konanTarget.name) + + if (currentMinVersion == null || currentMinVersion.isLowerVersionThan(minRequiredVersion)) { + addFreeCompilerArgs("$overrideKonanPropertiesKey=${name}.${konanTarget.name}=$minRequiredVersion") + } + } + + overrideVersion("osVersionMin") + overrideVersion("osVersionMinSinceXcode15") +} + + +private val SkieTarget.distribution: Provider + get() = freeCompilerArgs.map { + val overrideKonanProperties = parseOverrideKonanProperties(it) + Distribution(konanHome = project.getKonanHome().absolutePath, propertyOverrides = overrideKonanProperties) + } + +private fun Properties.targetString(name: String, target: KonanTarget): String? = + resolvablePropertyString(name, target.name) + +private const val overrideKonanPropertiesKey = "-Xoverride-konan-properties" + + +private fun parseOverrideKonanProperties( + arguments: List, +): Map = + arguments.associate { it.substringBefore('=') to it.substringAfter('=') } + .filterKeys { it == overrideKonanPropertiesKey } + .flatMap { it.value.split(";") } + .associate { it.substringBefore('=') to it.substringAfter('=') } diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/IsCoroutinesInteropEnabled.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/coroutines/IsCoroutinesInteropEnabled.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/IsCoroutinesInteropEnabled.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/coroutines/IsCoroutinesInteropEnabled.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/defaultarguments/DisableCachingForDefaultArguments.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/defaultarguments/DisableCachingForDefaultArguments.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/defaultarguments/DisableCachingForDefaultArguments.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/defaultarguments/DisableCachingForDefaultArguments.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/dependencies/SkieCompilerPluginDependencyProvider.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/dependencies/SkieCompilerPluginDependencyProvider.kt similarity index 75% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/dependencies/SkieCompilerPluginDependencyProvider.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/dependencies/SkieCompilerPluginDependencyProvider.kt index b966759db..0d3f34d34 100644 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/dependencies/SkieCompilerPluginDependencyProvider.kt +++ b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/dependencies/SkieCompilerPluginDependencyProvider.kt @@ -1,6 +1,7 @@ package co.touchlab.skie.plugin.dependencies import co.touchlab.skie.gradle.KotlinCompilerVersion +import co.touchlab.skie.gradle.KotlinToolingVersion import co.touchlab.skie.gradle_plugin.BuildConfig import co.touchlab.skie.plugin.util.named import org.gradle.api.Project @@ -10,17 +11,17 @@ internal object SkieCompilerPluginDependencyProvider { private const val configurationName = "skieCompilerPlugin" - fun getOrCreateDependencyConfiguration(project: Project): Configuration = + fun getOrCreateDependencyConfiguration(project: Project, kotlinToolingVersion: String): Configuration = project.configurations.findByName(configurationName) - ?: createDependencyConfiguration(project) + ?: createDependencyConfiguration(project, kotlinToolingVersion) - private fun createDependencyConfiguration(project: Project): Configuration { + private fun createDependencyConfiguration(project: Project, kotlinToolingVersion: String): Configuration { val skieCompilerPluginConfiguration = project.configurations.create(configurationName) { isCanBeConsumed = false isCanBeResolved = true attributes { - attribute(KotlinCompilerVersion.attribute, project.objects.named(BuildConfig.KOTLIN_TOOLING_VERSION)) + attribute(KotlinCompilerVersion.attribute, project.objects.named(kotlinToolingVersion)) } exclude( diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/directory/SkieDirectoriesManager.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/directory/SkieDirectoriesManager.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/directory/SkieDirectoriesManager.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/directory/SkieDirectoriesManager.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/fatframework/FatFrameworkConfigurator.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/fatframework/FatFrameworkConfigurator.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/fatframework/FatFrameworkConfigurator.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/fatframework/FatFrameworkConfigurator.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubPluginManager.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubPluginManager.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubPluginManager.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubPluginManager.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubplugin.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubplugin.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubplugin.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/subplugin/SkieSubplugin.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/switflink/SwiftLinkingConfigurator.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/switflink/SwiftLinkingConfigurator.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/switflink/SwiftLinkingConfigurator.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/switflink/SwiftLinkingConfigurator.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/BaseSkieTask.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/BaseSkieTask.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/BaseSkieTask.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/BaseSkieTask.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/DarwinTarget.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/DarwinTarget.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/DarwinTarget.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/DarwinTarget.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/KonanHome.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/KonanHome.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/KonanHome.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/KonanHome.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/KotlinDsl.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/KotlinDsl.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/KotlinDsl.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/KotlinDsl.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/KotlinPluginExtensions.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/KotlinPluginExtensions.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/KotlinPluginExtensions.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/KotlinPluginExtensions.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/SkiePluginOptionToCompilerPluginOption.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/SkiePluginOptionToCompilerPluginOption.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/SkiePluginOptionToCompilerPluginOption.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/SkiePluginOptionToCompilerPluginOption.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/SkieTarget.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/SkieTarget.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/SkieTarget.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/SkieTarget.kt diff --git a/SKIE/skie-gradle/plugin-loader/src/main/kotlin/co/touchlab/skie/plugin/util/StringMap.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/StringMap.kt similarity index 100% rename from SKIE/skie-gradle/plugin-loader/src/main/kotlin/co/touchlab/skie/plugin/util/StringMap.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/StringMap.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/TargetTriple.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/TargetTriple.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/TargetTriple.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/TargetTriple.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/TaskDoOptimized.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/TaskDoOptimized.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/TaskDoOptimized.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/TaskDoOptimized.kt diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/toPrettyJson.kt b/SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/toPrettyJson.kt similarity index 100% rename from SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/util/toPrettyJson.kt rename to SKIE/gradle-plugin/src/main/kotlin/co/touchlab/skie/plugin/util/toPrettyJson.kt diff --git a/SKIE/skie-gradle/plugin-loader/src/test/kotlin/co/touchlab/skie/plugin/SkieGradlePluginTest.kt b/SKIE/gradle-plugin/src/test/kotlin/co/touchlab/skie/plugin/SkieGradlePluginTest.kt similarity index 100% rename from SKIE/skie-gradle/plugin-loader/src/test/kotlin/co/touchlab/skie/plugin/SkieGradlePluginTest.kt rename to SKIE/gradle-plugin/src/test/kotlin/co/touchlab/skie/plugin/SkieGradlePluginTest.kt diff --git a/SKIE/settings.gradle.kts b/SKIE/settings.gradle.kts index 73d81d653..fc2d220cd 100644 --- a/SKIE/settings.gradle.kts +++ b/SKIE/settings.gradle.kts @@ -61,11 +61,7 @@ buildSetup { val `kotlin-plugin` by module } - val gradle by group("skie-gradle") { - val plugin by module - val `plugin-api` by module - val `plugin-loader` by module - } + val `gradle-plugin` by module val `acceptance-tests` by module { val `acceptance-tests-framework` by module("framework") diff --git a/SKIE/skie-gradle/plugin-api/gradle-plugin-api.gradle.kts b/SKIE/skie-gradle/plugin-api/gradle-plugin-api.gradle.kts deleted file mode 100644 index e05ebf641..000000000 --- a/SKIE/skie-gradle/plugin-api/gradle-plugin-api.gradle.kts +++ /dev/null @@ -1,20 +0,0 @@ -plugins { - id("skie.gradle") - id("skie.publishable") -} - -skiePublishing { - name = "SKIE Gradle Plugin API" - description = "API that's implemented by the SKIE Gradle Plugin, used by the loader module." -} - -kotlin { - sourceSets { - val commonMain by getting { - dependencies { - api(projects.common.configuration.configurationDeclaration) - implementation(projects.common.configuration.configurationApi) - } - } - } -} diff --git a/SKIE/skie-gradle/plugin/gradle-plugin.gradle.kts b/SKIE/skie-gradle/plugin/gradle-plugin.gradle.kts deleted file mode 100644 index a3cc79ce2..000000000 --- a/SKIE/skie-gradle/plugin/gradle-plugin.gradle.kts +++ /dev/null @@ -1,94 +0,0 @@ -import co.touchlab.skie.gradle.publish.dependencyName -import co.touchlab.skie.gradle.util.enquoted -import co.touchlab.skie.gradle.version.gradleApiVersion -import co.touchlab.skie.gradle.version.kotlinToolingVersion -import co.touchlab.skie.gradle.version.target.ExpectActualBuildConfigGenerator - -plugins { - id("skie.shim") - id("skie.publishable") - - id("dev.buildconfig") -} - -skiePublishing { - name = "SKIE Gradle Plugin" - description = "Gradle plugin for configuring SKIE compiler plugin.." -} - -kotlin { - sourceSets { - val commonMain by getting { - dependencies { - // TODO: It might be worthwhile to make this compile-time safe, so we don't have to manually check. Or at least a test? - // Whichever dependency is brought in by `gradle-plugin-loader` has to be `compileOnly` as we don't want duplicate classes. - compileOnly(projects.gradle.gradlePluginApi) - compileOnly(projects.common.configuration.configurationDeclaration) - - implementation(libs.ci.info) - implementation(libs.jgit) - implementation(libs.mixpanel) - - implementation(projects.common.analytics) - implementation(projects.common.util) - } - } - } -} - -buildConfig { - generator( - ExpectActualBuildConfigGenerator( - isActualImplementation = false, - internalVisibility = false, - ) - ) - - buildConfigField("String", "KOTLIN_PLUGIN_GROUP", "") - buildConfigField("String", "KOTLIN_PLUGIN_NAME", "") - buildConfigField("String", "KOTLIN_PLUGIN_VERSION", "") - buildConfigField("String", "KOTLIN_TOOLING_VERSION", "") - buildConfigField("String", "GRADLE_API_VERSION", "") - buildConfigField("String", "RUNTIME_DEPENDENCY_GROUP", "") - buildConfigField("String", "RUNTIME_DEPENDENCY_NAME", "") - buildConfigField("String", "RUNTIME_DEPENDENCY_VERSION", "") - buildConfigField("String", "KOTLIN_PLUGIN_ID", "") - buildConfigField("String", "MIXPANEL_PROJECT_TOKEN", "") -} - -multiDimensionTarget.configureSourceSet { sourceSet -> - if (sourceSet.isRoot) { - kotlinSourceSet.kotlin.srcDir( - "src/kgp_common/gradle_common/kotlin-compiler-attribute-local", - ) - } -} - -multiDimensionTarget.configureSourceSet { sourceSet -> - if (!sourceSet.isTarget || compilation.isTest) { return@configureSourceSet } - - buildConfig { - this.sourceSets.named(kotlinSourceSet.name).configure { - generator(ExpectActualBuildConfigGenerator(isActualImplementation = true, internalVisibility = false)) - className.set("BuildConfig") - - val kotlinPlugin = projects.compiler.kotlinPlugin.dependencyProject - - buildConfigField("String", "KOTLIN_PLUGIN_GROUP", kotlinPlugin.group.toString().enquoted()) - buildConfigField("String", "KOTLIN_PLUGIN_NAME", kotlinPlugin.name.enquoted()) - buildConfigField("String", "KOTLIN_PLUGIN_VERSION", kotlinPlugin.version.toString().enquoted()) - buildConfigField("String", "KOTLIN_TOOLING_VERSION", sourceSet.kotlinToolingVersion.value.enquoted()) - buildConfigField("String", "GRADLE_API_VERSION", sourceSet.gradleApiVersion.value.enquoted()) - - val runtime = project.provider { projects.runtime.runtimeKotlin.dependencyProject } - buildConfigField("String", "RUNTIME_DEPENDENCY_GROUP", runtime.map { it.group.toString().enquoted() }) - buildConfigField("String", "RUNTIME_DEPENDENCY_NAME", runtime.map { it.name.enquoted() }) - buildConfigField("String", "RUNTIME_DEPENDENCY_VERSION", runtime.map { it.version.toString().enquoted() }) - - val pluginId: String by properties - buildConfigField("String", "KOTLIN_PLUGIN_ID", "\"$pluginId\"") - - buildConfigField("String", "MIXPANEL_PROJECT_TOKEN", "\"a4c9352b6713103c0f8621757a35b8c9\"") - } - } -} diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin-compiler-attribute-local b/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin-compiler-attribute-local deleted file mode 120000 index 43317c21c..000000000 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin-compiler-attribute-local +++ /dev/null @@ -1 +0,0 @@ -../../../../plugin-loader/src/main/kotlin-compiler-attribute \ No newline at end of file diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/SkieGradlePlugin.kt b/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/SkieGradlePlugin.kt deleted file mode 100644 index 673cf601c..000000000 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/SkieGradlePlugin.kt +++ /dev/null @@ -1,129 +0,0 @@ -package co.touchlab.skie.plugin - -import co.touchlab.skie.plugin.analytics.GradleAnalyticsManager -import co.touchlab.skie.plugin.configuration.CreateSkieConfigurationTask -import co.touchlab.skie.plugin.configuration.skieExtension -import co.touchlab.skie.plugin.coroutines.addDependencyOnSkieRuntime -import co.touchlab.skie.plugin.coroutines.registerConfigureMinOsVersionTaskIfNeeded -import co.touchlab.skie.plugin.defaultarguments.disableCachingIfNeeded -import co.touchlab.skie.plugin.dependencies.SkieCompilerPluginDependencyProvider -import co.touchlab.skie.plugin.directory.SkieDirectoriesManager -import co.touchlab.skie.plugin.fatframework.FatFrameworkConfigurator -import co.touchlab.skie.plugin.subplugin.SkieSubPluginManager -import co.touchlab.skie.plugin.switflink.SwiftLinkingConfigurator -import co.touchlab.skie.plugin.util.* -import co.touchlab.skie.util.plugin.SkiePlugin -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.dsl.KotlinNativeArtifact -import org.jetbrains.kotlin.gradle.plugin.mpp.Framework -import org.jetbrains.kotlin.gradle.targets.native.tasks.artifact.kotlinArtifactsExtension -import org.jetbrains.kotlin.konan.target.HostManager - -abstract class SkieGradlePlugin : Plugin { - - override fun apply(project: Project) { - project.extensions.create("skieInternal", SkieInternalExtension::class.java) - - project.configureSkieGradlePlugin() - - project.afterEvaluate { - project.configureRuntimeVariantFallback() - project.configureSkieCompilerPlugin() - } - } - - private fun Project.configureSkieGradlePlugin() { - SkieSubPluginManager.configureDependenciesForSubPlugins(project) - } - - private fun Project.configureRuntimeVariantFallback() { - if (!skieInternal.runtimeVariantFallback.isPresent) { - val extraPropertiesKey = "skieRuntimeVariantFallback" - skieInternal.runtimeVariantFallback.set( - project.properties[extraPropertiesKey]?.toString().toBoolean() - ) - } - } - - private fun Project.configureSkieCompilerPlugin() { - if (!isSkieEnabled) { - return - } - - warnOnEmptyFrameworks() - - FatFrameworkConfigurator.configureSkieForFatFrameworks(project) - - kotlinMultiplatformExtension?.appleTargets?.all { - val target = this - binaries.withType().all { - val binary = this - skieInternal.targets.add( - SkieTarget.TargetBinary( - project = project, - target = target, - binary = binary, - ) - ) - } - } - - kotlinArtifactsExtension.artifacts.withType().all { - skieInternal.targets.addAll(skieTargetsOf(this)) - } - - skieInternal.targets.all { - configureSkie() - } - } - - private fun SkieTarget.configureSkie() { - SkieDirectoriesManager.configureCreateSkieBuildDirectoryTask(this) - - GradleAnalyticsManager(project).configureAnalytics(this) - - registerConfigureMinOsVersionTaskIfNeeded() - - CreateSkieConfigurationTask.registerTask(this) - - SwiftLinkingConfigurator.configureCustomSwiftLinking(this) - - disableCachingIfNeeded() - - addDependencyOnSkieRuntime() - - SkieSubPluginManager.registerSubPlugins(this) - - configureKotlinCompiler() - } - - private fun SkieTarget.configureKotlinCompiler() { - addPluginArgument( - SkiePlugin.id, - SkiePlugin.Options.skieDirectories.subpluginOption(skieDirectories.get()), - ) - - addToCompilerClasspath( - SkieCompilerPluginDependencyProvider.getOrCreateDependencyConfiguration(project) - ) - } -} - -internal fun Project.warnOnEmptyFrameworks() { - gradle.taskGraph.whenReady { - if (skieInternal.targets.isEmpty()) { - logger.warn("w: No Apple frameworks configured in module ${this@warnOnEmptyFrameworks.path}. Make sure you applied SKIE plugin in the correct module.") - } - } -} - -private val Project.isSkieEnabled: Boolean - get() = project.skieExtension.isEnabled.get() && HostManager.hostIsMac - -internal val Project.kotlinMultiplatformExtension: KotlinMultiplatformExtension? - get() = project.extensions.findByType(KotlinMultiplatformExtension::class.java) - -internal val Project.skieInternal: SkieInternalExtension - get() = project.extensions.getByType(SkieInternalExtension::class.java) diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersionTask.kt b/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersionTask.kt deleted file mode 100644 index c41e86ebd..000000000 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersionTask.kt +++ /dev/null @@ -1,94 +0,0 @@ -package co.touchlab.skie.plugin.coroutines - -import co.touchlab.skie.plugin.util.SkieTarget -import co.touchlab.skie.plugin.util.getKonanHome -import co.touchlab.skie.util.version.getMinRequiredOsVersionForSwiftAsync -import co.touchlab.skie.util.version.isLowerVersionThan -import org.gradle.api.DefaultTask -import org.gradle.api.Project -import org.gradle.api.provider.Property -import org.gradle.api.provider.Provider -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.TaskAction -import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBinary -import org.jetbrains.kotlin.gradle.targets.native.tasks.artifact.KotlinNativeLinkArtifactTask -import org.jetbrains.kotlin.konan.properties.resolvablePropertyString -import org.jetbrains.kotlin.konan.target.Distribution -import org.jetbrains.kotlin.konan.target.KonanTarget -import java.util.Properties - -internal abstract class ConfigureMinOsVersionTask : DefaultTask() { - - @get:Internal - abstract val target: Property - - @TaskAction - fun runTask() { - val target = target.get() - val konanTarget = target.konanTarget - val distribution = target.distribution.get() - - fun overrideVersion(name: String) { - val currentMinVersion = distribution.properties.targetString(name, konanTarget) - val minRequiredVersion = getMinRequiredOsVersionForSwiftAsync(konanTarget.name) - - if (currentMinVersion == null || currentMinVersion.isLowerVersionThan(minRequiredVersion)) { - target.addFreeCompilerArgs("$overrideKonanPropertiesKey=${name}.${konanTarget.name}=$minRequiredVersion") - } - } - - overrideVersion("osVersionMin") - overrideVersion("osVersionMinSinceXcode15") - } - - sealed interface NativeBinaryOrArtifact { - data class Binary(val binary: NativeBinary): NativeBinaryOrArtifact - data class Artifact(val task: KotlinNativeLinkArtifactTask): NativeBinaryOrArtifact - - val project: Project - get() = when (this) { - is Binary -> binary.project - is Artifact -> task.project - } - - val konanTarget: KonanTarget - get() = when (this) { - is Binary -> binary.target.konanTarget - is Artifact -> task.konanTarget - } - - var freeCompilerArgs: List - get() = when (this) { - is Binary -> binary.freeCompilerArgs - is Artifact -> task.toolOptions.freeCompilerArgs.get() - } - set(value) { - when (this) { - is Binary -> binary.freeCompilerArgs = value - is Artifact -> task.toolOptions.freeCompilerArgs.set(value) - } - } - - - } -} - -private val SkieTarget.distribution: Provider - get() = freeCompilerArgs.map { - val overrideKonanProperties = parseOverrideKonanProperties(it) - Distribution(konanHome = project.getKonanHome().absolutePath, propertyOverrides = overrideKonanProperties) - } - -private fun Properties.targetString(name: String, target: KonanTarget): String? = - resolvablePropertyString(name, target.name) - -private const val overrideKonanPropertiesKey = "-Xoverride-konan-properties" - - -private fun parseOverrideKonanProperties( - arguments: List, -): Map = - arguments.associate { it.substringBefore('=') to it.substringAfter('=') } - .filterKeys { it == overrideKonanPropertiesKey } - .flatMap { it.value.split(";") } - .associate { it.substringBefore('=') to it.substringAfter('=') } diff --git a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersions.kt b/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersions.kt deleted file mode 100644 index 94f5b794b..000000000 --- a/SKIE/skie-gradle/plugin/src/kgp_common/gradle_common/kotlin/co/touchlab/skie/plugin/coroutines/ConfigureMinOsVersions.kt +++ /dev/null @@ -1,18 +0,0 @@ -package co.touchlab.skie.plugin.coroutines - -import co.touchlab.skie.plugin.util.SkieTarget -import co.touchlab.skie.plugin.util.registerSkieTargetBasedTask - -internal fun SkieTarget.registerConfigureMinOsVersionTaskIfNeeded() { - if (!project.isCoroutinesInteropEnabled) { - return - } - - val configureMinOsVersionTask = registerSkieTargetBasedTask("configureMinOsVersion") { - this.target.set(this@registerConfigureMinOsVersionTaskIfNeeded) - } - - task.configure { - dependsOn(configureMinOsVersionTask) - } -} diff --git a/build-setup/src/main/kotlin-compiler-attribute-local b/build-setup/src/main/kotlin-compiler-attribute-local index 0d3830773..91bfa0625 120000 --- a/build-setup/src/main/kotlin-compiler-attribute-local +++ b/build-setup/src/main/kotlin-compiler-attribute-local @@ -1 +1 @@ -../../../SKIE/skie-gradle/plugin-loader/src/main/kotlin-compiler-attribute \ No newline at end of file +../../../SKIE/gradle-plugin/src/main/kotlin-compiler-attribute \ No newline at end of file diff --git a/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTests.kt b/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTests.kt index f98494fe3..070aa3bdd 100644 --- a/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTests.kt +++ b/build-setup/src/main/kotlin/co/touchlab/skie/buildsetup/plugins/DevAcceptanceTests.kt @@ -3,6 +3,7 @@ package co.touchlab.skie.buildsetup.plugins import co.touchlab.skie.gradle.KotlinCompilerVersion import co.touchlab.skie.gradle.KotlinToolingVersion import co.touchlab.skie.gradle.architecture.MacOsCpuArchitecture +import co.touchlab.skie.gradle.architecture.currentMacOsCpuArchitecture import co.touchlab.skie.gradle.util.enquoted import co.touchlab.skie.gradle.util.withKotlinNativeCompilerEmbeddableDependency import co.touchlab.skie.gradle.version.AcceptanceTestsComponent @@ -237,7 +238,7 @@ abstract class DevAcceptanceTests : Plugin { attributes { attribute(KotlinCompilerVersion.attribute, objects.named(target.kotlinToolingVersion.value)) attribute(KotlinPlatformType.attribute, KotlinPlatformType.native) - attribute(KotlinNativeTarget.konanTargetAttribute, MacOsCpuArchitecture.getCurrent().konanTarget) + attributeProvider(KotlinNativeTarget.konanTargetAttribute, currentMacOsCpuArchitecture.map { it.konanTarget }) attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, KotlinUsages.KOTLIN_API)) } } diff --git a/build-setup/src/main/kotlin/co/touchlab/skie/gradle/architecture/MacOsCpuArchitecture.kt b/build-setup/src/main/kotlin/co/touchlab/skie/gradle/architecture/MacOsCpuArchitecture.kt index 68d35c8b0..ee64531a8 100644 --- a/build-setup/src/main/kotlin/co/touchlab/skie/gradle/architecture/MacOsCpuArchitecture.kt +++ b/build-setup/src/main/kotlin/co/touchlab/skie/gradle/architecture/MacOsCpuArchitecture.kt @@ -1,17 +1,38 @@ package co.touchlab.skie.gradle.architecture import org.codehaus.groovy.runtime.ProcessGroovyMethods +import org.gradle.api.Project +import org.gradle.api.provider.Provider +import org.gradle.api.provider.ValueSource +import org.gradle.api.provider.ValueSourceParameters +import org.gradle.kotlin.dsl.of +import org.gradle.process.ExecOperations +import java.io.ByteArrayOutputStream +import java.nio.charset.Charset +import javax.inject.Inject enum class MacOsCpuArchitecture(val systemName: String, val kotlinGradleName: String, val konanTarget: String) { Arm64("arm64", "macosArm64", "macos_arm64"), X64("x86_64", "macosX64", "macos_x64"); +} - companion object { +val Project.currentMacOsCpuArchitecture: Provider + get() = providers.of(MacOsCpuArchitectureValueSource::class) {} - fun getCurrent(): MacOsCpuArchitecture { - val systemName = "uname -m".let(ProcessGroovyMethods::execute).let(ProcessGroovyMethods::getText).trim() +abstract class MacOsCpuArchitectureValueSource : ValueSource { + @get:Inject + abstract val execOperations: ExecOperations - return values().firstOrNull { it.systemName == systemName } ?: error("Unsupported architecture: $systemName") + override fun obtain(): MacOsCpuArchitecture { + val output = ByteArrayOutputStream() + execOperations.exec { + commandLine("uname", "-m") + standardOutput = output } + + val systemName = String(output.toByteArray(), Charset.defaultCharset()).trim() + return MacOsCpuArchitecture.values().firstOrNull { + it.systemName == systemName + } ?: error("Unsupported architecture: $systemName") } } diff --git a/build-setup/src/main/kotlin/co/touchlab/skie/gradle/util/KotlinNativeCompilerHome.kt b/build-setup/src/main/kotlin/co/touchlab/skie/gradle/util/KotlinNativeCompilerHome.kt index 89da4cc92..3105e73a8 100644 --- a/build-setup/src/main/kotlin/co/touchlab/skie/gradle/util/KotlinNativeCompilerHome.kt +++ b/build-setup/src/main/kotlin/co/touchlab/skie/gradle/util/KotlinNativeCompilerHome.kt @@ -6,7 +6,6 @@ import org.gradle.api.artifacts.Dependency import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.provideDelegate import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader -import org.jetbrains.kotlin.konan.CompilerVersion import java.io.File private data class BackupProperty( @@ -21,7 +20,7 @@ private object KotlinNativeVersionPropertyName { } fun Project.kotlinNativeCompilerHome(kotlinVersion: KotlinToolingVersion): File { - return NativeCompilerDownloader(project, CompilerVersion.fromString(kotlinVersion.toString())) + return NativeCompilerDownloader(project, kotlinVersion.toString()) .also { downloader -> val backupProperty = backupProperty(KotlinNativeVersionPropertyName.main) ?: backupProperty(KotlinNativeVersionPropertyName.deprecated) extra.set(KotlinNativeVersionPropertyName.main, kotlinVersion.toString()) diff --git a/common-gradle/gradle/wrapper/gradle-wrapper.properties b/common-gradle/gradle/wrapper/gradle-wrapper.properties index a1f2792d7..510e4efae 100644 --- a/common-gradle/gradle/wrapper/gradle-wrapper.properties +++ b/common-gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/dev-support/build.gradle.kts b/dev-support/build.gradle.kts index 635346d03..2b0c63f28 100644 --- a/dev-support/build.gradle.kts +++ b/dev-support/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("dev.root") - kotlin("multiplatform") version "1.9.20" apply false + kotlin("multiplatform") version "1.9.22" apply false } buildscript { diff --git a/dev-support/pure-compiler/framework/build.gradle.kts b/dev-support/pure-compiler/framework/build.gradle.kts index 5dba25c45..0e0d5320d 100644 --- a/dev-support/pure-compiler/framework/build.gradle.kts +++ b/dev-support/pure-compiler/framework/build.gradle.kts @@ -1,6 +1,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink import co.touchlab.skie.gradle.architecture.MacOsCpuArchitecture +import co.touchlab.skie.gradle.architecture.currentMacOsCpuArchitecture plugins { id("dev.multiplatform") @@ -22,7 +23,7 @@ kotlin { baseName = "Kotlin" freeCompilerArgs = freeCompilerArgs + listOf("-Xbinary=bundleId=Kotlin") - export(projects.devSupport.pureCompiler.dependency) + export(projects.devSupport.pureCompilerDependency) exportedLibraries.forEach { export(it) @@ -36,7 +37,7 @@ kotlin { implementation(libs.kotlinx.coroutines.core) implementation("co.touchlab.skie:configuration-annotations") - api(projects.devSupport.pureCompiler.dependency) + api(projects.devSupport.pureCompilerDependency) exportedLibraries.forEach { api(it) @@ -72,7 +73,7 @@ tasks.withType().configureEach { tasks.register("dependenciesForExport") { doLast { - val configuration = configurations.getByName(MacOsCpuArchitecture.getCurrent().kotlinGradleName + "Api") + val configuration = configurations.getByName(project.currentMacOsCpuArchitecture.get().kotlinGradleName + "Api") val dependencies = configuration.incoming.resolutionResult.allComponents.map { it.toString() } val externalDependencies = dependencies.filterNot { it.startsWith("project :") } diff --git a/dev-support/settings.gradle.kts b/dev-support/settings.gradle.kts index c82db4a1a..90e35a996 100644 --- a/dev-support/settings.gradle.kts +++ b/dev-support/settings.gradle.kts @@ -12,7 +12,18 @@ plugins { id("dev.settings") } -include( +fun modules(vararg names: String) { + names.forEach { name -> + val path = name.drop(1).split(":") + val joinedName = path.joinToString("-", prefix = ":") + include(joinedName) + project(joinedName).projectDir = path.fold(rootDir) { acc, directoryName -> + acc.resolve(directoryName) + } + } +} + +modules( ":skie:mac", ":skie:mac:framework", ":skie:mac:dependency", diff --git a/dev-support/skie/ios/framework/build.gradle.kts b/dev-support/skie/ios/framework/build.gradle.kts index 6fb78a70a..63e4a2ee7 100644 --- a/dev-support/skie/ios/framework/build.gradle.kts +++ b/dev-support/skie/ios/framework/build.gradle.kts @@ -49,7 +49,7 @@ kotlin { baseName = "Kotlin" freeCompilerArgs = freeCompilerArgs + listOf("-Xbinary=bundleId=Kotlin") - export(projects.devSupport.skie.ios.dependency) + export(projects.devSupport.skieIosDependency) exportedLibraries.forEach { export(it) @@ -63,7 +63,7 @@ kotlin { implementation(libs.kotlinx.coroutines.core) implementation("co.touchlab.skie:configuration-annotations") - api(projects.devSupport.skie.ios.dependency) + api(projects.devSupport.skieIosDependency) exportedLibraries.forEach { api(it) diff --git a/dev-support/skie/mac/framework/build.gradle.kts b/dev-support/skie/mac/framework/build.gradle.kts index 4c7a305bf..b9a7a625d 100644 --- a/dev-support/skie/mac/framework/build.gradle.kts +++ b/dev-support/skie/mac/framework/build.gradle.kts @@ -3,6 +3,7 @@ import co.touchlab.skie.configuration.DefaultArgumentInterop import co.touchlab.skie.configuration.ExperimentalFeatures import co.touchlab.skie.configuration.SealedInterop import co.touchlab.skie.gradle.architecture.MacOsCpuArchitecture +import co.touchlab.skie.gradle.architecture.currentMacOsCpuArchitecture import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import java.util.Locale @@ -57,7 +58,7 @@ kotlin { baseName = "Kotlin" freeCompilerArgs = freeCompilerArgs + listOf("-Xbinary=bundleId=Kotlin") - export(projects.skie.mac.dependency) + export(projects.skieMacDependency) exportedLibraries.forEach { export(it) @@ -71,7 +72,7 @@ kotlin { implementation(libs.kotlinx.coroutines.core) implementation("co.touchlab.skie:configuration-annotations") - api(projects.skie.mac.dependency) + api(projects.skieMacDependency) exportedLibraries.forEach { api(it) @@ -94,7 +95,7 @@ kotlin { tasks.register("dependenciesForExport") { doLast { - val configuration = configurations.getByName(MacOsCpuArchitecture.getCurrent().kotlinGradleName + "Api") + val configuration = configurations.getByName(currentMacOsCpuArchitecture.get().kotlinGradleName + "Api") val dependencies = configuration.incoming.resolutionResult.allComponents.map { it.toString() } val externalDependencies = dependencies.filterNot { it.startsWith("project :") } diff --git a/dev-support/skie/mac/swift/build.gradle.kts b/dev-support/skie/mac/swift/build.gradle.kts index df1517624..4e6552919 100644 --- a/dev-support/skie/mac/swift/build.gradle.kts +++ b/dev-support/skie/mac/swift/build.gradle.kts @@ -1,7 +1,8 @@ import co.touchlab.skie.gradle.architecture.MacOsCpuArchitecture +import co.touchlab.skie.gradle.architecture.currentMacOsCpuArchitecture import org.gradle.configurationcache.extensions.capitalized -val architecture = MacOsCpuArchitecture.getCurrent() +val architecture = currentMacOsCpuArchitecture.get() val createSwiftMain by tasks.registering { val mainFile = layout.projectDirectory.file("main.swift")