mirror of https://github.com/sbt/sbt.git
Replace Ivy interface with the component from xsbt
This commit is contained in:
parent
9021b6c30d
commit
fa93a64cf9
|
|
@ -1,5 +1,6 @@
|
|||
package xsbt
|
||||
|
||||
import sbt.ComponentManager
|
||||
import xsbti.{AnalysisCallback, Logger => xLogger}
|
||||
import java.io.File
|
||||
import java.net.{URL, URLClassLoader}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package xsbt
|
||||
|
||||
import java.io.File
|
||||
import sbt.{ComponentManager, IfMissing}
|
||||
|
||||
object ComponentCompiler
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package xsbt
|
||||
|
||||
import sbt.{ComponentManager, TestIvyLogger}
|
||||
|
||||
import java.io.File
|
||||
import FileUtilities.withTemporaryDirectory
|
||||
import org.specs._
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package xsbt
|
||||
package sbt
|
||||
|
||||
import java.io.{File,FileOutputStream}
|
||||
import java.util.concurrent.Callable
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009 Mark Harrah
|
||||
*/
|
||||
package xsbt
|
||||
package sbt
|
||||
|
||||
import org.apache.ivy.{core,plugins}
|
||||
import core.module.id.ModuleRevisionId
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009 Mark Harrah
|
||||
*/
|
||||
package xsbt
|
||||
package sbt
|
||||
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.net.URL
|
||||
|
|
@ -14,7 +14,7 @@ import plugins.repository.Resource
|
|||
import plugins.repository.url.URLResource
|
||||
|
||||
/** Subclasses the default Ivy file parser in order to provide access to protected methods.*/
|
||||
private[xsbt] object CustomXmlParser extends XmlModuleDescriptorParser with NotNull
|
||||
private[sbt] object CustomXmlParser extends XmlModuleDescriptorParser with NotNull
|
||||
{
|
||||
import XmlModuleDescriptorParser.Parser
|
||||
class CustomParser(settings: IvySettings, defaultConfig: Option[String]) extends Parser(CustomXmlParser, settings) with NotNull
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009 Mark Harrah
|
||||
* Copyright 2008, 2009, 2010 Mark Harrah
|
||||
*/
|
||||
package xsbt
|
||||
package sbt
|
||||
|
||||
import Artifact.{defaultExtension, defaultType}
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ import util.Message
|
|||
|
||||
final class IvySbt(configuration: IvyConfiguration)
|
||||
{
|
||||
import configuration._
|
||||
import configuration.{log, baseDirectory}
|
||||
/** ========== Configuration/Setup ============
|
||||
* This part configures the Ivy instance by first creating the logger interface to ivy, then IvySettings, and then the Ivy instance.
|
||||
* These are lazy so that they are loaded within the right context. This is important so that no Ivy XML configuration needs to be loaded,
|
||||
|
|
@ -39,12 +39,15 @@ final class IvySbt(configuration: IvyConfiguration)
|
|||
private lazy val settings =
|
||||
{
|
||||
val is = new IvySettings
|
||||
is.setBaseDir(paths.baseDirectory)
|
||||
IvySbt.configureCache(is, paths.cacheDirectory)
|
||||
if(resolvers.isEmpty)
|
||||
autodetectConfiguration(is)
|
||||
else
|
||||
IvySbt.setResolvers(is, resolvers, log)
|
||||
is.setBaseDir(baseDirectory)
|
||||
configuration match
|
||||
{
|
||||
case e: ExternalIvyConfiguration => is.load(e.file)
|
||||
case i: InlineIvyConfiguration =>
|
||||
IvySbt.configureCache(is, i.paths.cacheDirectory)
|
||||
IvySbt.setResolvers(is, i.resolvers, log)
|
||||
IvySbt.setModuleConfigurations(is, i.moduleConfigurations)
|
||||
}
|
||||
is
|
||||
}
|
||||
private lazy val ivy =
|
||||
|
|
@ -53,17 +56,6 @@ final class IvySbt(configuration: IvyConfiguration)
|
|||
i.getLoggerEngine.pushLogger(logger)
|
||||
i
|
||||
}
|
||||
/** Called to configure Ivy when inline resolvers are not specified.
|
||||
* This will configure Ivy with an 'ivy-settings.xml' file if there is one or else use default resolvers.*/
|
||||
private def autodetectConfiguration(settings: IvySettings)
|
||||
{
|
||||
log.debug("Autodetecting configuration.")
|
||||
val defaultIvyConfigFile = IvySbt.defaultIvyConfiguration(paths.baseDirectory)
|
||||
if(defaultIvyConfigFile.canRead)
|
||||
settings.load(defaultIvyConfigFile)
|
||||
else
|
||||
IvySbt.setResolvers(settings, Resolver.withDefaultResolvers(Nil), log)
|
||||
}
|
||||
/** ========== End Configuration/Setup ============*/
|
||||
|
||||
/** Uses the configured Ivy instance within a safe context.*/
|
||||
|
|
@ -104,9 +96,7 @@ final class IvySbt(configuration: IvyConfiguration)
|
|||
|
||||
val parser = IvySbt.parseIvyXML(ivy.getSettings, IvySbt.wrapped(module, ivyXML), moduleID, defaultConf.name, validate)
|
||||
|
||||
IvySbt.addArtifacts(moduleID, artifacts)
|
||||
IvySbt.addDependencies(moduleID, dependencies, parser)
|
||||
IvySbt.setModuleConfigurations(settings, moduleConfigurations)
|
||||
IvySbt.addMainArtifact(moduleID)
|
||||
(moduleID, parser.getDefaultConf)
|
||||
}
|
||||
|
|
@ -115,6 +105,7 @@ final class IvySbt(configuration: IvyConfiguration)
|
|||
val mod = new DefaultModuleDescriptor(IvySbt.toID(module), "release", null, false)
|
||||
mod.setLastModified(System.currentTimeMillis)
|
||||
configurations.foreach(config => mod.addConfiguration(IvySbt.toIvyConfiguration(config)))
|
||||
IvySbt.addArtifacts(mod, module.explicitArtifacts)
|
||||
mod
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +292,7 @@ private object IvySbt
|
|||
/** This method is used to add inline artifacts to the provided module. */
|
||||
def addArtifacts(moduleID: DefaultModuleDescriptor, artifacts: Iterable[Artifact])
|
||||
{
|
||||
val allConfigurations = moduleID.getPublicConfigurationsNames
|
||||
lazy val allConfigurations = moduleID.getPublicConfigurationsNames
|
||||
for(artifact <- artifacts)
|
||||
{
|
||||
val configurationStrings =
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package xsbt
|
||||
package sbt
|
||||
|
||||
import java.io.File
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package xsbt
|
||||
package sbt
|
||||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
|
|
@ -83,7 +83,7 @@ object IvyCache
|
|||
{
|
||||
val local = Resolver.defaultLocal
|
||||
val paths = new IvyPaths(new File("."), None)
|
||||
val conf = new IvyConfiguration(paths, Seq(local), Nil, log)
|
||||
val conf = new InlineIvyConfiguration(paths, Seq(local), Nil, log)
|
||||
(new IvySbt(conf), local)
|
||||
}
|
||||
/** Creates a default jar artifact based on the given ID.*/
|
||||
|
|
|
|||
|
|
@ -1,30 +1,70 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009 Mark Harrah
|
||||
* Copyright 2008, 2009, 2010 Mark Harrah
|
||||
*/
|
||||
package xsbt
|
||||
package sbt
|
||||
|
||||
import java.io.File
|
||||
import scala.xml.NodeSeq
|
||||
|
||||
final class IvyPaths(val baseDirectory: File, val cacheDirectory: Option[File]) extends NotNull
|
||||
final class IvyConfiguration(val paths: IvyPaths, val resolvers: Seq[Resolver],
|
||||
val moduleConfigurations: Seq[ModuleConfiguration], val log: IvyLogger) extends NotNull
|
||||
|
||||
sealed trait IvyConfiguration extends NotNull
|
||||
{
|
||||
def baseDirectory: File
|
||||
def log: IvyLogger
|
||||
}
|
||||
final class InlineIvyConfiguration(val paths: IvyPaths, val resolvers: Seq[Resolver],
|
||||
val moduleConfigurations: Seq[ModuleConfiguration], val log: IvyLogger) extends IvyConfiguration
|
||||
{
|
||||
def baseDirectory = paths.baseDirectory
|
||||
}
|
||||
final class ExternalIvyConfiguration(val baseDirectory: File, val file: File, val log: IvyLogger) extends IvyConfiguration
|
||||
|
||||
object IvyConfiguration
|
||||
{
|
||||
/** Called to configure Ivy when inline resolvers are not specified.
|
||||
* This will configure Ivy with an 'ivy-settings.xml' file if there is one or else use default resolvers.*/
|
||||
def apply(paths: IvyPaths, log: IvyLogger): IvyConfiguration =
|
||||
{
|
||||
log.debug("Autodetecting configuration.")
|
||||
val defaultIvyConfigFile = IvySbt.defaultIvyConfiguration(paths.baseDirectory)
|
||||
if(defaultIvyConfigFile.canRead)
|
||||
new ExternalIvyConfiguration(paths.baseDirectory, defaultIvyConfigFile, log)
|
||||
else
|
||||
new InlineIvyConfiguration(paths, Resolver.withDefaultResolvers(Nil), Nil, log)
|
||||
}
|
||||
}
|
||||
|
||||
sealed trait ModuleSettings extends NotNull
|
||||
{
|
||||
def validate: Boolean
|
||||
def ivyScala: Option[IvyScala]
|
||||
def noScala: ModuleSettings
|
||||
}
|
||||
final class IvyFileConfiguration(val file: File, val ivyScala: Option[IvyScala], val validate: Boolean) extends ModuleSettings
|
||||
{
|
||||
def noScala = new IvyFileConfiguration(file, None, validate)
|
||||
}
|
||||
final class PomConfiguration(val file: File, val ivyScala: Option[IvyScala], val validate: Boolean) extends ModuleSettings
|
||||
{
|
||||
def noScala = new PomConfiguration(file, None, validate)
|
||||
}
|
||||
final class InlineConfiguration(val module: ModuleID, val dependencies: Iterable[ModuleID], val ivyXML: NodeSeq,
|
||||
val configurations: Iterable[Configuration], val defaultConfiguration: Option[Configuration], val ivyScala: Option[IvyScala],
|
||||
val artifacts: Iterable[Artifact], val validate: Boolean) extends ModuleSettings
|
||||
val validate: Boolean) extends ModuleSettings
|
||||
{
|
||||
def withConfigurations(configurations: Iterable[Configuration]) =
|
||||
new InlineConfiguration(module, dependencies, ivyXML, configurations, defaultConfiguration, None, validate)
|
||||
def noScala = new InlineConfiguration(module, dependencies, ivyXML, configurations, defaultConfiguration, None, validate)
|
||||
}
|
||||
final class EmptyConfiguration(val module: ModuleID, val ivyScala: Option[IvyScala], val validate: Boolean) extends ModuleSettings
|
||||
{
|
||||
def noScala = new EmptyConfiguration(module, None, validate)
|
||||
}
|
||||
object InlineConfiguration
|
||||
{
|
||||
def apply(module: ModuleID, dependencies: Iterable[ModuleID], artifacts: Iterable[Artifact]) =
|
||||
new InlineConfiguration(module, dependencies, NodeSeq.Empty, Nil, None, None, artifacts, false)
|
||||
def apply(module: ModuleID, dependencies: Iterable[ModuleID]) =
|
||||
new InlineConfiguration(module, dependencies, NodeSeq.Empty, Nil, None, None, false)
|
||||
def configurations(explicitConfigurations: Iterable[Configuration], defaultConfiguration: Option[Configuration]) =
|
||||
if(explicitConfigurations.isEmpty)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009 Mark Harrah
|
||||
*/
|
||||
package xsbt
|
||||
package sbt
|
||||
|
||||
import java.io.File
|
||||
import java.net.{URI, URL}
|
||||
|
|
@ -52,9 +52,9 @@ sealed case class MavenRepository(name: String, root: String) extends Resolver
|
|||
|
||||
final class Patterns(val ivyPatterns: Seq[String], val artifactPatterns: Seq[String], val isMavenCompatible: Boolean) extends NotNull
|
||||
{
|
||||
private[xsbt] def mavenStyle(): Patterns = Patterns(ivyPatterns, artifactPatterns, true)
|
||||
private[xsbt] def withIvys(patterns: Seq[String]): Patterns = Patterns(patterns ++ ivyPatterns, artifactPatterns, isMavenCompatible)
|
||||
private[xsbt] def withArtifacts(patterns: Seq[String]): Patterns = Patterns(ivyPatterns, patterns ++ artifactPatterns, isMavenCompatible)
|
||||
private[sbt] def mavenStyle(): Patterns = Patterns(ivyPatterns, artifactPatterns, true)
|
||||
private[sbt] def withIvys(patterns: Seq[String]): Patterns = Patterns(patterns ++ ivyPatterns, artifactPatterns, isMavenCompatible)
|
||||
private[sbt] def withArtifacts(patterns: Seq[String]): Patterns = Patterns(ivyPatterns, patterns ++ artifactPatterns, isMavenCompatible)
|
||||
}
|
||||
object Patterns
|
||||
{
|
||||
|
|
@ -295,11 +295,11 @@ object Configurations
|
|||
|
||||
lazy val CompilerPlugin = config("plugin") hide
|
||||
|
||||
private[xsbt] val DefaultMavenConfiguration = defaultConfiguration(true)
|
||||
private[xsbt] val DefaultIvyConfiguration = defaultConfiguration(false)
|
||||
private[xsbt] def DefaultConfiguration(mavenStyle: Boolean) = if(mavenStyle) DefaultMavenConfiguration else DefaultIvyConfiguration
|
||||
private[xsbt] def defaultConfiguration(mavenStyle: Boolean) = if(mavenStyle) Configurations.Compile else Configurations.Default
|
||||
private[xsbt] def removeDuplicates(configs: Iterable[Configuration]) = Set(scala.collection.mutable.Map(configs.map(config => (config.name, config)).toSeq: _*).values.toList: _*)
|
||||
private[sbt] val DefaultMavenConfiguration = defaultConfiguration(true)
|
||||
private[sbt] val DefaultIvyConfiguration = defaultConfiguration(false)
|
||||
private[sbt] def DefaultConfiguration(mavenStyle: Boolean) = if(mavenStyle) DefaultMavenConfiguration else DefaultIvyConfiguration
|
||||
private[sbt] def defaultConfiguration(mavenStyle: Boolean) = if(mavenStyle) Configurations.Compile else Configurations.Default
|
||||
private[sbt] def removeDuplicates(configs: Iterable[Configuration]) = Set(scala.collection.mutable.Map(configs.map(config => (config.name, config)).toSeq: _*).values.toList: _*)
|
||||
}
|
||||
/** Represents an Ivy configuration. */
|
||||
final case class Configuration(name: String, description: String, isPublic: Boolean, extendsConfigs: List[Configuration], transitive: Boolean) extends NotNull
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009 Mark Harrah
|
||||
*/
|
||||
package xsbt
|
||||
package sbt
|
||||
|
||||
import org.apache.ivy.util.{Message, MessageLogger}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009 Mark Harrah
|
||||
* Copyright 2008, 2009, 2010 Mark Harrah
|
||||
*/
|
||||
package xsbt
|
||||
package sbt
|
||||
|
||||
import java.util.Collections
|
||||
import scala.collection.mutable.HashSet
|
||||
|
|
@ -12,13 +12,18 @@ import core.module.descriptor.{DefaultModuleDescriptor, ModuleDescriptor}
|
|||
import core.module.id.{ArtifactId,ModuleId, ModuleRevisionId}
|
||||
import plugins.matcher.ExactPatternMatcher
|
||||
|
||||
object ScalaArtifacts
|
||||
{
|
||||
val Organization = "org.scala-lang"
|
||||
val LibraryID = "scala-library"
|
||||
val CompilerID = "scala-compiler"
|
||||
}
|
||||
|
||||
import ScalaArtifacts._
|
||||
|
||||
final class IvyScala(val scalaVersion: String, val configurations: Iterable[Configuration], val checkExplicit: Boolean, val filterImplicit: Boolean) extends NotNull
|
||||
private object IvyScala
|
||||
{
|
||||
val ScalaOrganization = "org.scala-lang"
|
||||
val ScalaLibraryID = "scala-library"
|
||||
val ScalaCompilerID = "scala-compiler"
|
||||
|
||||
/** Performs checks/adds filters on Scala dependencies (if enabled in IvyScala). */
|
||||
def checkModule(module: DefaultModuleDescriptor, conf: String)(check: IvyScala)
|
||||
{
|
||||
|
|
@ -35,7 +40,7 @@ private object IvyScala
|
|||
for(dep <- module.getDependencies.toList)
|
||||
{
|
||||
val id = dep.getDependencyRevisionId
|
||||
if(id.getOrganisation == ScalaOrganization && id.getRevision != scalaVersion && dep.getModuleConfigurations.exists(configSet.contains))
|
||||
if(id.getOrganisation == Organization && id.getRevision != scalaVersion && dep.getModuleConfigurations.exists(configSet.contains))
|
||||
error("Different Scala version specified in dependency ("+ id.getRevision + ") than in project (" + scalaVersion + ").")
|
||||
}
|
||||
}
|
||||
|
|
@ -58,9 +63,9 @@ private object IvyScala
|
|||
}
|
||||
}
|
||||
def excludeScalaJar(name: String): Unit =
|
||||
module.addExcludeRule(excludeRule(ScalaOrganization, name, configurationNames))
|
||||
excludeScalaJar(ScalaLibraryID)
|
||||
excludeScalaJar(ScalaCompilerID)
|
||||
module.addExcludeRule(excludeRule(Organization, name, configurationNames))
|
||||
excludeScalaJar(LibraryID)
|
||||
excludeScalaJar(CompilerID)
|
||||
}
|
||||
/** Creates an ExcludeRule that excludes artifacts with the given module organization and name for
|
||||
* the given configurations. */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
package xsbt
|
||||
package sbt
|
||||
|
||||
import xsbt.{BufferedLogger, FileUtilities}
|
||||
|
||||
import java.io.File
|
||||
import org.specs._
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
package xsbt
|
||||
package sbt
|
||||
|
||||
import xsbt.{BufferedLogger, ConsoleLogger, Level}
|
||||
|
||||
class TestIvyLogger extends BufferedLogger(new ConsoleLogger) with IvyLogger { def verbose(msg: => String) = info(msg) }
|
||||
object TestIvyLogger
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#Project properties
|
||||
#Tue Dec 29 21:21:49 EST 2009
|
||||
project.organization=org.scala-tools.sbt
|
||||
project.name=xsbt
|
||||
sbt.version=0.5.6
|
||||
project.version=0.6.10-SNAPSHOT
|
||||
sbt.version=0.5.7-SNAPSHOT
|
||||
project.version=0.6.11-SNAPSHOT
|
||||
scala.version=2.7.7
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class XSbt(info: ProjectInfo) extends ParentProject(info)
|
|||
/* Subproject configurations*/
|
||||
class LaunchProject(info: ProjectInfo) extends Base(info) with TestWithIO with TestDependencies with ProguardLaunch
|
||||
{
|
||||
val jline = "jline" % "jline" % jlineRev
|
||||
val jline = "jline" % "jline" % jlineRev intransitive()
|
||||
val ivy = "org.apache.ivy" % "ivy" % "2.0.0"
|
||||
def rawJarPath = jarPath
|
||||
override final def crossScalaVersions = Set.empty // don't need to cross-build, since the distributed jar is standalone (proguard)
|
||||
|
|
@ -171,7 +171,7 @@ class XSbt(info: ProjectInfo) extends ParentProject(info)
|
|||
override def componentID = Some(cID)
|
||||
override def ivyXML =
|
||||
<dependencies>
|
||||
<dependency org="jline" name="jline" rev={jlineRev}>
|
||||
<dependency org="jline" name="jline" rev={jlineRev} transitive="false">
|
||||
<artifact name="jline" type="jar" e:component={cID}/>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
|||
Loading…
Reference in New Issue