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

Add KOTLIN_SCRIPTS feature flag #583

Merged
merged 5 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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)
}
Comment on lines +22 to +38
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be in a separate PR, don't you?

Copy link
Member Author

@jmfayard jmfayard Sep 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually no, because it's a copy/paste from RefreshVersionsTask that is known to work, and because adding the flag is my main focus here, see comment below


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

@TaskAction
fun cleanupKotlinScripts() {
if (FeatureFlag.KOTLIN_SCRIPTS.isEnabled) {
println("TODO: refreshVersionsCleanUp should clean up Kotlin Scripts see https://github.com/jmfayard/refreshVersions/issues/582")
jmfayard marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ open class RefreshVersionsTask : DefaultTask() {
}
}
}
if (FeatureFlag.KOTLIN_SCRIPTS.isEnabled) {
println("TODO: refreshVersions should support Kotlin Scripts see https://github.com/jmfayard/refreshVersions/issues/582")
jmfayard marked this conversation as resolved.
Show resolved Hide resolved
}
}

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

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