Skip to content

Commit

Permalink
Merge pull request #66 from neva-dev/65-allow-users-to-force-a-value-…
Browse files Browse the repository at this point in the history
…on-other-properties-when-a-condition-is-met

65 allow users to force a value on other properties when a condition is met
  • Loading branch information
krystian-panek-vmltech authored Aug 2, 2022
2 parents 165c29c + 44398da commit 4043a49
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=7.0.9
version=7.0.11
release.useAutomaticVersion=true

# Performance tuning
Expand Down
14 changes: 14 additions & 0 deletions src/main/kotlin/com/neva/gradle/fork/config/properties/Property.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ class Property(
}
}

fun force(flag: Boolean, value: String, vararg names: String) = force(flag, value, names.toList())

fun force(flag: Boolean, value: String, patterns: List<String>) {
for (pattern in patterns) {
val others = others(pattern)
for (property in others) {
if (flag) {
property.value = value
}
property.enabled = !flag
}
}
}

fun other(name: String) = context.get(name)

fun others(pattern: String) = context.find(pattern)
Expand Down

0 comments on commit 4043a49

Please sign in to comment.