diff --git a/compile/AnalyzingCompiler.scala b/compile/AnalyzingCompiler.scala index e8c70ff40..a18799814 100644 --- a/compile/AnalyzingCompiler.scala +++ b/compile/AnalyzingCompiler.scala @@ -1,5 +1,6 @@ package xsbt + import sbt.ComponentManager import xsbti.{AnalysisCallback, Logger => xLogger} import java.io.File import java.net.{URL, URLClassLoader} diff --git a/compile/ComponentCompiler.scala b/compile/ComponentCompiler.scala index 2372f0da9..d8522168b 100644 --- a/compile/ComponentCompiler.scala +++ b/compile/ComponentCompiler.scala @@ -1,6 +1,7 @@ package xsbt import java.io.File +import sbt.{ComponentManager, IfMissing} object ComponentCompiler { diff --git a/compile/src/test/scala/CompileTest.scala b/compile/src/test/scala/CompileTest.scala index 92d0a1c07..1ef98efbf 100644 --- a/compile/src/test/scala/CompileTest.scala +++ b/compile/src/test/scala/CompileTest.scala @@ -1,5 +1,7 @@ package xsbt +import sbt.{ComponentManager, TestIvyLogger} + import java.io.File import FileUtilities.withTemporaryDirectory import org.specs._ diff --git a/ivy/ComponentManager.scala b/ivy/ComponentManager.scala index fc4606f6d..5e2c8bd51 100644 --- a/ivy/ComponentManager.scala +++ b/ivy/ComponentManager.scala @@ -1,4 +1,4 @@ -package xsbt +package sbt import java.io.{File,FileOutputStream} import java.util.concurrent.Callable diff --git a/ivy/ConvertResolver.scala b/ivy/ConvertResolver.scala index 6625e604e..1d9ec9414 100644 --- a/ivy/ConvertResolver.scala +++ b/ivy/ConvertResolver.scala @@ -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 diff --git a/ivy/CustomXmlParser.scala b/ivy/CustomXmlParser.scala index 1c4d88b0c..f80eed9b9 100644 --- a/ivy/CustomXmlParser.scala +++ b/ivy/CustomXmlParser.scala @@ -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 diff --git a/ivy/Ivy.scala b/ivy/Ivy.scala index 485a6fcf4..a92e818b6 100644 --- a/ivy/Ivy.scala +++ b/ivy/Ivy.scala @@ -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 = diff --git a/ivy/IvyActions.scala b/ivy/IvyActions.scala index f738a3912..5c4ddf2fb 100644 --- a/ivy/IvyActions.scala +++ b/ivy/IvyActions.scala @@ -1,4 +1,4 @@ -package xsbt +package sbt import java.io.File diff --git a/ivy/IvyCache.scala b/ivy/IvyCache.scala index cfb829458..64ccfd907 100644 --- a/ivy/IvyCache.scala +++ b/ivy/IvyCache.scala @@ -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.*/ diff --git a/ivy/IvyConfigurations.scala b/ivy/IvyConfigurations.scala index 29cbd15ab..ed2fccc55 100644 --- a/ivy/IvyConfigurations.scala +++ b/ivy/IvyConfigurations.scala @@ -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) { diff --git a/ivy/IvyInterface.scala b/ivy/IvyInterface.scala index d44179deb..213e959e2 100644 --- a/ivy/IvyInterface.scala +++ b/ivy/IvyInterface.scala @@ -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 diff --git a/ivy/IvyLogger.scala b/ivy/IvyLogger.scala index c58ffd054..7b062d7af 100644 --- a/ivy/IvyLogger.scala +++ b/ivy/IvyLogger.scala @@ -1,7 +1,7 @@ /* sbt -- Simple Build Tool * Copyright 2008, 2009 Mark Harrah */ -package xsbt +package sbt import org.apache.ivy.util.{Message, MessageLogger} diff --git a/ivy/IvyScala.scala b/ivy/IvyScala.scala index 0f3332d34..38ea1bd84 100644 --- a/ivy/IvyScala.scala +++ b/ivy/IvyScala.scala @@ -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. */ diff --git a/ivy/src/test/scala/ComponentManagerTest.scala b/ivy/src/test/scala/ComponentManagerTest.scala index 446cec24e..ec29ae476 100644 --- a/ivy/src/test/scala/ComponentManagerTest.scala +++ b/ivy/src/test/scala/ComponentManagerTest.scala @@ -1,4 +1,6 @@ -package xsbt +package sbt + +import xsbt.{BufferedLogger, FileUtilities} import java.io.File import org.specs._ diff --git a/ivy/src/test/scala/TestIvyLogger.scala b/ivy/src/test/scala/TestIvyLogger.scala index 9d987b806..bf4386d7f 100644 --- a/ivy/src/test/scala/TestIvyLogger.scala +++ b/ivy/src/test/scala/TestIvyLogger.scala @@ -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 diff --git a/project/build.properties b/project/build.properties index 1e3813844..c4e0cf87c 100644 --- a/project/build.properties +++ b/project/build.properties @@ -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 diff --git a/project/build/XSbt.scala b/project/build/XSbt.scala index 86f4dcdc2..13b728e09 100644 --- a/project/build/XSbt.scala +++ b/project/build/XSbt.scala @@ -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 = - +