-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sbt#7567 from adpi2/backport-7538
[1.10.x] Fix `dependency-management/force-update-period` (backport of sbt#7538)
- Loading branch information
Showing
4 changed files
with
44 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 12 additions & 10 deletions
22
sbt-app/src/sbt-test/dependency-management/force-update-period/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
ThisBuild / useCoursier := false | ||
|
||
name := "force-update-period" | ||
scalaVersion := "2.12.18" | ||
libraryDependencies += "log4j" % "log4j" % "1.2.16" % "compile" | ||
|
||
autoScalaLibrary := false | ||
|
||
crossPaths := false | ||
|
||
TaskKey[Unit]("check-last-update-time") := (streams map { (s) => | ||
val fullUpdateOutput = s.cacheDirectory / "out" | ||
val timeDiff = System.currentTimeMillis()-fullUpdateOutput.lastModified() | ||
val exists = fullUpdateOutput.exists() | ||
TaskKey[Unit]("check-last-update-time") := { | ||
val s = streams.value | ||
val updateOutput = crossTarget.value / "update" / updateCacheName.value / "output" | ||
if (!updateOutput.exists()) { | ||
sys.error("Update cache does not exist") | ||
} | ||
val timeDiff = System.currentTimeMillis() - updateOutput.lastModified() | ||
s.log.info(s"Amount of time since last full update: $timeDiff") | ||
if (exists && timeDiff > 5000) { | ||
sys.error("Full update not performed") | ||
if (timeDiff > 5000) { | ||
sys.error("Update not performed") | ||
} | ||
}).value | ||
} |
8 changes: 4 additions & 4 deletions
8
sbt-app/src/sbt-test/dependency-management/force-update-period/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
$ absent target/resolution-cache | ||
$ absent target/scala-2.12/resolution-cache | ||
> compile | ||
$ exists target/resolution-cache | ||
$ exists target/scala-2.12/resolution-cache | ||
> checkLastUpdateTime | ||
$ sleep 10000 | ||
$ sleep 5000 | ||
> compile | ||
# This is expected to fail | ||
-> checkLastUpdateTime | ||
> set forceUpdatePeriod := Some(new scala.concurrent.duration.FiniteDuration(5000, java.util.concurrent.TimeUnit.MILLISECONDS)) | ||
> compile | ||
> checkLastUpdateTime | ||
> checkLastUpdateTime |