Skip to content

Commit

Permalink
Merge pull request #583 from jmfayard/GH-582-kotlin-scripts
Browse files Browse the repository at this point in the history
Add KOTLIN_SCRIPTS feature flag
  • Loading branch information
LouisCAD committed Oct 2, 2022
2 parents cb146dc + 6cebb27 commit 462ba24
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum class FeatureFlag(private val enabledByDefault: Boolean?) {
LIBS(enabledByDefault = false),
NPM_IMPLICIT_RANGE(enabledByDefault = false),
VERSIONS_CATALOG(enabledByDefault = true),
KOTLIN_SCRIPTS(enabledByDefault = false),
;

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,32 @@ import de.fayard.refreshVersions.core.internal.versions.VersionsPropertiesModel.
import de.fayard.refreshVersions.core.internal.versions.readFromFile
import de.fayard.refreshVersions.core.internal.versions.writeTo
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.options.Option
import java.io.File

open class RefreshVersionsCleanupTask : DefaultTask() {

@Input
@Optional
@Option(option = "enable", description = "Enable a feature flag")
var enableFlag: FeatureFlag? = null
set(value) {
field = value
if (value != null) FeatureFlag.userSettings.put(value, true)
}

@Input
@Optional
@Option(option = "disable", description = "Disable a feature flag")
var disableFlag: FeatureFlag? = null
set(value) {
field = value
if (value != null) FeatureFlag.userSettings.put(value, false)
}

@TaskAction
fun cleanUpVersionsProperties() {
OutputFile.checkWhichFilesExist()
Expand Down Expand Up @@ -61,4 +82,11 @@ open class RefreshVersionsCleanupTask : DefaultTask() {
}
}
}

@TaskAction
fun cleanupKotlinScripts() {
if (FeatureFlag.KOTLIN_SCRIPTS.isEnabled) {
println("NOTE: refreshVersionsCleanUp doesn't clean up Kotlin Scripts yet, see https://github.com/jmfayard/refreshVersions/issues/582")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ open class RefreshVersionsTask : DefaultTask() {
}
}
}
if (FeatureFlag.KOTLIN_SCRIPTS.isEnabled) {
println("NOTE: refreshVersions support for Kotlin Scripts isn't implemented yet, see https://github.com/jmfayard/refreshVersions/issues/582")
}
}

private fun warnAboutRefreshVersionsIfSettingIfAny() {
Expand Down
2 changes: 2 additions & 0 deletions sample-kotlin/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ refreshVersions {
enable(LIBS)
enable(OLD_TASKS)
disable(GRADLE_UPDATES)
disable(VERSIONS_CATALOG)
enable(KOTLIN_SCRIPTS)
}

extraArtifactVersionKeyRules(file("refreshVersions-extra-rules.txt"))
Expand Down

0 comments on commit 462ba24

Please sign in to comment.