Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display dynamic --jvm-target values when using --help flag #4694

Merged
merged 1 commit into from Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,6 +2,7 @@ package io.gitlab.arturbosch.detekt.cli

import com.beust.jcommander.IStringConverter
import com.beust.jcommander.ParameterException
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.LanguageVersion
import java.io.File
import java.net.URL
Expand Down Expand Up @@ -50,6 +51,11 @@ class LanguageVersionConverter : IStringConverter<LanguageVersion> {
checkNotNull(LanguageVersion.fromFullVersionString(value)) { "Invalid value passed to --language-version" }
}

class JvmTargetConverter : IStringConverter<JvmTarget> {
override fun convert(value: String): JvmTarget =
checkNotNull(JvmTarget.fromString(value)) { "Invalid value passed to --jvm-target" }
}

class ClasspathResourceConverter : IStringConverter<URL> {
override fun convert(resource: String): URL {
val relativeResource = if (resource.startsWith("/")) resource else "/$resource"
Expand Down
Expand Up @@ -188,10 +188,11 @@ class CliArgs {

@Parameter(
names = ["--jvm-target"],
converter = JvmTargetConverter::class,
description = "EXPERIMENTAL: Target version of the generated JVM bytecode that was generated during " +
"compilation and is now being used for type resolution (1.6, 1.8, 9, 10, 11, 12, 13, 14, 15, 16 or 17)"
"compilation and is now being used for type resolution"
)
var jvmTarget: String = JvmTarget.DEFAULT.description
var jvmTarget: JvmTarget = JvmTarget.DEFAULT

@Parameter(
names = ["--version"],
Expand Down
Expand Up @@ -65,7 +65,7 @@ internal fun CliArgs.createSpec(output: Appendable, error: Appendable): Processi
}

compiler {
jvmTarget = args.jvmTarget
jvmTarget = args.jvmTarget.toString()
languageVersion = args.languageVersion?.versionString
classpath = args.classpath?.trim()
}
Expand Down