Skip to content

Commit 0899508

Browse files
authored
Merge pull request #321 from mockito/sf
Fixed the CI releases
2 parents 6ecaa0f + 66b3eaa commit 0899508

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ script:
2121
# To validate changes, we run building and bintray upload in dry run. This happens on every build, even PRs.
2222
# To publish, we perform github release and perform bintray upload (no dry run). This only for main branch builds.
2323
- >
24-
./gradlew resolveVersion
25-
&& ./gradlew build bintrayUpload -PbintrayDryRun
24+
./gradlew build bintrayUpload -PbintrayDryRun
2625
&& if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "release/1.x" ];
2726
then ./gradlew bintrayUpload githubRelease; fi

build.gradle

+2-7
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

+12-7
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)