Skip to content

Commit

Permalink
Add Atomicfu feature
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierSegoviaCordoba committed Sep 1, 2024
1 parent f2a0565 commit a49d60c
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Added

- Atomicfu feature

### Changed

- Kotlin Multiplatform to use `applyDefaultHierarchyTemplate()`
Expand Down
1 change: 1 addition & 0 deletions hubdle-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ hubdle {
api(hubdle.plugins.jetbrains.compose.artifact)
api(hubdle.plugins.jetbrains.dokka.artifact)
api(hubdle.plugins.jetbrains.intellij.artifact)
api(hubdle.plugins.jetbrains.kotlin.plugin.atomicfu.artifact)
api(hubdle.plugins.jetbrains.kotlin.plugin.compose.artifact)
api(hubdle.plugins.jetbrains.kotlin.plugin.serialization.artifact)
api(hubdle.plugins.jetbrains.kotlinx.binary.compatibility.validator.artifact)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.javiersc.hubdle.project.extensions.kotlin.android.library.HubdleKotli
import com.javiersc.hubdle.project.extensions.kotlin.android.library.features.HubdleKotlinAndroidLibraryFeaturesExtension
import com.javiersc.hubdle.project.extensions.kotlin.compiler.options.HubdleKotlinCompilerOptionsExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.HubdleKotlinFeaturesExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinAtomicfuFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinComposeFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinContextReceiversFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinCoroutinesFeatureExtension
Expand Down Expand Up @@ -74,6 +75,7 @@ internal fun HubdleState.createHubdleKotlinExtensions() {
private fun HubdleState.createKotlinFeatureExtensions() {
createExtension<HubdleKotlinFeaturesExtension> {
createExtension<HubdleKotlinCompilerPluginFeatureExtension>()
createExtension<HubdleKotlinAtomicfuFeatureExtension>()
createExtension<HubdleKotlinComposeFeatureExtension>()
createExtension<HubdleKotlinContextReceiversFeatureExtension>()
createExtension<HubdleKotlinCoroutinesFeatureExtension>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.javiersc.hubdle.project.extensions.HubdleDslMarker
import com.javiersc.hubdle.project.extensions._internal.getHubdleExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleEnableableExtension
import com.javiersc.hubdle.project.extensions.kotlin.android.application.hubdleAndroidApplication
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinAtomicfuDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinComposeDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinCoroutinesDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinExtendedStdlibDelegateFeatureExtension
Expand Down Expand Up @@ -33,6 +34,7 @@ constructor(project: Project) :
}

public interface HubdleKotlinAndroidApplicationDelegateFeaturesExtension :
HubdleKotlinAtomicfuDelegateFeatureExtension,
HubdleKotlinComposeDelegateFeatureExtension,
HubdleKotlinCoroutinesDelegateFeatureExtension,
HubdleKotlinExtendedStdlibDelegateFeatureExtension,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.javiersc.hubdle.project.extensions._internal.getHubdleExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleEnableableExtension
import com.javiersc.hubdle.project.extensions.kotlin.android.application.hubdleAndroidApplication
import com.javiersc.hubdle.project.extensions.kotlin.android.library.HubdleKotlinAndroidLibraryExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinAtomicfuDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinComposeDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinCoroutinesDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinExtendedStdlibDelegateFeatureExtension
Expand Down Expand Up @@ -34,6 +35,7 @@ constructor(project: Project) :
}

public interface HubdleKotlinAndroidLibraryDelegateFeaturesExtension :
HubdleKotlinAtomicfuDelegateFeatureExtension,
HubdleKotlinComposeDelegateFeatureExtension,
HubdleKotlinCoroutinesDelegateFeatureExtension,
HubdleKotlinExtendedStdlibDelegateFeatureExtension,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.javiersc.hubdle.project.extensions.kotlin.features.shared

import com.javiersc.hubdle.project.extensions.HubdleDslMarker
import com.javiersc.hubdle.project.extensions._internal.ApplicablePlugin.Scope
import com.javiersc.hubdle.project.extensions._internal.fallbackAction
import com.javiersc.hubdle.project.extensions._internal.getHubdleExtension
import com.javiersc.hubdle.project.extensions.apis.BaseHubdleExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleConfigurableExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleEnableableExtension
import com.javiersc.hubdle.project.extensions.apis.enableAndExecute
import com.javiersc.hubdle.project.extensions.kotlin.hubdleKotlinAny
import com.javiersc.hubdle.project.extensions.shared.PluginId
import javax.inject.Inject
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.provider.Property
import org.jetbrains.kotlinx.atomicfu.gradle.AtomicfuKotlinGradleSubplugin.AtomicfuKotlinGradleExtension

public open class HubdleKotlinAtomicfuFeatureExtension @Inject constructor(project: Project) :
HubdleConfigurableExtension(project) {

override val isEnabled: Property<Boolean> = property { false }

override val oneOfExtensions: Set<HubdleEnableableExtension>
get() = hubdleKotlinAny

public val isJsIrTransformationEnabled: Property<Boolean> = property { false }

public val isJvmIrTransformationEnabled: Property<Boolean> = property { false }

public val isNativeIrTransformationEnabled: Property<Boolean> = property { false }

@HubdleDslMarker
public fun jsIrTransformation(enable: Boolean = true) {
isJsIrTransformationEnabled.set(enable)
}

@HubdleDslMarker
public fun jvmIrTransformation(enable: Boolean = true) {
isJvmIrTransformationEnabled.set(enable)
}

@HubdleDslMarker
public fun nativeIrTransformation(enable: Boolean = true) {
isNativeIrTransformationEnabled.set(enable)
}

@HubdleDslMarker
public fun atomicfu(action: Action<AtomicfuKotlinGradleExtension> = Action {}): Unit =
fallbackAction(action)

override fun Project.defaultConfiguration() {
applicablePlugin(scope = Scope.CurrentProject, pluginId = PluginId.JetbrainsKotlinAtomicfu)
lazyConfigurable {
configure<AtomicfuKotlinGradleExtension> {
isJsIrTransformationEnabled =
this@HubdleKotlinAtomicfuFeatureExtension.isJsIrTransformationEnabled.get()
isJvmIrTransformationEnabled =
this@HubdleKotlinAtomicfuFeatureExtension.isJvmIrTransformationEnabled.get()
isNativeIrTransformationEnabled =
this@HubdleKotlinAtomicfuFeatureExtension.isNativeIrTransformationEnabled.get()
}
}
}
}

public interface HubdleKotlinAtomicfuDelegateFeatureExtension : BaseHubdleExtension {

public val atomicfu: HubdleKotlinAtomicfuFeatureExtension
get() = project.getHubdleExtension()

@HubdleDslMarker
public fun atomicfu(action: Action<HubdleKotlinAtomicfuFeatureExtension> = Action {}) {
atomicfu.enableAndExecute(action)
}
}

internal val HubdleEnableableExtension.hubdleAtomicfuFeature: HubdleKotlinAtomicfuFeatureExtension
get() = getHubdleExtension()

internal val Project.hubdleAtomicfuFeature: HubdleKotlinAtomicfuFeatureExtension
get() = getHubdleExtension()
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.javiersc.hubdle.project.extensions.kotlin.jvm.features
import com.javiersc.hubdle.project.extensions.HubdleDslMarker
import com.javiersc.hubdle.project.extensions._internal.getHubdleExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleEnableableExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinAtomicfuDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinComposeDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinContextReceiversDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinCoroutinesDelegateFeatureExtension
Expand Down Expand Up @@ -35,6 +36,7 @@ public open class HubdleKotlinJvmFeaturesExtension @Inject constructor(project:
}

public interface HubdleKotlinJvmDelegateFeaturesExtension :
HubdleKotlinAtomicfuDelegateFeatureExtension,
HubdleGradleDelegateFeatureExtension,
HubdleIntellijDelegateFeatureExtension,
HubdleJavaApplicationDelegateFeatureExtension,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.javiersc.hubdle.project.extensions.kotlin.multiplatform.features
import com.javiersc.hubdle.project.extensions.HubdleDslMarker
import com.javiersc.hubdle.project.extensions._internal.getHubdleExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleEnableableExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinAtomicfuDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinComposeDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinCoroutinesDelegateFeatureExtension
import com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinExtendedStdlibDelegateFeatureExtension
Expand Down Expand Up @@ -32,6 +33,7 @@ public open class HubdleKotlinMultiplatformFeaturesExtension @Inject constructor

public interface HubdleKotlinMultiplatformDelegateFeaturesExtension :
HubdleKotlinMultiplatformMinimumTargetPerOsDelegateFeatureExtension,
HubdleKotlinAtomicfuDelegateFeatureExtension,
HubdleKotlinComposeDelegateFeatureExtension,
HubdleKotlinCoroutinesDelegateFeatureExtension,
HubdleKotlinExtendedStdlibDelegateFeatureExtension,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum class PluginId(public val id: String) {
JetbrainsKotlinJvm("org.jetbrains.kotlin.jvm"),
JetbrainsKotlinMultiplatform("org.jetbrains.kotlin.multiplatform"),
JetbrainsKotlinPluginCompose("org.jetbrains.kotlin.plugin.compose"),
JetbrainsKotlinAtomicfu("org.jetbrains.kotlin.plugin.atomicfu"),
JetbrainsKotlinPluginSerialization("org.jetbrains.kotlin.plugin.serialization"),
JetbrainsKotlinxBinaryCompatibilityValidator(KotlinBinaryCompatibilityValidator),
JetbrainsKotlinxKover("org.jetbrains.kotlinx.kover"),
Expand Down

0 comments on commit a49d60c

Please sign in to comment.