Upgrade to new sbt/librarymanagement

This commit is contained in:
Dale Wijnand 2016-11-17 12:49:24 +00:00
parent e4dfbb0174
commit b9060c63ee
2 changed files with 23 additions and 23 deletions

View File

@ -9,9 +9,9 @@ import java.io.File
import scala.util.Try import scala.util.Try
import sbt.io.{ Hash, IO } import sbt.io.{ Hash, IO }
import sbt.internal.librarymanagement._ import sbt.internal.librarymanagement._
import sbt.librarymanagement.{ Configurations, ModuleID, ModuleInfo, Resolver, UpdateOptions, VersionNumber, ArtifactTypeFilter } import sbt.librarymanagement.{ Configurations, ModuleID, ModuleInfo, Resolver, UpdateConfiguration, UpdateLogging, UpdateOptions, ArtifactTypeFilter }
import sbt.util.Logger import sbt.util.Logger
import sbt.internal.util.{ BufferedLogger, FullLogger } import sbt.internal.util.{ BufferedLogger, CacheStore, FullLogger }
private[sbt] object ComponentCompiler { private[sbt] object ComponentCompiler {
// val xsbtiID = "xsbti" // val xsbtiID = "xsbti"
@ -19,11 +19,11 @@ private[sbt] object ComponentCompiler {
val binSeparator = "-bin_" val binSeparator = "-bin_"
val javaVersion = System.getProperty("java.class.version") val javaVersion = System.getProperty("java.class.version")
def interfaceProvider(manager: ComponentManager, ivyConfiguration: IvyConfiguration, sourcesModule: ModuleID): CompilerBridgeProvider = new CompilerBridgeProvider { def interfaceProvider(manager: ComponentManager, ivyConfiguration: IvyConfiguration, fileToStore: File => CacheStore, sourcesModule: ModuleID): CompilerBridgeProvider = new CompilerBridgeProvider {
def apply(scalaInstance: xsbti.compile.ScalaInstance, log: Logger): File = def apply(scalaInstance: xsbti.compile.ScalaInstance, log: Logger): File =
{ {
// this is the instance used to compile the interface component // this is the instance used to compile the interface component
val componentCompiler = new IvyComponentCompiler(new RawCompiler(scalaInstance, ClasspathOptionsUtil.auto, log), manager, ivyConfiguration, sourcesModule, log) val componentCompiler = new IvyComponentCompiler(new RawCompiler(scalaInstance, ClasspathOptionsUtil.auto, log), manager, ivyConfiguration, fileToStore, sourcesModule, log)
log.debug("Getting " + sourcesModule + " from component compiler for Scala " + scalaInstance.version) log.debug("Getting " + sourcesModule + " from component compiler for Scala " + scalaInstance.version)
componentCompiler() componentCompiler()
} }
@ -43,7 +43,7 @@ private[sbt] object ComponentCompiler {
* The compiled classes are cached using the provided component manager according * The compiled classes are cached using the provided component manager according
* to the actualVersion field of the RawCompiler. * to the actualVersion field of the RawCompiler.
*/ */
private[inc] class IvyComponentCompiler(compiler: RawCompiler, manager: ComponentManager, ivyConfiguration: IvyConfiguration, sourcesModule: ModuleID, log: Logger) { private[inc] class IvyComponentCompiler(compiler: RawCompiler, manager: ComponentManager, ivyConfiguration: IvyConfiguration, fileToStore: File => CacheStore, sourcesModule: ModuleID, log: Logger) {
import ComponentCompiler._ import ComponentCompiler._
private val sbtOrg = xsbti.ArtifactInfo.SbtOrganization private val sbtOrg = xsbti.ArtifactInfo.SbtOrganization
@ -51,7 +51,7 @@ private[inc] class IvyComponentCompiler(compiler: RawCompiler, manager: Componen
// private val xsbtiInterfaceID = s"interface-$incrementalVersion" // private val xsbtiInterfaceID = s"interface-$incrementalVersion"
private val sbtOrgTemp = JsonUtil.sbtOrgTemp private val sbtOrgTemp = JsonUtil.sbtOrgTemp
private val modulePrefixTemp = "temp-module-" private val modulePrefixTemp = "temp-module-"
private val ivySbt: IvySbt = new IvySbt(ivyConfiguration) private val ivySbt: IvySbt = new IvySbt(ivyConfiguration, fileToStore)
private val buffered = new BufferedLogger(FullLogger(log)) private val buffered = new BufferedLogger(FullLogger(log))
def apply(): File = { def apply(): File = {
@ -96,18 +96,18 @@ private[inc] class IvyComponentCompiler(compiler: RawCompiler, manager: Componen
*/ */
private def getModule(moduleID: ModuleID): ivySbt.Module = { private def getModule(moduleID: ModuleID): ivySbt.Module = {
val sha1 = Hash.toHex(Hash(moduleID.name)) val sha1 = Hash.toHex(Hash(moduleID.name))
val dummyID = ModuleID(sbtOrgTemp, modulePrefixTemp + sha1, moduleID.revision, moduleID.configurations) val dummyID = ModuleID(sbtOrgTemp, modulePrefixTemp + sha1, moduleID.revision).withConfigurations(moduleID.configurations)
getModule(dummyID, Seq(moduleID)) getModule(dummyID, Vector(moduleID))
} }
private def getModule(moduleID: ModuleID, deps: Seq[ModuleID], uo: UpdateOptions = UpdateOptions()): ivySbt.Module = { private def getModule(moduleID: ModuleID, deps: Vector[ModuleID], uo: UpdateOptions = UpdateOptions()): ivySbt.Module = {
val moduleSetting = InlineConfiguration( val moduleSetting = InlineConfiguration(
validate = false,
ivyScala = None,
module = moduleID, module = moduleID,
moduleInfo = ModuleInfo(moduleID.name), moduleInfo = ModuleInfo(moduleID.name),
dependencies = deps, dependencies = deps
configurations = Seq(Configurations.Component), ).withConfigurations(Vector(Configurations.Component))
ivyScala = None
)
new ivySbt.Module(moduleSetting) new ivySbt.Module(moduleSetting)
} }
@ -126,7 +126,7 @@ private[inc] class IvyComponentCompiler(compiler: RawCompiler, manager: Componen
private def update(module: ivySbt.Module, retrieveDirectory: File): Seq[File] = { private def update(module: ivySbt.Module, retrieveDirectory: File): Seq[File] = {
val retrieveConfiguration = new RetrieveConfiguration(retrieveDirectory, Resolver.defaultRetrievePattern, false) val retrieveConfiguration = new RetrieveConfiguration(retrieveDirectory, Resolver.defaultRetrievePattern, false, None)
val updateConfiguration = new UpdateConfiguration(Some(retrieveConfiguration), true, UpdateLogging.DownloadOnly, ArtifactTypeFilter.forbid(Set("doc"))) val updateConfiguration = new UpdateConfiguration(Some(retrieveConfiguration), true, UpdateLogging.DownloadOnly, ArtifactTypeFilter.forbid(Set("doc")))
buffered.info(s"Attempting to fetch ${dependenciesNames(module)}. This operation may fail.") buffered.info(s"Attempting to fetch ${dependenciesNames(module)}. This operation may fail.")

View File

@ -21,20 +21,20 @@ abstract class BridgeProviderSpecification extends BaseIvySpecification {
def realLocal: Resolver = def realLocal: Resolver =
{ {
val pList = s"$${user.home}/.ivy2/local/${Resolver.localBasePattern}" :: Nil val pList = Vector(s"$${user.home}/.ivy2/local/${Resolver.localBasePattern}")
FileRepository("local", Resolver.defaultFileConfiguration, Patterns(pList, pList, false)) FileRepository("local", Resolver.defaultFileConfiguration, Patterns().withIvyPatterns(pList).withArtifactPatterns(pList).withIsMavenCompatible(false))
} }
override def resolvers: Seq[Resolver] = Seq(realLocal, DefaultMavenRepository) override def resolvers: Vector[Resolver] = Vector(realLocal, DefaultMavenRepository)
private val ivyConfiguration = mkIvyConfiguration(UpdateOptions()) private val ivyConfiguration = mkIvyConfiguration(UpdateOptions())
def getCompilerBridge(targetDir: File, log: Logger, scalaVersion: String): File = { def getCompilerBridge(targetDir: File, log: Logger, scalaVersion: String): File = {
val instance = scalaInstance(scalaVersion) val instance = scalaInstance(scalaVersion)
val bridgeId = compilerBridgeId(scalaVersion) val bridgeId = compilerBridgeId(scalaVersion)
val sourceModule = ModuleID(xsbti.ArtifactInfo.SbtOrganization, bridgeId, ComponentCompiler.incrementalVersion, Some("component")).sources() val sourceModule = ModuleID(xsbti.ArtifactInfo.SbtOrganization, bridgeId, ComponentCompiler.incrementalVersion).withConfigurations(Some("component")).sources()
val raw = new RawCompiler(instance, ClasspathOptionsUtil.auto, log) val raw = new RawCompiler(instance, ClasspathOptionsUtil.auto, log)
val manager = new ComponentManager(lock, provider(targetDir), None, log) val manager = new ComponentManager(lock, provider(targetDir), None, log)
val componentCompiler = new IvyComponentCompiler(raw, manager, ivyConfiguration, sourceModule, log) val componentCompiler = new IvyComponentCompiler(raw, manager, ivyConfiguration, fileToStore, sourceModule, log)
val bridge = componentCompiler.apply() val bridge = componentCompiler.apply()
val target = targetDir / s"target-bridge-$scalaVersion.jar" val target = targetDir / s"target-bridge-$scalaVersion.jar"
@ -44,11 +44,11 @@ abstract class BridgeProviderSpecification extends BaseIvySpecification {
def scalaInstance(scalaVersion: String): ScalaInstance = { def scalaInstance(scalaVersion: String): ScalaInstance = {
val scalaModule = { val scalaModule = {
val dummyModule = ModuleID(JsonUtil.sbtOrgTemp, "tmp-scala-" + scalaVersion, scalaVersion, Some("compile")) val dummyModule = ModuleID(JsonUtil.sbtOrgTemp, "tmp-scala-" + scalaVersion, scalaVersion).withConfigurations(Some("compile"))
val scalaLibrary = ModuleID(xsbti.ArtifactInfo.ScalaOrganization, xsbti.ArtifactInfo.ScalaLibraryID, scalaVersion, Some("compile")) val scalaLibrary = ModuleID(xsbti.ArtifactInfo.ScalaOrganization, xsbti.ArtifactInfo.ScalaLibraryID, scalaVersion).withConfigurations(Some("compile"))
val scalaCompiler = ModuleID(xsbti.ArtifactInfo.ScalaOrganization, xsbti.ArtifactInfo.ScalaCompilerID, scalaVersion, Some("compile")) val scalaCompiler = ModuleID(xsbti.ArtifactInfo.ScalaOrganization, xsbti.ArtifactInfo.ScalaCompilerID, scalaVersion).withConfigurations(Some("compile"))
module(dummyModule, Seq(scalaLibrary, scalaCompiler), None) module(dummyModule, Vector(scalaLibrary, scalaCompiler), None)
} }
val allArtifacts = val allArtifacts =