Skip to content

Commit adfadc7

Browse files
committed
Fixed the CI releases
Fixed the version injection to the SBT build. This will fix the CI failures: https://travis-ci.com/github/mockito/mockito-scala/builds/203412229
1 parent 6ecaa0f commit adfadc7

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

build.gradle

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,12 @@ buildscript {
1414

1515
apply from: "gradle/shipkit.gradle"
1616

17-
task resolveVersion {
18-
description = "Resolves version in the 'version.properties' file for the SBT build."
19-
doLast {
20-
file("version.properties").text = "version=$version"
21-
}
22-
}
23-
2417
task build(type: Exec) {
2518
commandLine "./build.sh"
19+
environment "PROJECT_VERSION", version
2620
}
2721

2822
task clean(type: Exec) {
2923
commandLine "./clean.sh"
24+
environment "PROJECT_VERSION", version
3025
}

build.sbt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ lazy val commonSettings =
1313
organization := "org.mockito",
1414
//Load version from the file so that Gradle/Shipkit and SBT use the same version
1515
version := {
16-
val pattern = """^version=(.+)$""".r
17-
val source = Source.fromFile("version.properties")
18-
val version = Try(source.getLines.collectFirst { case pattern(v) =>
19-
v
20-
}.get)
21-
source.close
22-
version.get.replace(".*", "-SNAPSHOT")
16+
val versionFromEnv = System.getenv("PROJECT_VERSION")
17+
if (versionFromEnv != null && !versionFromEnv.trim().isEmpty()) {
18+
versionFromEnv
19+
} else {
20+
val pattern = """^version=(.+)$""".r
21+
val source = Source.fromFile("version.properties")
22+
val version = Try(source.getLines.collectFirst { case pattern(v) =>
23+
v
24+
}.get)
25+
source.close
26+
version.get.replace(".*", "-SNAPSHOT")
27+
}
2328
},
2429
crossScalaVersions := Seq(currentScalaVersion, "2.12.12", "2.11.12"),
2530
scalafmtOnCompile := true,

0 commit comments

Comments
 (0)