Skip to content

Commit

Permalink
Determine snapshot version automatically from root gradle.properties
Browse files Browse the repository at this point in the history
(cherry picked from commit 6236a1f)
  • Loading branch information
ilya-g committed Apr 27, 2023
1 parent e74b999 commit d0c9e38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ final String kotlinRootDir = rootProject.file("../../../").absolutePath.replace(
final String kotlinLibsDir = "$buildDir/libs"

final String githubRevision = isTeamcityBuild ? project.property("githubRevision") : "master"
final String kotlinVersion = isTeamcityBuild ? project.property("deployVersion") : "1.8.255-SNAPSHOT"
final String kotlinVersion = isTeamcityBuild ? project.property("deployVersion") : defaultSnapshotVersion(kotlinRootDir)
final String repo = isTeamcityBuild ? project.property("kotlinLibsRepo") : "$kotlinRootDir/build/repo"

def defaultSnapshotVersion(String kotlinRootDir) {
file("$kotlinRootDir/gradle.properties").newInputStream().with {
final def props = new Properties()
props.load(it)
return Objects.requireNonNull(props.get("defaultSnapshotVersion")) as String
}
}

println("# Extracting info:")
println(" isTeamcityBuild: $isTeamcityBuild")
println(" githubRevision: $githubRevision")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ val kotlinRootDir = rootProject.file("../../../").absoluteFile.invariantSeparato
val kotlinLibsDir = "$buildDir/libs"

val githubRevision = if (isTeamcityBuild) project.property("githubRevision") else "master"
val kotlinVersion = if (isTeamcityBuild) project.property("deployVersion") as String else "1.8.255-SNAPSHOT"
val kotlinVersion = if (isTeamcityBuild) project.property("deployVersion") as String else defaultSnapshotVersion()
val repo = if (isTeamcityBuild) project.property("kotlinLibsRepo") as String else "$kotlinRootDir/build/repo"

fun defaultSnapshotVersion(): String = file(kotlinRootDir).resolve("gradle.properties").inputStream().use { stream ->
java.util.Properties().apply { load(stream) }["defaultSnapshotVersion"] as String
}

println("# Parameters summary:")
println(" isTeamcityBuild: $isTeamcityBuild")
println(" githubRevision: $githubRevision")
Expand Down

0 comments on commit d0c9e38

Please sign in to comment.