Skip to content
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
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ buildscript {

apply from: "gradle/shipkit.gradle"

task resolveVersion {
description = "Resolves version in the 'version.properties' file for the SBT build."
doLast {
file("version.properties").text = "version=$version"
}
}

task build(type: Exec) {
commandLine "./build.sh"
environment "PROJECT_VERSION", version
}

task clean(type: Exec) {
commandLine "./clean.sh"
environment "PROJECT_VERSION", version
}
19 changes: 12 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ lazy val commonSettings =
organization := "org.mockito",
//Load version from the file so that Gradle/Shipkit and SBT use the same version
version := {
val pattern = """^version=(.+)$""".r
val source = Source.fromFile("version.properties")
val version = Try(source.getLines.collectFirst { case pattern(v) =>
v
}.get)
source.close
version.get.replace(".*", "-SNAPSHOT")
val versionFromEnv = System.getenv("PROJECT_VERSION")
Copy link
Member Author

Choose a reason for hiding this comment

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

@bbonanno, ok with this?

Copy link
Member

Choose a reason for hiding this comment

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

It looks ok, but it seems it also breaks the PR builds

if (versionFromEnv != null && !versionFromEnv.trim().isEmpty()) {
versionFromEnv
} else {
val pattern = """^version=(.+)$""".r
val source = Source.fromFile("version.properties")
val version = Try(source.getLines.collectFirst { case pattern(v) =>
v
}.get)
source.close
version.get.replace(".*", "-SNAPSHOT")
}
},
crossScalaVersions := Seq(currentScalaVersion, "2.12.12", "2.11.12"),
scalafmtOnCompile := true,
Expand Down