-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix compiler plugin options not working
- Loading branch information
Showing
6 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
sekret-compiler-plugin/src/main/kotlin/dev/datlag/sekret/SekretCommandLineProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package dev.datlag.sekret | ||
|
||
import com.google.auto.service.AutoService | ||
import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption | ||
import org.jetbrains.kotlin.compiler.plugin.CliOption | ||
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor | ||
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi | ||
import org.jetbrains.kotlin.config.CompilerConfiguration | ||
import org.jetbrains.kotlin.config.CompilerConfigurationKey | ||
|
||
@OptIn(ExperimentalCompilerApi::class) | ||
@AutoService(CommandLineProcessor::class) | ||
class SekretCommandLineProcessor : CommandLineProcessor { | ||
override val pluginId: String = "sekretPlugin" | ||
|
||
override val pluginOptions: Collection<AbstractCliOption> = listOf( | ||
CliOption( | ||
optionName = KEY_SECRET_MASK.toString(), valueDescription = "<fqname>", | ||
description = "Mask for Strings annotated with @Secret" | ||
), | ||
CliOption( | ||
optionName = KEY_SECRET_MASK_NULL.toString(), valueDescription = "<true|false>", | ||
description = "Apply mask to nullable values or not" | ||
) | ||
) | ||
|
||
override fun processOption(option: AbstractCliOption, value: String, configuration: CompilerConfiguration) { | ||
super.processOption(option, value, configuration) | ||
|
||
when (option.optionName) { | ||
KEY_SECRET_MASK.toString() -> configuration.put(KEY_SECRET_MASK, value) | ||
KEY_SECRET_MASK_NULL.toString() -> configuration.put(KEY_SECRET_MASK_NULL, value.toBoolean()) | ||
} | ||
} | ||
} | ||
|
||
val KEY_SECRET_MASK = CompilerConfigurationKey<String>("secretMask") | ||
val KEY_SECRET_MASK_NULL = CompilerConfigurationKey<Boolean>("secretMaskNull") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters