Merge pull request #5344 from eed3si9n/wip/repeatable

Don't emit timestamps when packaging to jar, take 2
This commit is contained in:
eugene yokota 2019-12-29 02:58:53 -05:00 committed by GitHub
commit bf9225bccf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 6 deletions

View File

@ -70,13 +70,23 @@ object Package {
val options: Seq[PackageOption]
)
@deprecated("Please specify whether to use a static timestamp", "1.4.0")
def apply(conf: Configuration, cacheStoreFactory: CacheStoreFactory, log: Logger): Unit =
apply(conf, cacheStoreFactory, log, None)
/**
*
* @param conf the package configuration that should be build
* @param cacheStoreFactory used for jar caching. We try to avoid rebuilds as much as possible
* @param log feedback for the user
* @param time static timestamp to use for all entries, if any.
*/
def apply(conf: Configuration, cacheStoreFactory: CacheStoreFactory, log: Logger): Unit = {
def apply(
conf: Configuration,
cacheStoreFactory: CacheStoreFactory,
log: Logger,
time: Option[Long]
): Unit = {
val manifest = new Manifest
val main = manifest.getMainAttributes
for (option <- conf.options) {
@ -96,7 +106,7 @@ object Package {
val sources :+: _ :+: manifest :+: HNil = inputs
outputChanged(cacheStoreFactory make "output") { (outChanged, jar: PlainFileInfo) =>
if (inChanged || outChanged) {
makeJar(sources, jar.file, manifest, log)
makeJar(sources, jar.file, manifest, log, time)
jar.file
()
} else
@ -153,7 +163,17 @@ object Package {
homepage map (h => (IMPLEMENTATION_URL, h.toString))
}: _*)
}
def makeJar(sources: Seq[(File, String)], jar: File, manifest: Manifest, log: Logger): Unit = {
@deprecated("Please specify whether to use a static timestamp", "1.4.0")
def makeJar(sources: Seq[(File, String)], jar: File, manifest: Manifest, log: Logger): Unit =
makeJar(sources, jar, manifest, log, None)
def makeJar(
sources: Seq[(File, String)],
jar: File,
manifest: Manifest,
log: Logger,
time: Option[Long]
): Unit = {
val path = jar.getAbsolutePath
log.debug("Packaging " + path + " ...")
if (jar.exists)
@ -162,7 +182,7 @@ object Package {
else
sys.error(path + " exists, but is not a regular file")
log.debug(sourcesDebugString(sources))
IO.jar(sources, jar, manifest)
IO.jar(sources, jar, manifest, time)
log.debug("Done packaging.")
}
def sourcesDebugString(sources: Seq[(File, String)]): String =

View File

@ -1409,7 +1409,12 @@ object Defaults extends BuildCommon {
Def.task {
val config = packageConfiguration.value
val s = streams.value
Package(config, s.cacheStoreFactory, s.log)
Package(
config,
s.cacheStoreFactory,
s.log,
sys.env.get("SOURCE_DATE_EPOCH").map(_.toLong * 1000).orElse(Some(0L))
)
config.jar
}

View File

@ -11,7 +11,7 @@ object Dependencies {
def nightlyVersion: Option[String] = sys.props.get("sbt.build.version")
// sbt modules
private val ioVersion = nightlyVersion.getOrElse("1.3.1")
private val ioVersion = nightlyVersion.getOrElse("1.4.0-M2")
private val lmVersion =
sys.props.get("sbt.build.lm.version") match {
case Some(version) => version