[Gradle] Made kotlin native configuration init only once.
`maybeCreateResolvable` with `also` each time configures configuration. But we cannot add new dependencies after the configuration is resolved. Thus, it is more correct to add init block for a case when it is a newly created configuration. ^KTIJ-28742 Fixed
This commit is contained in:
committed by
Space Team
parent
58e1c4c6ac
commit
af872b5692
+4
-4
@@ -60,12 +60,12 @@ internal object KotlinNativeBundleArtifactFormat {
|
|||||||
|
|
||||||
internal fun addKotlinNativeBundleConfiguration(project: Project) {
|
internal fun addKotlinNativeBundleConfiguration(project: Project) {
|
||||||
project.configurations
|
project.configurations
|
||||||
.maybeCreateResolvable(KOTLIN_NATIVE_BUNDLE_CONFIGURATION_NAME).also { configuration ->
|
.maybeCreateResolvable(KOTLIN_NATIVE_BUNDLE_CONFIGURATION_NAME) {
|
||||||
configuration.defaultDependencies {
|
defaultDependencies {
|
||||||
it.add(project.dependencies.create(NativeCompilerDownloader.getCompilerDependencyNotation(project)))
|
it.add(project.dependencies.create(NativeCompilerDownloader.getCompilerDependencyNotation(project)))
|
||||||
}
|
}
|
||||||
if (!configuration.attributes.contains(attribute)) {
|
if (!attributes.contains(attribute)) {
|
||||||
configuration.attributes.setAttribute(attribute, KotlinNativeBundleArtifactsTypes.DIRECTORY)
|
attributes.setAttribute(attribute, KotlinNativeBundleArtifactsTypes.DIRECTORY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-5
@@ -20,7 +20,10 @@ const val RUNTIME = "runtime"
|
|||||||
internal const val INTRANSITIVE = "intransitive"
|
internal const val INTRANSITIVE = "intransitive"
|
||||||
private val gradleVersionWithNewApi = GradleVersion.version("8.4")
|
private val gradleVersionWithNewApi = GradleVersion.version("8.4")
|
||||||
|
|
||||||
internal fun ConfigurationContainer.createResolvable(name: String): Configuration = create(name).apply {
|
internal fun ConfigurationContainer.createResolvable(
|
||||||
|
name: String,
|
||||||
|
configurationOnCreate: Configuration.() -> Unit = {},
|
||||||
|
): Configuration = create(name, configurationOnCreate).apply {
|
||||||
isCanBeConsumed = false
|
isCanBeConsumed = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,8 +45,11 @@ internal fun ConfigurationContainer.findResolvable(name: String): Configuration?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun ConfigurationContainer.maybeCreateResolvable(name: String): Configuration =
|
internal fun ConfigurationContainer.maybeCreateResolvable(
|
||||||
findResolvable(name) ?: createResolvable(name)
|
name: String,
|
||||||
|
configurationOnCreate: Configuration.() -> Unit = {},
|
||||||
|
): Configuration =
|
||||||
|
findResolvable(name) ?: createResolvable(name, configurationOnCreate)
|
||||||
|
|
||||||
internal fun ConfigurationContainer.detachedResolvable(vararg dependencies: Dependency) =
|
internal fun ConfigurationContainer.detachedResolvable(vararg dependencies: Dependency) =
|
||||||
detachedConfiguration(*dependencies).apply {
|
detachedConfiguration(*dependencies).apply {
|
||||||
@@ -67,7 +73,7 @@ internal fun ConfigurationContainer.maybeCreateConsumable(name: String): Configu
|
|||||||
|
|
||||||
internal fun ConfigurationContainer.createDependencyScope(
|
internal fun ConfigurationContainer.createDependencyScope(
|
||||||
name: String,
|
name: String,
|
||||||
configuration: Configuration.() -> Unit = {}
|
configuration: Configuration.() -> Unit = {},
|
||||||
): NamedDomainObjectProvider<out Configuration> =
|
): NamedDomainObjectProvider<out Configuration> =
|
||||||
if (GradleVersion.current() >= gradleVersionWithNewApi) {
|
if (GradleVersion.current() >= gradleVersionWithNewApi) {
|
||||||
dependencyScope(name, configuration)
|
dependencyScope(name, configuration)
|
||||||
@@ -91,5 +97,5 @@ internal fun ConfigurationContainer.findDependencyScope(name: String): Configura
|
|||||||
|
|
||||||
internal fun ConfigurationContainer.maybeCreateDependencyScope(
|
internal fun ConfigurationContainer.maybeCreateDependencyScope(
|
||||||
name: String,
|
name: String,
|
||||||
configurationOnCreate: Configuration.() -> Unit = {}
|
configurationOnCreate: Configuration.() -> Unit = {},
|
||||||
): Configuration = findDependencyScope(name) ?: createDependencyScope(name, configurationOnCreate).get()
|
): Configuration = findDependencyScope(name) ?: createDependencyScope(name, configurationOnCreate).get()
|
||||||
|
|||||||
Reference in New Issue
Block a user