diff --git a/interface/src/main/java/xsbti/Versions.java b/interface/src/main/java/xsbti/Versions.java deleted file mode 100644 index 122499c04..000000000 --- a/interface/src/main/java/xsbti/Versions.java +++ /dev/null @@ -1,11 +0,0 @@ -/* sbt -- Simple Build Tool - * Copyright 2009 Mark Harrah - */ -package xsbti; - -public interface Versions -{ - public static final String Sbt = "0.7.0_13"; // keep in sync with LauncherProject in the XSbt project definition; - public static final int Interface = 1; - public static final int BootInterface = 1; -} diff --git a/ivy/ComponentManager.scala b/ivy/ComponentManager.scala index 0056ace7a..fc4606f6d 100644 --- a/ivy/ComponentManager.scala +++ b/ivy/ComponentManager.scala @@ -55,7 +55,7 @@ class ComponentManager(globalLock: xsbti.GlobalLock, provider: xsbti.ComponentPr /** Retrieve the file for component 'id' from the local repository. */ private def update(id: String): Unit = IvyCache.withCachedJar(sbtModuleID(id), log)(jar => define(id, Seq(jar)) ) - private def sbtModuleID(id: String) = ModuleID("org.scala-tools.sbt", id, xsbti.Versions.Sbt) + private def sbtModuleID(id: String) = ModuleID("org.scala-tools.sbt", id, ComponentManager.stampedVersion) /** Install the files for component 'id' to the local repository. This is usually used after writing files to the directory returned by 'location'. */ def cache(id: String): Unit = IvyCache.cacheJar(sbtModuleID(id), file(id)(IfMissing.Fail), log) def clearCache(id: String): Unit = lockGlobalCache { IvyCache.clearCachedJar(sbtModuleID(id), log) } @@ -69,4 +69,15 @@ object IfMissing { object Fail extends IfMissing final class Define(val cache: Boolean, define: => Unit) extends IfMissing { def apply() = define } +} +object ComponentManager +{ + lazy val (version, timestamp) = + { + val properties = new java.util.Properties + val propertiesStream = getClass.getResourceAsStream("/xsbt.version.properties") + try { properties.load(propertiesStream) } finally { propertiesStream.close() } + (properties.getProperty("version"), properties.getProperty("timestamp")) + } + lazy val stampedVersion = version + "_" + timestamp } \ No newline at end of file diff --git a/ivy/IvyCache.scala b/ivy/IvyCache.scala index e3f0044bc..cfb829458 100644 --- a/ivy/IvyCache.scala +++ b/ivy/IvyCache.scala @@ -52,8 +52,7 @@ object IvyCache copyTo } - /** Get the location of the cached jar for the given ID in the Ivy cache. If the jar is not in the cache, NotInCache is thrown - * TODO: locking.*/ + /** Get the location of the cached jar for the given ID in the Ivy cache. If the jar is not in the cache, NotInCache is thrown .*/ def withCachedJar[T](id: ModuleID, log: IvyLogger)(f: File => T): T = { val cachedFile = diff --git a/launch/src/test/scala/ScalaProviderTest.scala b/launch/src/test/scala/ScalaProviderTest.scala index b324d7f39..2071b3773 100644 --- a/launch/src/test/scala/ScalaProviderTest.scala +++ b/launch/src/test/scala/ScalaProviderTest.scala @@ -73,7 +73,7 @@ package test { object MainTest { - val Version = "test-" + xsbti.Versions.Sbt + val Version = "test-" + System.currentTimeMillis } class Exit(val code: Int) extends xsbti.Exit final class MainException(message: String) extends RuntimeException(message) diff --git a/project/build/XSbt.scala b/project/build/XSbt.scala index 987eb09c5..9b2649349 100644 --- a/project/build/XSbt.scala +++ b/project/build/XSbt.scala @@ -119,11 +119,21 @@ class XSbt(info: ProjectInfo) extends ParentProject(info) val ivy = "org.apache.ivy" % "ivy" % "2.0.0" override def deliverProjectDependencies = Set(super.deliverProjectDependencies.toSeq : _*) - launchInterfaceSub.projectID } - class InterfaceProject(info: ProjectInfo) extends DefaultProject(info) with ManagedBase with TestWithLog with Component with JavaProject + abstract class BaseInterfaceProject(info: ProjectInfo) extends DefaultProject(info) with ManagedBase with TestWithLog with Component with JavaProject + class InterfaceProject(info: ProjectInfo) extends BaseInterfaceProject(info) { override def componentID: Option[String] = Some("xsbti") + override def packageAction = super.packageAction dependsOn generateVersions + def versionPropertiesPath = mainResourcesPath / "xsbt.version.properties" + lazy val generateVersions = task { + import java.util.{Date, TimeZone} + val formatter = new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss") + formatter.setTimeZone(TimeZone.getTimeZone("GMT")) + val timestamp = formatter.format(new Date) + FileUtilities.write(versionPropertiesPath.asFile, "version=" + version + "\ntimestamp=" + timestamp, log) + } } - class LaunchInterfaceProject(info: ProjectInfo) extends InterfaceProject(info) + class LaunchInterfaceProject(info: ProjectInfo) extends BaseInterfaceProject(info) { override def componentID = None }