better default behavior for classpathConfiguration for external Ivy files. fixes #214

This commit is contained in:
Mark Harrah 2011-10-05 18:14:32 -04:00
parent 0f447c201e
commit 09a87a3bc6
6 changed files with 19 additions and 6 deletions

View File

@ -7,6 +7,7 @@ package sbt
import Scope.{fillTaskAxis, GlobalScope, ThisScope}
import xsbt.api.Discovery
import Project.{inConfig, Initialize, inScope, inTask, ScopedKey, Setting, SettingsDefinition}
import Load.LoadedBuild
import Artifact.{DocClassifier, SourceClassifier}
import Configurations.{Compile, CompilerPlugin, IntegrationTest, names, Provided, Runtime, Test}
import complete._
@ -539,12 +540,12 @@ object Defaults extends BuildCommon
transitiveDependencies(base, lb, includeRoot, classpath, aggregate) map ( ref => (key in ref) ?? default(ref) ) join ;
}
def transitiveDependencies(base: ProjectRef, structure: Load.LoadedBuild, includeRoot: Boolean, classpath: Boolean = true, aggregate: Boolean = false): Seq[ProjectRef] =
def transitiveDependencies(base: ProjectRef, structure: LoadedBuild, includeRoot: Boolean, classpath: Boolean = true, aggregate: Boolean = false): Seq[ProjectRef] =
{
val full = Dag.topologicalSort(base)(getDependencies(structure, classpath, aggregate))
if(includeRoot) full else full.dropRight(1)
}
def getDependencies(structure: Load.LoadedBuild, classpath: Boolean = true, aggregate: Boolean = false): ProjectRef => Seq[ProjectRef] =
def getDependencies(structure: LoadedBuild, classpath: Boolean = true, aggregate: Boolean = false): ProjectRef => Seq[ProjectRef] =
ref => Project.getProject(ref, structure).toList flatMap { p =>
(if(classpath) p.dependencies.map(_.project) else Nil) ++
(if(aggregate) p.aggregate else Nil)
@ -594,7 +595,7 @@ object Classpaths
products <<= makeProducts,
productDirectories <<= compileInputs map (_.config.classesDirectory :: Nil),
exportedProducts <<= exportProductsTask,
classpathConfiguration <<= (internalConfigurationMap, configuration)( _ apply _ ),
classpathConfiguration <<= (internalConfigurationMap, configuration, classpathConfiguration.?, update.task) apply findClasspathConfig,
managedClasspath <<= (classpathConfiguration, classpathTypes, update) map managedJars,
// remove when defaultExcludes and classpathFilter are removed
excludeFilter in unmanagedJars <<= (defaultExcludes in unmanagedJars) or (excludeFilter in unmanagedJars),
@ -608,6 +609,14 @@ object Classpaths
for(task <- defaultPackageKeys; conf <- Seq(Compile, Test)) yield (task in conf)
lazy val defaultArtifactTasks: Seq[ScopedTask[File]] = makePom +: defaultPackages
def findClasspathConfig(map: Configuration => Configuration, thisConfig: Configuration, delegate: Task[Option[Configuration]], up: Task[UpdateReport]): Task[Configuration] =
(delegate :^: up :^: KNil) map { case delegated :+: report :+: HNil =>
val defined = report.allConfigurations.toSet
val search = map(thisConfig) +: (delegated.toList ++ Seq(Compile, Configurations.Default))
def notFound = error("Configuration to use for managed classpath must be explicitly defined when default configurations are not present.")
search find { defined contains _.name } getOrElse notFound
}
def packaged(pkgTasks: Seq[ScopedTask[File]]): Initialize[Task[Map[Artifact, File]]] =
enabledOnly(packagedArtifact.task, pkgTasks) apply (_.join.map(_.toMap))
def artifactDefs(pkgTasks: Seq[ScopedTask[File]]): Initialize[Seq[Artifact]] =

View File

@ -219,7 +219,7 @@ object Keys
val fullClasspath = TaskKey[Classpath]("full-classpath", "The exported classpath, consisting of build products and unmanaged and managed, internal and external dependencies.")
val internalConfigurationMap = SettingKey[Configuration => Configuration]("internal-configuration-map", "Maps configurations to the actual configuration used to define the classpath.")
val classpathConfiguration = SettingKey[Configuration]("classpath-configuration", "The configuration used to define the classpath.")
val classpathConfiguration = TaskKey[Configuration]("classpath-configuration", "The configuration used to define the classpath.")
val ivyConfiguration = TaskKey[IvyConfiguration]("ivy-configuration", "General dependency management (Ivy) settings, such as the resolvers and paths to use.")
val ivyConfigurations = SettingKey[Seq[Configuration]]("ivy-configurations", "The defined configurations for dependency management. This may be different from the configurations for Project settings.")
val moduleSettings = TaskKey[ModuleSettings]("module-settings", "Module settings, which configure a specific module, such as a project.")

View File

@ -1,6 +1,6 @@
seq(externalIvySettings(), externalIvyFile())
TaskKey[Unit]("check") <<= (baseDirectory, update) map { (base, report) =>
val files = report.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck", revision = "1.5") )
val files = report.matching( moduleFilter(organization = "org.scala-tools.testing", name = "scalacheck*", revision = "1.9") )
assert(!files.isEmpty, "ScalaCheck module not found in update report")
}

View File

@ -2,6 +2,6 @@
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="org" module="ivy-settings-test"/>
<dependencies>
<dependency org="org.scalacheck" name="scalacheck" rev="1.5"/>
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>
</dependencies>
</ivy-module>

View File

@ -0,0 +1,3 @@
import org.scalacheck._
object Test extends Properties("Test")

View File

@ -5,3 +5,4 @@ $ copy-file changes/scalacheck-ivy.xml ivy.xml
$ copy-file changes/scala-tools-ivysettings.xml ivysettings.xml
> check
> test:compile