Reorganize subprojects around

This commit is contained in:
Eugene Yokota 2015-09-13 01:13:42 -04:00
parent ce915b23ba
commit f26f95fe6a
1 changed files with 3 additions and 58 deletions

View File

@ -12,25 +12,12 @@ import sbt.librarymanagement.{ Configurations, ModuleID, ModuleInfo, Resolver, U
import sbt.util.Logger
import sbt.internal.util.{ BufferedLogger, FullLogger }
object ComponentCompiler {
val xsbtiID = "xsbti"
val srcExtension = "-src"
private[sbt] object ComponentCompiler {
// val xsbtiID = "xsbti"
// val srcExtension = "-src"
val binSeparator = "-bin_"
val compilerInterfaceID = "compiler-interface"
val compilerInterfaceSrcID = compilerInterfaceID + srcExtension
val javaVersion = System.getProperty("java.class.version")
@deprecated("Use `interfaceProvider(ComponentManager, IvyConfiguration, ModuleID)`.", "0.13.10")
def interfaceProvider(manager: ComponentManager): CompilerInterfaceProvider = new CompilerInterfaceProvider {
def apply(scalaInstance: xsbti.compile.ScalaInstance, log: Logger): File =
{
// this is the instance used to compile the interface component
val componentCompiler = new ComponentCompiler(new RawCompiler(scalaInstance, ClasspathOptions.auto, log), manager)
log.debug("Getting " + compilerInterfaceID + " from component compiler for Scala " + scalaInstance.version)
componentCompiler(compilerInterfaceID)
}
}
def interfaceProvider(manager: ComponentManager, ivyConfiguration: IvyConfiguration, sourcesModule: ModuleID): CompilerInterfaceProvider = new CompilerInterfaceProvider {
def apply(scalaInstance: xsbti.compile.ScalaInstance, log: Logger): File =
{
@ -48,48 +35,6 @@ object ComponentCompiler {
properties.getProperty("version")
}
}
/**
* This class provides source components compiled with the provided RawCompiler.
* The compiled classes are cached using the provided component manager according
* to the actualVersion field of the RawCompiler.
*/
@deprecated("Replaced by IvyComponentCompiler.", "0.13.10")
class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager) {
import ComponentCompiler._
def apply(id: String): File =
try { getPrecompiled(id) }
catch { case _: InvalidComponent => getLocallyCompiled(id) }
/**
* Gets the precompiled (distributed with sbt) component with the given 'id'
* If the component has not been precompiled, this throws InvalidComponent.
*/
def getPrecompiled(id: String): File = manager.file(binaryID(id, false))(IfMissing.Fail)
/**
* Get the locally compiled component with the given 'id' or compiles it if it has not been compiled yet.
* If the component does not exist, this throws InvalidComponent.
*/
def getLocallyCompiled(id: String): File =
{
val binID = binaryID(id, true)
manager.file(binID)(new IfMissing.Define(true, compileAndInstall(id, binID)))
}
def clearCache(id: String): Unit = manager.clearCache(binaryID(id, true))
protected def binaryID(id: String, withJavaVersion: Boolean) =
{
val base = id + binSeparator + compiler.scalaInstance.actualVersion
if (withJavaVersion) base + "__" + javaVersion else base
}
protected def compileAndInstall(id: String, binID: String): Unit = {
val srcID = id + srcExtension
IO.withTemporaryDirectory { binaryDirectory =>
val targetJar = new File(binaryDirectory, id + ".jar")
val xsbtiJars = manager.files(xsbtiID)(IfMissing.Fail)
AnalyzingCompiler.compileSources(manager.files(srcID)(IfMissing.Fail), targetJar, xsbtiJars, id, compiler, manager.log)
manager.define(binID, Seq(targetJar))
}
}
}
/**
* Component compiler which is able to to retrieve the compiler bridge sources