File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -161,19 +161,19 @@ tasks.withType<Detekt>().configureEach detekt@{
161
161
}
162
162
163
163
tasks.withType<KotlinCompile >().configureEach {
164
- val hasSerialization = plugins.hasPlugin(libs.plugins.kotlinSerialization.get().pluginId)
165
-
166
- val customCompilerArgs = buildList {
167
- add( " -opt-in= kotlin.contracts.ExperimentalContracts" )
168
- add( " -opt-in= kotlin.io.encoding.ExperimentalEncodingApi" )
169
- add( " -opt-in= kotlin.io.path.ExperimentalPathApi" )
170
- add( " -opt-in= kotlin.time.ExperimentalTime" )
171
- if (hasSerialization) add( " -opt-in= kotlinx.serialization.ExperimentalSerializationApi" )
172
- }
164
+ val hasSerializationPlugin = plugins.hasPlugin(libs.plugins.kotlinSerialization.get().pluginId)
165
+
166
+ val optInRequirements = listOfNotNull(
167
+ " kotlin.contracts.ExperimentalContracts" ,
168
+ " kotlin.io.encoding.ExperimentalEncodingApi" ,
169
+ " kotlin.io.path.ExperimentalPathApi" ,
170
+ " kotlin.time.ExperimentalTime" ,
171
+ " kotlinx.serialization.ExperimentalSerializationApi" . takeIf { hasSerializationPlugin }
172
+ )
173
173
174
174
compilerOptions {
175
175
allWarningsAsErrors = true
176
- freeCompilerArgs.addAll(customCompilerArgs)
176
+ optIn = optInRequirements
177
177
jvmTarget = maxKotlinJvmTarget
178
178
}
179
179
}
Original file line number Diff line number Diff line change @@ -43,11 +43,7 @@ dependencies {
43
43
}
44
44
45
45
tasks.named<KotlinCompile >(" compileTestKotlin" ) {
46
- val customCompilerArgs = listOf (
47
- " -opt-in=kotlinx.serialization.ExperimentalSerializationApi"
48
- )
49
-
50
46
compilerOptions {
51
- freeCompilerArgs.addAll(customCompilerArgs )
47
+ optIn = listOf ( " kotlinx.serialization.ExperimentalSerializationApi " )
52
48
}
53
49
}
You can’t perform that action at this time.
0 commit comments