* Cleanup

* Exposed ClasspathUtilities.toLoader(PathFinder) methods
 * Implemented adding project dependencies for Ivy files



git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@885 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
dmharrah 2009-07-26 19:25:54 +00:00
parent 6cbe27ed95
commit ff97bbec4b
5 changed files with 19 additions and 12 deletions

View File

@ -391,19 +391,24 @@ trait BasicManagedProject extends ManagedProject with ReflectiveManagedProject w
Nil Nil
pathPatterns.map(_.relativePath) pathPatterns.map(_.relativePath)
} }
def extraDependencies: Iterable[ModuleID] = Nil//deliverProjectDependencies def extraDependencies: Iterable[ModuleID] = deliverProjectDependencies
/** The configurations to include in the publish/deliver action: specify none for all public configurations. */ /** The configurations to include in the publish/deliver action: specify none for all public configurations. */
def configurations: Option[Iterable[Configuration]] = None def configurations: Option[Iterable[Configuration]] = None
} }
private[this] def depMap[T](f: BasicManagedProject => T) =
topologicalSort.dropRight(1).flatMap { case m: BasicManagedProject => f(m) :: Nil; case _ => Nil }
lazy val update = updateAction lazy val update = updateAction
lazy val makePom = makePomAction lazy val makePom = makePomAction
lazy val deliverLocal = deliverLocalAction
lazy val publishLocal = publishLocalAction
lazy val deliver = deliverAction
lazy val publish = publishAction
lazy val cleanLib = cleanLibAction lazy val cleanLib = cleanLibAction
lazy val cleanCache = cleanCacheAction lazy val cleanCache = cleanCacheAction
// deliver must run after its dependencies' `publish` so that the artifacts produced by the dependencies can be resolved
// (deliver requires a resolve first)
lazy val deliverLocal: Task = deliverLocalAction dependsOn(depMap(_.publishLocal) : _*)
lazy val publishLocal: Task = publishLocalAction
lazy val deliver: Task = deliverAction dependsOn(depMap(_.publish) : _*)
lazy val publish: Task = publishAction
} }
object BasicManagedProject object BasicManagedProject

View File

@ -9,7 +9,7 @@ import java.util.Collections
import scala.collection.Set import scala.collection.Set
import scala.collection.mutable.{HashSet, ListBuffer} import scala.collection.mutable.{HashSet, ListBuffer}
private[sbt] object ClasspathUtilities object ClasspathUtilities
{ {
def toClasspath(finder: PathFinder): Array[URL] = toClasspath(finder.get) def toClasspath(finder: PathFinder): Array[URL] = toClasspath(finder.get)
def toClasspath(paths: Iterable[Path]): Array[URL] = paths.map(_.asURL).toSeq.toArray def toClasspath(paths: Iterable[Path]): Array[URL] = paths.map(_.asURL).toSeq.toArray
@ -18,13 +18,16 @@ private[sbt] object ClasspathUtilities
def toLoader(paths: Iterable[Path]): ClassLoader = new URLClassLoader(toClasspath(paths), getClass.getClassLoader) def toLoader(paths: Iterable[Path]): ClassLoader = new URLClassLoader(toClasspath(paths), getClass.getClassLoader)
def toLoader(paths: Iterable[Path], parent: ClassLoader): ClassLoader = new URLClassLoader(toClasspath(paths), parent) def toLoader(paths: Iterable[Path], parent: ClassLoader): ClassLoader = new URLClassLoader(toClasspath(paths), parent)
private[sbt] def printSource(c: Class[_]) =
println(c.getName + " loader=" +c.getClassLoader + " location=" + FileUtilities.classLocationFile(c))
def isArchive(path: Path): Boolean = isArchive(path.asFile) def isArchive(path: Path): Boolean = isArchive(path.asFile)
def isArchive(file: File): Boolean = isArchiveName(file.getName) def isArchive(file: File): Boolean = isArchiveName(file.getName)
def isArchiveName(fileName: String) = fileName.endsWith(".jar") || fileName.endsWith(".zip") def isArchiveName(fileName: String) = fileName.endsWith(".jar") || fileName.endsWith(".zip")
// Partitions the given classpath into (jars, directories) // Partitions the given classpath into (jars, directories)
def separate(paths: Iterable[File]): (Iterable[File], Iterable[File]) = paths.partition(isArchive) private[sbt] def separate(paths: Iterable[File]): (Iterable[File], Iterable[File]) = paths.partition(isArchive)
// Partitions the given classpath into (jars, directories) // Partitions the given classpath into (jars, directories)
def separatePaths(paths: Iterable[Path]) = separate(paths.map(_.asFile.getCanonicalFile)) private[sbt] def separatePaths(paths: Iterable[Path]) = separate(paths.map(_.asFile.getCanonicalFile))
private[sbt] def buildSearchPaths(classpath: Iterable[Path]): (wrap.Set[File], wrap.Set[File]) = private[sbt] def buildSearchPaths(classpath: Iterable[Path]): (wrap.Set[File], wrap.Set[File]) =
{ {
val (jars, dirs) = separatePaths(classpath) val (jars, dirs) = separatePaths(classpath)
@ -40,7 +43,7 @@ private[sbt] object ClasspathUtilities
} }
/** Returns all entries in 'classpath' that correspond to a compiler plugin.*/ /** Returns all entries in 'classpath' that correspond to a compiler plugin.*/
def compilerPlugins(classpath: Iterable[Path]): Iterable[File] = private[sbt] def compilerPlugins(classpath: Iterable[Path]): Iterable[File] =
{ {
val loader = new URLClassLoader(classpath.map(_.asURL).toList.toArray) val loader = new URLClassLoader(classpath.map(_.asURL).toList.toArray)
wrap.Wrappers.toList(loader.getResources("scalac-plugin.xml")).flatMap(asFile) wrap.Wrappers.toList(loader.getResources("scalac-plugin.xml")).flatMap(asFile)

View File

@ -35,7 +35,6 @@ abstract class Logger extends NotNull
def log(level: Level.Value, message: => String): Unit def log(level: Level.Value, message: => String): Unit
def control(event: ControlEvent.Value, message: => String): Unit def control(event: ControlEvent.Value, message: => String): Unit
/** Use this method to ensure calls. */
def logAll(events: Seq[LogEvent]): Unit def logAll(events: Seq[LogEvent]): Unit
/** Defined in terms of other methods in Logger and should not be called from them. */ /** Defined in terms of other methods in Logger and should not be called from them. */
final def log(event: LogEvent) final def log(event: LogEvent)

View File

@ -408,7 +408,7 @@ object ManageDependencies
Control.trapUnit("Could not deliver: ", ivyConfig.log) Control.trapUnit("Could not deliver: ", ivyConfig.log)
{ {
val module = addLateDependencies(ivy, md, default, extraDependencies) val module = addLateDependencies(ivy, md, default, extraDependencies)
resolve(ivy, updateConfig, module) orElse resolve(ivy, updateConfig, module) orElse // todo: set download = false for resolve
{ {
val revID = module.getModuleRevisionId val revID = module.getModuleRevisionId
val options = DeliverOptions.newInstance(ivy.getSettings).setStatus(status) val options = DeliverOptions.newInstance(ivy.getSettings).setStatus(status)

View File

@ -82,7 +82,7 @@ trait TaskManager{
def work = createWork def work = createWork
} }
def dynamic(createTask: => Project#Task) = new CompoundTask(SubWork[Project#Task](checkDynamic(createTask))) def dynamic(createTask: => Project#Task) = new CompoundTask(SubWork[Project#Task](checkDynamic(createTask)))
@deprecated def compoundTask(createTask: => Project#Task) = dynamic(createTask)
/** Verifies that the given dynamically created task does not depend on any statically defined tasks. /** Verifies that the given dynamically created task does not depend on any statically defined tasks.
* Returns the task if it is valid.*/ * Returns the task if it is valid.*/
private def checkDynamic(task: Project#Task) = private def checkDynamic(task: Project#Task) =