Skip to content

Commit

Permalink
Simpler API for configuring simple rules #580
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfayard committed Sep 5, 2022
1 parent 6bb8dce commit 5d20383
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ open class RefreshVersionsExtension {
extraArtifactVersionKeyRules = extraArtifactVersionKeyRules + rawRules
}

fun extraVersionRules(vararg rules: PrefixRule) {
extraArtifactVersionKeyRules(rules.joinToString("\n\n") { it.toRawRules() })
}

fun featureFlags(extension: Action<FeatureFlagExtension>) {
extension.execute(FeatureFlagExtension())
}
Expand All @@ -51,3 +55,14 @@ open class FeatureFlagExtension {
FeatureFlag.userSettings[flag] = false
}
}

data class PrefixRule(
val versionName: String,
val mavenGroup: String,
val prefix: String? = null
) {
fun toRawRules(): String {
println("TODO: refreshVersions.extraVersionRules(PrefixRule(...)) not implemented. See https://github.com/jmfayard/refreshVersions/issues/580")
return ""
}
}
7 changes: 7 additions & 0 deletions sample-kotlin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import de.fayard.refreshVersions.PrefixRule
import de.fayard.refreshVersions.core.FeatureFlag.*
import de.fayard.refreshVersions.core.StabilityLevel

Expand Down Expand Up @@ -30,6 +31,12 @@ refreshVersions {

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


extraVersionRules(
PrefixRule("koin", "io.insert-koin", "koin"),
PrefixRule("ktor", "io.ktor", null),
)

// ignore dependencies among a blacklist of version keys
rejectVersionIf {
val blacklist = listOf("version.retrofit", "version.okhttp3")
Expand Down
2 changes: 1 addition & 1 deletion sample-kotlin/versions.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### Dependencies and Plugin versions with their available updates.
#### Generated by `./gradlew refreshVersions` version 0.41.0-SNAPSHOT
#### Revision of dependency notations removals: 11
#### Revision of dependency notations removals: 14
####
#### Don't manually edit or split the comments that start with four hashtags (####),
#### they will be overwritten by refreshVersions.
Expand Down

0 comments on commit 5d20383

Please sign in to comment.