mirror of https://github.com/sbt/sbt.git
Use FiniteDuration to represent time rather than a long
This commit is contained in:
parent
32b1f65503
commit
7c0f455c79
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import scala.concurrent.duration.Duration
|
||||
import scala.concurrent.duration.{ FiniteDuration, Duration }
|
||||
import Attributed.data
|
||||
import Scope.{ fillTaskAxis, GlobalScope, ThisScope }
|
||||
import sbt.Compiler.InputsWithPrevious
|
||||
|
|
@ -27,7 +27,7 @@ import org.apache.ivy.core.module.{ descriptor, id }
|
|||
import descriptor.ModuleDescriptor, id.ModuleRevisionId
|
||||
import java.io.{ File, PrintWriter }
|
||||
import java.net.{ URI, URL, MalformedURLException }
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.{ TimeUnit, Callable }
|
||||
import sbinary.DefaultProtocol.StringFormat
|
||||
import Cache.seqFormat
|
||||
import CommandStrings.ExportStream
|
||||
|
|
@ -116,7 +116,7 @@ object Defaults extends BuildCommon {
|
|||
pomAllRepositories :== false,
|
||||
pomIncludeRepository :== Classpaths.defaultRepositoryFilter,
|
||||
updateOptions := UpdateOptions(),
|
||||
forceUpdateMs :== None
|
||||
forceUpdatePeriod :== None
|
||||
)
|
||||
|
||||
/** Core non-plugin settings for sbt builds. These *must* be on every build or the sbt engine will fail to run at all. */
|
||||
|
|
@ -1325,12 +1325,14 @@ object Classpaths {
|
|||
def updateTask: Initialize[Task[UpdateReport]] = Def.task {
|
||||
val depsUpdated = transitiveUpdate.value.exists(!_.stats.cached)
|
||||
val isRoot = executionRoots.value contains resolvedScoped.value
|
||||
val forceUpdate = forceUpdateMs.value
|
||||
val forceUpdate = forceUpdatePeriod.value
|
||||
val s = streams.value
|
||||
val fullUpdateOutput = s.cacheDirectory / "out"
|
||||
val forceUpdateByTime = forceUpdate match {
|
||||
case None => false
|
||||
case Some(period) => fullUpdateOutput.exists() && fullUpdateOutput.lastModified() <= (System.currentTimeMillis() - period)
|
||||
case None => false
|
||||
case Some(period) =>
|
||||
val elapsedDuration = new FiniteDuration(System.currentTimeMillis() - fullUpdateOutput.lastModified(), TimeUnit.MILLISECONDS)
|
||||
fullUpdateOutput.exists() && elapsedDuration > period
|
||||
}
|
||||
val scalaProvider = appConfiguration.value.provider.scalaProvider
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package sbt
|
|||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import scala.concurrent.duration.Duration
|
||||
import scala.concurrent.duration.{ FiniteDuration, Duration }
|
||||
import Def.ScopedKey
|
||||
import complete._
|
||||
import inc.Analysis
|
||||
|
|
@ -324,7 +324,7 @@ object Keys {
|
|||
val publishArtifact = SettingKey[Boolean]("publish-artifact", "Enables (true) or disables (false) publishing an artifact.", AMinusSetting)
|
||||
val packagedArtifact = TaskKey[(Artifact, File)]("packaged-artifact", "Generates a packaged artifact, returning the Artifact and the produced File.", CTask)
|
||||
val checksums = SettingKey[Seq[String]]("checksums", "The list of checksums to generate and to verify for dependencies.", BSetting)
|
||||
val forceUpdateMs = SettingKey[Option[Long]]("force-update-ms", "Amount of time in milliseconds after which to force a full update to occur", CSetting)
|
||||
val forceUpdatePeriod = SettingKey[Option[FiniteDuration]]("force-update-period", "Duration after which to force a full update to occur", CSetting)
|
||||
|
||||
val classifiersModule = TaskKey[GetClassifiersModule]("classifiers-module", rank = CTask)
|
||||
val conflictWarning = SettingKey[ConflictWarning]("conflict-warning", "Configures warnings for conflicts in dependency management.", CSetting)
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
[@ajsquared]: https://github.com/ajsquared
|
||||
|
||||
|
||||
### Changes with compatibility implications
|
||||
|
||||
### Improvements
|
||||
- Adds `forceUpdateMs` key, that takes values of `Option[Long]` representing a number of milliseconds. If set, a full `update` will occur after that amount of time without needing to explicitly run the `update` task. By [@ajsquared][@ajsquared]
|
||||
|
||||
### Fixes
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
[@ajsquared]: https://github.com/ajsquared
|
||||
|
||||
|
||||
### Changes with compatibility implications
|
||||
|
||||
### Improvements
|
||||
- Adds `forceUpdatePeriod` key, that takes values of `Option[FiniteDuration]`. If set, a full `update` will occur after that amount of time without needing to explicitly run the `update` task. By [@ajsquared][@ajsquared]
|
||||
|
||||
### Fixes
|
||||
|
|
@ -6,6 +6,6 @@ $ sleep 10000
|
|||
> compile
|
||||
# This is expected to fail
|
||||
-> checkLastUpdateTime
|
||||
> set forceUpdateMs := Some(5000)
|
||||
> set forceUpdatePeriod := Some(new scala.concurrent.duration.FiniteDuration(5000, java.util.concurrent.TimeUnit.MILLISECONDS))
|
||||
> compile
|
||||
> checkLastUpdateTime
|
||||
Loading…
Reference in New Issue