Skip to content

Commit

Permalink
Merge pull request #100 from jmfayard/buildSrcVersions-98
Browse files Browse the repository at this point in the history
implements #98 const val versionPlaceHolder = "_"
  • Loading branch information
Jean-Michel Fayard authored Oct 7, 2019
2 parents d1309c1 + 92c427e commit fd2fddf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugin/src/main/kotlin/de/fayard/internal/KotlinPoetry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fun Dependency.newerVersion(): String? =
available.milestone.isNullOrBlank().not() -> available.milestone
available.integration.isNullOrBlank().not() -> available.integration
else -> null
}
}?.trim()

fun Dependency.generateLibsProperty(extension: BuildSrcVersionsExtension): PropertySpec {
val libValue = when {
Expand Down
14 changes: 10 additions & 4 deletions plugin/src/main/kotlin/de/fayard/internal/UpdateVersionsOnly.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ object UpdateVersionsOnly {
}
val commentPrefix = " available="
val spacing = PluginConfig.spaces(key.length - commentPrefix.length - 1)
val available = when (val v = newerVersion()) {
null -> ""
else -> "\n#$spacing#$commentPrefix$v"
val newerVersion = newerVersion()
val available = when {
newerVersion == null -> ""
version in listOf("+", "_") -> ""
else -> "\n#$spacing#$commentPrefix$newerVersion"
}
return "$key=$version$available"
val validatedVersion = when (version) {
"+", "_" -> newerVersion() ?: version
else -> version
}
return "$key=$validatedVersion$available"
}

fun parseBuildFileOrNew(versionsOnlyFile: File?, versionsOnlyMode: VersionsOnlyMode, fromDir: File): Pair<File, SingleModeResult> = when {
Expand Down
10 changes: 10 additions & 0 deletions plugin/src/test/kotlin/de/fayard/GradlePropertiesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class GradlePropertiesTest : FreeSpec({
val publish = "com.gradle.plugin-publish:com.gradle.plugin-publish.gradle.plugin:1.0".asDependency()
publish.asGradleProperty() shouldBe "plugin.com.gradle.plugin-publish=1.0"
}

"replace versionPlaceHolder = _" {
val bsv = "com.wealthfront:magellan:_ // 1.1.0".asDependency()
bsv.asGradleProperty() shouldBe ("version.magellan=1.1.0")
}

"replace versionPlaceHolder = +" {
val bsv = "com.wealthfront:magellan:+ // 1.1.0".asDependency()
bsv.asGradleProperty() shouldBe ("version.magellan=1.1.0")
}
}
}
})
Expand Down
2 changes: 2 additions & 0 deletions sample-versionsOnlyMode/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ repositories {
dependencies {
implementation("com.google.guava:guava:15.0")
implementation("com.google.inject:guice:2.0")
implementation("com.wealthfront:magellan:_")
implementation("com.wealthfront:magellan-rx:+")
}

tasks.withType<KotlinCompile> {
Expand Down
1 change: 1 addition & 0 deletions sample-versionsOnlyMode/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ plugin.com.gradle.build-scan=2.4.1
plugin.nebula.kotlin=1.3.50
version.org.jetbrains.kotlin=1.3.50
version.gradleLatestVersion=5.6.2
version.com.wealthfront=1.1.0
version.guava=15.0
version.guice=2.0

0 comments on commit fd2fddf

Please sign in to comment.