mirror of https://github.com/sbt/sbt.git
better invalidation of interface version.properties file
This commit is contained in:
parent
7bed381bec
commit
062b47ac8d
|
|
@ -1,4 +1,3 @@
|
|||
// TODO(high): proper incremental xsbt.version.properties generation
|
||||
// TODO(low): proper generated API sources caching: doesn't detect output directory change
|
||||
|
||||
import sbt._
|
||||
|
|
@ -192,7 +191,7 @@ object Sbt extends Build
|
|||
exportJars := true,
|
||||
componentID := Some("xsbti"),
|
||||
watchSources <++= apiDefinitions,
|
||||
resourceGenerators in Compile <+= (version, resourceManaged, streams) map generateVersionFile,
|
||||
resourceGenerators in Compile <+= (version, resourceManaged, streams, compile in Compile) map generateVersionFile,
|
||||
apiDefinitions <<= baseDirectory map { base => (base / "definition") :: (base / "other") :: (base / "type") :: Nil },
|
||||
sourceGenerators in Compile <+= (cacheDirectory, apiDefinitions, fullClasspath in Compile in datatypeSub, sourceManaged in Compile, mainClass in datatypeSub in Compile, runner, streams) map generateAPICached
|
||||
)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,12 @@ object Util
|
|||
toError(run.run(mainClass, cp.files, args, s.log))
|
||||
(out ** "*.java").get
|
||||
}
|
||||
def generateVersionFile(version: String, dir: File, s: TaskStreams): Seq[File] =
|
||||
def lastCompilationTime(analysis: sbt.inc.Analysis): Long =
|
||||
{
|
||||
val times = analysis.apis.internal.values.map(_.compilation.startTime)
|
||||
if(times.isEmpty) 0L else times.max
|
||||
}
|
||||
def generateVersionFile(version: String, dir: File, s: TaskStreams, analysis: sbt.inc.Analysis): Seq[File] =
|
||||
{
|
||||
import java.util.{Date, TimeZone}
|
||||
val formatter = new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss")
|
||||
|
|
@ -63,7 +68,7 @@ object Util
|
|||
val timestamp = formatter.format(new Date)
|
||||
val content = "version=" + version + "\ntimestamp=" + timestamp
|
||||
val f = dir / "xsbt.version.properties"
|
||||
if(!f.exists) { // TODO: properly handle this
|
||||
if(!f.exists || f.lastModified < lastCompilationTime(analysis)) {
|
||||
s.log.info("Writing version information to " + f + " :\n" + content)
|
||||
IO.write(f, content)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue