diff options
9 files changed, 14 insertions, 30 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 46f043f3..360178e9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,18 +24,16 @@ subprojects { disabledRules.set(setOf("no-wildcard-imports")) } - val compilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn") - tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { + tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { // JVM only kotlinOptions.jvmTarget = "1.8" - kotlinOptions.freeCompilerArgs += compilerArgs } - tasks.withType<org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile> { - kotlinOptions.freeCompilerArgs = compilerArgs - } - - tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompileCommon> { - kotlinOptions.freeCompilerArgs = compilerArgs + // this doesn't cover multiplatform projects, see sw-common-model's build.gradle.kts + tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> { + kotlinOptions.freeCompilerArgs += listOf( + "-Xopt-in=kotlin.RequiresOptIn", + "-Xopt-in=kotlin.time.ExperimentalTime" + ) } tasks.withType<AbstractTestTask> { diff --git a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt index 39759fd0..86ade852 100644 --- a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt +++ b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt @@ -11,7 +11,6 @@ import org.luxons.sevenwonders.model.resources.noTransactions import org.luxons.sevenwonders.model.wonders.AssignedWonder import org.slf4j.LoggerFactory import kotlin.random.Random -import kotlin.time.ExperimentalTime private val logger = LoggerFactory.getLogger(SevenWondersBot::class.java) @@ -32,7 +31,6 @@ suspend fun SevenWondersClient.connectBots( config: BotConfig = BotConfig(), ): List<SevenWondersBot> = names.map { connectBot(serverUrl, it, config) } -@OptIn(ExperimentalTime::class) class SevenWondersBot( private val player: ConnectedPlayer, private val config: BotConfig = BotConfig(), @@ -121,7 +119,6 @@ private suspend fun SevenWondersSession.autoPlayTurn(turn: PlayerTurnInfo) { } } -@OptIn(ExperimentalStdlibApi::class) private fun createPlayCardMove(turnInfo: PlayerTurnInfo): PlayerMove { val hand = turnInfo.hand ?: error("Cannot choose move, no hand in current turn info!") val wonderBuildability = turnInfo.wonderBuildability diff --git a/sw-common-model/build.gradle.kts b/sw-common-model/build.gradle.kts index dd7b5327..dc95d608 100644 --- a/sw-common-model/build.gradle.kts +++ b/sw-common-model/build.gradle.kts @@ -11,6 +11,10 @@ kotlin { browser() // necessary for local dependency from JS UI module } sourceSets { + all { + languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn") + languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime") + } val commonMain by getting { dependencies { api("org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlinSerialization") diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt index 48b26aa4..7b9a3d60 100644 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt @@ -4,7 +4,6 @@ import kotlinx.serialization.Serializable import org.luxons.sevenwonders.model.PlayerMove import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.wonders.AssignedWonder -import kotlin.time.ExperimentalTime import kotlin.time.hours /** @@ -103,7 +102,6 @@ class UpdateSettingsAction( * The action to add a bot to the game. Can only be called in the lobby by the owner of the game. */ @Serializable -@OptIn(ExperimentalTime::class) class AddBotAction( /** * The display name for the bot to add. diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt index 4acdc3be..796dc719 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt @@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RestController import java.security.Principal -import kotlin.time.ExperimentalTime import kotlin.time.minutes /** @@ -22,7 +21,6 @@ import kotlin.time.minutes class AutoGameController( @Value("\${server.port}") private val serverPort: String, ) { - @OptIn(ExperimentalTime::class) @PostMapping("/autoGame") suspend fun autoGame(@RequestBody action: AutoGameAction, principal: Principal): AutoGameResult { logger.info("Starting auto-game {}", action.gameName) diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt index 5c2d4dd6..2edf7fee 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt @@ -25,7 +25,6 @@ import org.springframework.messaging.simp.SimpMessagingTemplate import org.springframework.stereotype.Controller import org.springframework.validation.annotation.Validated import java.security.Principal -import kotlin.time.ExperimentalTime import kotlin.time.milliseconds /** @@ -149,7 +148,6 @@ class LobbyController( template.convertAndSend("/topic/games", GameListEvent.CreateOrUpdate(lobbyDto).wrap()) } - @OptIn(ExperimentalTime::class) @MessageMapping("/lobby/addBot") fun addBot(@Validated action: AddBotAction, principal: Principal) { val lobby = principal.player.ownedLobby diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt index 7c830140..51daf0c8 100644 --- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt +++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.server -import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.produceIn import kotlinx.coroutines.launch @@ -21,7 +20,6 @@ import org.springframework.boot.web.server.LocalServerPort import org.springframework.test.context.junit4.SpringRunner import kotlin.test.* -@OptIn(FlowPreview::class) @RunWith(SpringRunner::class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) class SevenWondersTest { diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt index 0a2d7fa5..cb15460d 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt @@ -1,19 +1,14 @@ package org.luxons.sevenwonders.ui.redux.sagas -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.Job +import kotlinx.coroutines.* import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.launch import redux.Middleware import redux.MiddlewareApi import redux.RAction -@OptIn(ExperimentalCoroutinesApi::class) +@OptIn(ExperimentalCoroutinesApi::class) // for BroadcastChannel class SagaManager<S, A : RAction, R>( private val monitor: ((A) -> Unit)? = null, ) { @@ -62,7 +57,7 @@ class SagaManager<S, A : RAction, R>( } } -@OptIn(FlowPreview::class, ExperimentalCoroutinesApi::class) +@OptIn(ExperimentalCoroutinesApi::class) // for BroadcastChannel class SagaContext<S, A : RAction, R>( private val reduxApi: MiddlewareApi<S, A, R>, private val actions: BroadcastChannel<A>, diff --git a/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFrameworkTest.kt b/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFrameworkTest.kt index f580fc93..044ba1ef 100644 --- a/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFrameworkTest.kt +++ b/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFrameworkTest.kt @@ -1,6 +1,5 @@ package org.luxons.sevenwonders.ui.redux.sagas -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.promise @@ -39,7 +38,6 @@ private data class TestRedux( val sagas: SagaManager<State, RAction, WrapperAction>, ) -@OptIn(ExperimentalCoroutinesApi::class) class SagaContextTest { @Test |