mirror of https://github.com/sbt/sbt.git
Fix issue with parent project defining non-existing jar artifact
git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@987 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
parent
eaabe0b85f
commit
3cea48116f
|
|
@ -10,7 +10,7 @@ trait ClasspathProject extends Project
|
|||
{
|
||||
/** The local classpath for this project.*/
|
||||
def projectClasspath(config: Configuration): PathFinder
|
||||
|
||||
|
||||
/** Returns the classpath of this project and the classpaths of all dependencies for the
|
||||
* given configuration. Specifically, this concatentates projectClasspath(config) for all
|
||||
* projects of type ClasspathProject in topologicalSort. */
|
||||
|
|
@ -77,7 +77,7 @@ trait ManagedProject extends ClasspathProject
|
|||
/** An update option that overrides the default Ivy cache location. */
|
||||
final case class CacheDirectory(dir: Path) extends ManagedOption
|
||||
final case class CheckScalaVersion(configs: Iterable[Configuration], checkExplicit: Boolean, filterImplicit: Boolean) extends ManagedOption
|
||||
|
||||
|
||||
protected def withConfigurations(outputPattern: String, managedDependencyPath: Path, options: Seq[ManagedOption])
|
||||
(doWith: (IvyConfiguration, UpdateConfiguration) => Option[String]) =
|
||||
{
|
||||
|
|
@ -132,7 +132,7 @@ trait ManagedProject extends ClasspathProject
|
|||
updateTask(outputPattern, managedDependencyPath, options)
|
||||
def updateTask(outputPattern: String, managedDependencyPath: Path, options: => Seq[ManagedOption]) =
|
||||
withIvyTask(withConfigurations(outputPattern, managedDependencyPath, options)(ManageDependencies.update))
|
||||
|
||||
|
||||
def publishTask(publishConfiguration: => PublishConfiguration, options: => Seq[ManagedOption]) =
|
||||
withIvyTask
|
||||
{
|
||||
|
|
@ -154,23 +154,23 @@ trait ManagedProject extends ClasspathProject
|
|||
def makePomTask(output: => Path, extraDependencies: => Iterable[ModuleID], configurations: => Option[Iterable[Configuration]], options: => Seq[ManagedOption]) =
|
||||
withIvyTask(withConfigurations("", managedDependencyPath, options) { (ivyConf, ignore) =>
|
||||
ManageDependencies.makePom(ivyConf, extraDependencies, configurations, output.asFile) })
|
||||
|
||||
|
||||
def cleanCacheTask(managedDependencyPath: Path, options: => Seq[ManagedOption]) =
|
||||
withIvyTask(withConfigurations("", managedDependencyPath, options) { (ivyConf, ignore) => ManageDependencies.cleanCache(ivyConf) })
|
||||
|
||||
|
||||
def cleanLibTask(managedDependencyPath: Path) = task { FileUtilities.clean(managedDependencyPath.get, log) }
|
||||
|
||||
/** This is the public ID of the project (used for publishing, for example) */
|
||||
def moduleID: String = normalizedName + appendable(crossScalaVersionString)
|
||||
/** This is the full public ID of the project (used for publishing, for example) */
|
||||
def projectID: ModuleID = ModuleID(organization, moduleID, version.toString)
|
||||
def projectID: ModuleID = ModuleID(organization, moduleID, version.toString).artifacts(artifacts.toSeq : _*)
|
||||
|
||||
/** This is the default name for artifacts (such as jars) without any version string.*/
|
||||
def artifactID = moduleID
|
||||
/** This is the default name for artifacts (such as jars) including the version string.*/
|
||||
def artifactBaseName = artifactID + "-" + version.toString
|
||||
def artifacts: Iterable[Artifact]
|
||||
|
||||
|
||||
def managedDependencyPath: Path
|
||||
/** The managed classpath for the given configuration. This can be overridden to add jars from other configurations
|
||||
* so that the Ivy 'extends' mechanism is not required. That way, the jars are only copied to one configuration.*/
|
||||
|
|
@ -179,7 +179,7 @@ trait ManagedProject extends ClasspathProject
|
|||
final def configurationClasspath(config: Configuration): PathFinder = descendents(configurationPath(config), "*.jar")
|
||||
/** The base path to which dependencies in configuration 'config' are downloaded.*/
|
||||
def configurationPath(config: Configuration): Path = managedDependencyPath / config.toString
|
||||
|
||||
|
||||
import StringUtilities.nonEmpty
|
||||
implicit def toGroupID(groupID: String): GroupID =
|
||||
{
|
||||
|
|
@ -196,7 +196,7 @@ trait ManagedProject extends ClasspathProject
|
|||
require(m.configurations.isEmpty, "Configurations already specified for module " + m)
|
||||
new ModuleIDConfigurable(m)
|
||||
}
|
||||
|
||||
|
||||
/** Creates a new configuration with the given name.*/
|
||||
def config(name: String) = new Configuration(name)
|
||||
}
|
||||
|
|
@ -232,8 +232,8 @@ trait BasicManagedProject extends ManagedProject with ReflectiveManagedProject w
|
|||
/** The dependency manager that represents inline declarations. The default manager packages the information
|
||||
* from 'ivyXML', 'projectID', 'repositories', and 'libraryDependencies' and does not typically need to be
|
||||
* be overridden. */
|
||||
def manager = new SimpleManager(ivyXML, true, projectID, repositories.toSeq, ivyConfigurations, defaultConfiguration, artifacts, libraryDependencies.toList: _*)
|
||||
|
||||
def manager = new SimpleManager(ivyXML, true, projectID, repositories.toSeq, ivyConfigurations, defaultConfiguration, libraryDependencies.toList: _*)
|
||||
|
||||
/** The pattern for Ivy to use when retrieving dependencies into the local project. Classpath management
|
||||
* depends on the first directory being [conf] and the extension being [ext].*/
|
||||
def outputPattern = "[conf]/[artifact](-[revision]).[ext]"
|
||||
|
|
@ -261,7 +261,7 @@ trait BasicManagedProject extends ManagedProject with ReflectiveManagedProject w
|
|||
def defaultConfiguration: Option[Configuration] = Some(Configurations.DefaultConfiguration(useDefaultConfigurations))
|
||||
def useMavenConfigurations = true // TODO: deprecate after going through a minor version series to verify that this works ok
|
||||
def useDefaultConfigurations = useMavenConfigurations
|
||||
def managedStyle: ManagedType =
|
||||
def managedStyle: ManagedType =
|
||||
info.parent match
|
||||
{
|
||||
case Some(m: BasicManagedProject) => m.managedStyle
|
||||
|
|
@ -283,7 +283,7 @@ trait BasicManagedProject extends ManagedProject with ReflectiveManagedProject w
|
|||
def managerOption: Seq[ManagedOption] =
|
||||
{
|
||||
val m = manager
|
||||
if(m.dependencies.isEmpty && m.resolvers.isEmpty && ivyXML.isEmpty && m.artifacts.isEmpty && m.configurations.isEmpty)
|
||||
if(m.dependencies.isEmpty && m.resolvers.isEmpty && ivyXML.isEmpty && m.module.explicitArtifacts.isEmpty && m.configurations.isEmpty)
|
||||
Nil
|
||||
else
|
||||
LibraryManager(m) :: Nil
|
||||
|
|
@ -340,28 +340,19 @@ trait BasicManagedProject extends ManagedProject with ReflectiveManagedProject w
|
|||
case _ => baseClasspath
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected def updateAction = updateTask(outputPattern, managedDependencyPath, updateOptions) describedAs UpdateDescription
|
||||
protected def cleanLibAction = cleanLibTask(managedDependencyPath) describedAs CleanLibDescription
|
||||
protected def cleanCacheAction = cleanCacheTask(managedDependencyPath, updateOptions) describedAs CleanCacheDescription
|
||||
|
||||
|
||||
protected def deliverProjectDependencies: Iterable[ModuleID] =
|
||||
{
|
||||
val interDependencies = new scala.collection.mutable.ListBuffer[ModuleID]
|
||||
dependencies.foreach(dep => dep match { case mp: ManagedProject => interDependencies += projectModuleID(mp); case _ => () })
|
||||
dependencies.foreach(dep => dep match { case mp: ManagedProject => interDependencies += mp.projectID; case _ => () })
|
||||
if(filterScalaJars)
|
||||
interDependencies ++= deliverScalaDependencies
|
||||
interDependencies.readOnly
|
||||
}
|
||||
protected def projectModuleID(mp: ManagedProject) =
|
||||
{
|
||||
val base = mp.projectID
|
||||
val as = mp.artifacts.toSeq.toArray
|
||||
if(as.size == 1)
|
||||
base artifacts(as : _*)
|
||||
else
|
||||
base artifacts(as.filter(_.`type` != "pom") : _*)
|
||||
}
|
||||
protected def deliverScalaDependencies: Iterable[ModuleID] = Nil
|
||||
protected def makePomAction = makePomTask(pomPath, deliverProjectDependencies, None, updateOptions)
|
||||
protected def deliverLocalAction = deliverTask(publishLocalConfiguration, deliverOptions)
|
||||
|
|
@ -389,7 +380,7 @@ trait BasicManagedProject extends ManagedProject with ReflectiveManagedProject w
|
|||
def this(resolver: Resolver, status: String, publishIvy: Boolean) = this(resolver.name, status, publishIvy)
|
||||
def this(resolverName: String, status: String) = this(resolverName, status, true)
|
||||
def this(resolver: Resolver, status: String) = this(resolver.name, status)
|
||||
|
||||
|
||||
protected def deliveredPathPattern = outputPath / "[artifact]-[revision].[ext]"
|
||||
def deliveredPattern = deliveredPathPattern.relativePath
|
||||
def srcArtifactPatterns: Iterable[String] =
|
||||
|
|
@ -404,12 +395,12 @@ trait BasicManagedProject extends ManagedProject with ReflectiveManagedProject w
|
|||
/** The configurations to include in the publish/deliver action: specify none for all public configurations. */
|
||||
def configurations: Option[Iterable[Configuration]] = None
|
||||
}
|
||||
|
||||
|
||||
def packageToPublishActions: Seq[ManagedTask] = Nil
|
||||
|
||||
|
||||
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 makePom = makePomAction dependsOn(packageToPublishActions : _*)
|
||||
lazy val cleanLib = cleanLibAction
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
|
||||
val mainCompileConditional = new CompileConditional(mainCompileConfiguration)
|
||||
val testCompileConditional = new CompileConditional(testCompileConfiguration)
|
||||
|
||||
|
||||
def compileOrder = CompileOrder.Mixed
|
||||
|
||||
/** The main artifact produced by this project. To redefine the main artifact, override `defaultMainArtifact`
|
||||
|
|
@ -54,9 +54,9 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
/** Defines the default main Artifact assigned to `mainArtifact`. By default, this is a jar file with name given
|
||||
* by `artifactID`.*/
|
||||
protected def defaultMainArtifact = Artifact(artifactID, "jar", "jar")
|
||||
|
||||
|
||||
import Project._
|
||||
|
||||
|
||||
/** The options provided to the 'compile' action to pass to the Scala compiler.*/
|
||||
def compileOptions: Seq[CompileOption] = Deprecation :: Nil
|
||||
/** The options provided to the 'compile' action to pass to the Java compiler. */
|
||||
|
|
@ -65,7 +65,7 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
def testCompileOptions: Seq[CompileOption] = compileOptions
|
||||
/** The options provided to the 'test-compile' action to pass to the Java compiler. */
|
||||
def testJavaCompileOptions: Seq[JavaCompileOption] = javaCompileOptions
|
||||
|
||||
|
||||
/** The options provided to the 'doc' and 'docTest' actions.*/
|
||||
def documentOptions: Seq[ScaladocOption] =
|
||||
LinkSource ::
|
||||
|
|
@ -82,11 +82,11 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
ClearAnalysis(mainCompileConditional.analysis) ::
|
||||
ClearAnalysis(testCompileConditional.analysis) ::
|
||||
historyPath.map(history => Preserve(history)).toList
|
||||
|
||||
|
||||
def packageOptions: Seq[PackageOption] =
|
||||
manifestClassPath.map(cp => ManifestAttributes( (Attributes.Name.CLASS_PATH, cp) )).toList :::
|
||||
getMainClass(false).map(MainClass(_)).toList
|
||||
|
||||
|
||||
private def succeededTestPath = testAnalysisPath / "succeeded-tests"
|
||||
private def quickOptions(failedOnly: Boolean) =
|
||||
{
|
||||
|
|
@ -94,7 +94,7 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
val analysis = testCompileConditional.analysis
|
||||
TestFilter(new impl.TestQuickFilter(analysis, failedOnly, path, log)) :: TestListeners(new impl.TestStatusReporter(path, log) :: Nil) :: Nil
|
||||
}
|
||||
|
||||
|
||||
protected def includeTest(test: String): Boolean = true
|
||||
|
||||
/** This is called to create the initial directories when a user makes a new project from
|
||||
|
|
@ -110,7 +110,7 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
import Configurations._
|
||||
/** The managed configuration to use when determining the classpath for a Scala interpreter session.*/
|
||||
def consoleConfiguration = Test
|
||||
|
||||
|
||||
/** A PathFinder that provides the classpath to pass to scaladoc. It is the same as the compile classpath
|
||||
* by default. */
|
||||
def docClasspath = compileClasspath
|
||||
|
|
@ -154,7 +154,7 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
/** The unmanaged classpath for the test configuration. By default, it includes the run classpath, which includes the base
|
||||
* classpath returned by `mainUnmanagedClasspath`.*/
|
||||
protected def testUnmanagedClasspath = testCompilePath +++ testResourcesOutputPath +++ testDependencies.scalaCompiler +++ runUnmanagedClasspath
|
||||
|
||||
|
||||
/** @deprecated Use `mainDependencies.scalaJars`*/
|
||||
@deprecated protected final def scalaJars: Iterable[File] = mainDependencies.scalaJars.get.map(_.asFile)
|
||||
/** An analysis of the jar dependencies of the main Scala sources. It is only valid after main source compilation.
|
||||
|
|
@ -170,10 +170,10 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
def testFrameworks: Iterable[TestFramework] = ScalaCheckFramework :: SpecsFramework :: ScalaTestFramework :: Nil
|
||||
/** The list of listeners for testing. */
|
||||
def testListeners: Seq[TestReportListener] = new LogTestReportListener(log) :: Nil
|
||||
|
||||
|
||||
def mainLabel = "main"
|
||||
def testLabel = "test"
|
||||
|
||||
|
||||
def mainCompileConfiguration: CompileConfiguration = new MainCompileConfig
|
||||
def testCompileConfiguration: CompileConfiguration = new TestCompileConfig
|
||||
abstract class BaseCompileConfig extends CompileConfiguration
|
||||
|
|
@ -209,7 +209,7 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
def testDefinitionClassNames: Iterable[String] = testFrameworks.map(_.testSuperClassName)
|
||||
def javaOptions = javaOptionsAsString(testJavaCompileOptions)
|
||||
}
|
||||
|
||||
|
||||
/** Configures forking the compiler and runner. Use ForkScalaCompiler, ForkScalaRun or mix together.*/
|
||||
def fork: Option[ForkScala] = None
|
||||
private def doCompile(conditional: CompileConditional) =
|
||||
|
|
@ -228,15 +228,15 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
case _ => Run
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected def runTask(mainClass: String): MethodTask = task { args => runTask(Some(mainClass), runClasspath, args) dependsOn(compile, copyResources) }
|
||||
|
||||
|
||||
protected def compileAction = task { doCompile(mainCompileConditional) } describedAs MainCompileDescription
|
||||
protected def testCompileAction = task { doCompile(testCompileConditional) } dependsOn compile describedAs TestCompileDescription
|
||||
protected def cleanAction = cleanTask(outputPath, cleanOptions) describedAs CleanDescription
|
||||
protected def runAction = task { args => runTask(getMainClass(true), runClasspath, args, getRunner) dependsOn(compile, copyResources) } describedAs RunDescription
|
||||
protected def consoleQuickAction = consoleTask(consoleClasspath, getRunner) describedAs ConsoleQuickDescription
|
||||
protected def consoleAction = consoleTask(consoleClasspath, getRunner).dependsOn(testCompile, copyResources, copyTestResources) describedAs ConsoleDescription
|
||||
protected def consoleQuickAction = consoleTask(consoleClasspath, Run) describedAs ConsoleQuickDescription
|
||||
protected def consoleAction = consoleTask(consoleClasspath, Run).dependsOn(testCompile, copyResources, copyTestResources) describedAs ConsoleDescription
|
||||
protected def docAction = scaladocTask(mainLabel, mainSources, mainDocPath, docClasspath, documentOptions).dependsOn(compile) describedAs DocDescription
|
||||
protected def docTestAction = scaladocTask(testLabel, testSources, testDocPath, docClasspath, documentOptions).dependsOn(testCompile) describedAs TestDocDescription
|
||||
protected def testAction = defaultTestTask(testOptions)
|
||||
|
|
@ -248,25 +248,25 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
testQuickMethod(testCompileConditional.analysis, testOptions)(options => defaultTestTask(quickOptions(failedOnly) ::: options.toList))
|
||||
protected def defaultTestTask(testOptions: => Seq[TestOption]) =
|
||||
testTask(testFrameworks, testClasspath, testCompileConditional.analysis, testOptions).dependsOn(testCompile, copyResources, copyTestResources) describedAs TestDescription
|
||||
|
||||
|
||||
override def packageToPublishActions: Seq[ManagedTask] = `package` :: Nil
|
||||
|
||||
|
||||
protected def packageAction = packageTask(packagePaths, jarPath, packageOptions).dependsOn(compile) describedAs PackageDescription
|
||||
protected def packageTestAction = packageTask(packageTestPaths, packageTestJar).dependsOn(testCompile) describedAs TestPackageDescription
|
||||
protected def packageDocsAction = packageTask(mainDocPath ##, packageDocsJar, Recursive).dependsOn(doc) describedAs DocPackageDescription
|
||||
protected def packageSrcAction = packageTask(packageSourcePaths, packageSrcJar) describedAs SourcePackageDescription
|
||||
protected def packageTestSrcAction = packageTask(packageTestSourcePaths, packageTestSrcJar) describedAs TestSourcePackageDescription
|
||||
protected def packageProjectAction = zipTask(packageProjectPaths, packageProjectZip) describedAs ProjectPackageDescription
|
||||
|
||||
|
||||
protected def docAllAction = (doc && docTest) describedAs DocAllDescription
|
||||
protected def packageAllAction = task { None } dependsOn(`package`, packageTest, packageSrc, packageTestSrc, packageDocs) describedAs PackageAllDescription
|
||||
protected def graphAction = graphTask(graphPath, mainCompileConditional.analysis).dependsOn(compile)
|
||||
protected def incrementVersionAction = task { incrementVersionNumber(); None } describedAs IncrementVersionDescription
|
||||
protected def releaseAction = (test && packageAll && incrementVersion) describedAs ReleaseDescription
|
||||
|
||||
|
||||
protected def copyResourcesAction = syncPathsTask(mainResources, mainResourcesOutputPath) describedAs CopyResourcesDescription
|
||||
protected def copyTestResourcesAction = syncPathsTask(testResources, testResourcesOutputPath) describedAs CopyTestResourcesDescription
|
||||
|
||||
|
||||
lazy val compile = compileAction
|
||||
lazy val testCompile = testCompileAction
|
||||
lazy val clean = cleanAction
|
||||
|
|
@ -293,10 +293,10 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
lazy val testQuick = testQuickAction
|
||||
lazy val testFailed = testFailedAction
|
||||
lazy val testOnly = testOnlyAction
|
||||
|
||||
|
||||
lazy val javap = javapTask(runClasspath, mainCompileConditional, mainCompilePath)
|
||||
lazy val testJavap = javapTask(testClasspath, testCompileConditional, testCompilePath)
|
||||
|
||||
|
||||
def jarsOfProjectDependencies = Path.lazyPathFinder {
|
||||
topologicalSort.dropRight(1) flatMap { p =>
|
||||
p match
|
||||
|
|
@ -318,13 +318,13 @@ abstract class BasicWebScalaProject extends BasicScalaProject with WebScalaProje
|
|||
{ p =>
|
||||
import BasicWebScalaProject._
|
||||
override def watchPaths = super.watchPaths +++ webappResources
|
||||
|
||||
|
||||
lazy val prepareWebapp = prepareWebappAction
|
||||
protected def prepareWebappAction =
|
||||
prepareWebappTask(webappResources, temporaryWarPath, webappClasspath, mainDependencies.scalaJars) dependsOn(compile, copyResources)
|
||||
|
||||
|
||||
lazy val jettyInstance = new JettyRunner(jettyConfiguration)
|
||||
|
||||
|
||||
def jettyConfiguration =
|
||||
new DefaultJettyConfiguration
|
||||
{
|
||||
|
|
@ -361,7 +361,7 @@ abstract class BasicWebScalaProject extends BasicScalaProject with WebScalaProje
|
|||
while (System.in.available() > 0) System.in.read()
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
/** The directories that should be watched to determine if the web application needs to be reloaded..*/
|
||||
def scanDirectories: Seq[Path] = jettyWebappPath :: Nil
|
||||
/** The time in seconds between scans that check whether the web application should be reloaded.*/
|
||||
|
|
@ -372,11 +372,11 @@ abstract class BasicWebScalaProject extends BasicScalaProject with WebScalaProje
|
|||
lazy val jettyRestart = jettyStop && jettyRun
|
||||
lazy val jettyStop = jettyStopAction
|
||||
protected def jettyStopAction = jettyStopTask(jettyInstance) describedAs(JettyStopDescription)
|
||||
|
||||
|
||||
/** The clean action for a web project is modified so that it first stops jetty if it is running,
|
||||
* since the webapp directory will be removed by the clean.*/
|
||||
override def cleanAction = super.cleanAction dependsOn jettyStop
|
||||
|
||||
|
||||
/** Redefine the `package` action to make a war file.*/
|
||||
override protected def packageAction = packageTask(descendents(temporaryWarPath ##, "*"), warPath, Nil) dependsOn(prepareWebapp) describedAs PackageWarDescription
|
||||
|
||||
|
|
@ -434,7 +434,7 @@ object BasicScalaProject
|
|||
"Copies resources to the target directory where they can be included on classpaths."
|
||||
val CopyTestResourcesDescription =
|
||||
"Copies test resources to the target directory where they can be included on the test classpath."
|
||||
|
||||
|
||||
private def warnMultipleMainClasses(log: Logger) =
|
||||
{
|
||||
log.warn("No Main-Class attribute will be added automatically added:")
|
||||
|
|
@ -443,7 +443,7 @@ object BasicScalaProject
|
|||
}
|
||||
private def mapScalaModule(in: Iterable[_], id: String) =
|
||||
{
|
||||
ScalaVersion.current.toList.flatMap { scalaVersion =>
|
||||
ScalaVersion.current.toList.flatMap { scalaVersion =>
|
||||
in.map(jar => ModuleID(ScalaArtifacts.Organization, id, scalaVersion))
|
||||
}
|
||||
}
|
||||
|
|
@ -478,7 +478,7 @@ final class LibraryDependencies(project: Project, conditional: CompileConditiona
|
|||
|
||||
/** Returns an object that has all analyzed dependency information frozen at the time of this method call. */
|
||||
def snapshot = new Dependencies
|
||||
|
||||
|
||||
private def rootProjectDirectory = project.rootProject.info.projectPath
|
||||
|
||||
final class Dependencies
|
||||
|
|
@ -504,5 +504,5 @@ private object LibraryDependencies
|
|||
private def isScalaJar(file: File) = ClasspathUtilities.isArchive(file) && ScalaJarPrefixes.exists(isNamed(file))
|
||||
private def isScalaLibraryJar(file: File) = isNamed(file)(ScalaLibraryPrefix)
|
||||
private def isNamed(file: File)(name: String) = file.getName.startsWith(name)
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -47,11 +47,11 @@ object ManageDependencies
|
|||
val DefaultIvyConfigFilename = "ivysettings.xml"
|
||||
val DefaultIvyFilename = "ivy.xml"
|
||||
val DefaultMavenFilename = "pom.xml"
|
||||
|
||||
|
||||
private def defaultIvyFile(project: Path) = project / DefaultIvyFilename
|
||||
private def defaultIvyConfiguration(project: Path) = project / DefaultIvyConfigFilename
|
||||
private def defaultPOM(project: Path) = project / DefaultMavenFilename
|
||||
|
||||
|
||||
/** Configures Ivy using the provided configuration 'config' and calls 'doWithIvy'. This method takes care of setting up and cleaning up Ivy.*/
|
||||
private def withIvy(config: IvyConfiguration)(doWithIvy: (Ivy, ModuleDescriptor, String) => Option[String]) =
|
||||
withIvyValue(config)( (ivy, module, default) => doWithIvy(ivy, module, default).toLeft(()) ).left.toOption
|
||||
|
|
@ -67,7 +67,7 @@ object ManageDependencies
|
|||
val settings = new IvySettings
|
||||
settings.setBaseDir(paths.projectDirectory.asFile)
|
||||
log.debug("\nCreated settings...\n")
|
||||
|
||||
|
||||
/** Parses the given Maven pom 'pomFile'.*/
|
||||
def readPom(pomFile: File) =
|
||||
Control.trap("Could not read pom: ", log)
|
||||
|
|
@ -116,7 +116,7 @@ object ManageDependencies
|
|||
user ++
|
||||
Seq(DefaultMavenRepository) ++
|
||||
(if(flags.addScalaTools) Seq(ScalaToolsReleases) else Nil)
|
||||
|
||||
|
||||
/** Configures Ivy using defaults. This is done when no ivy-settings.xml exists. */
|
||||
def configureDefaults(resolvers: Seq[Resolver])
|
||||
{
|
||||
|
|
@ -155,7 +155,9 @@ object ManageDependencies
|
|||
{
|
||||
val defaultConf = ModuleDescriptor.DEFAULT_CONFIGURATION
|
||||
log.warn("No readable dependency configuration found, using defaults.")
|
||||
val moduleID = DefaultModuleDescriptor.newDefaultInstance(module)
|
||||
val moduleID = new DefaultModuleDescriptor(module, "release", null, false)
|
||||
moduleID.setLastModified(System.currentTimeMillis)
|
||||
moduleID.addConfiguration(toIvyConfiguration(Configurations.Default))
|
||||
addMainArtifact(moduleID)
|
||||
if(defaultArtifact)
|
||||
addDefaultArtifact(defaultConf, moduleID)
|
||||
|
|
@ -211,7 +213,7 @@ object ManageDependencies
|
|||
log.debug("Using inline dependencies specified in Scala" + (if(dependenciesXML.isEmpty) "." else " and XML."))
|
||||
for(parser <- parseXMLDependencies(wrapped(module, dependenciesXML), moduleID, defaultConf.name).right) yield
|
||||
{
|
||||
addArtifacts(moduleID, artifacts)
|
||||
addArtifacts(moduleID, module.explicitArtifacts)
|
||||
addDependencies(moduleID, dependencies, parser)
|
||||
addMainArtifact(moduleID)
|
||||
(moduleID, parser.getDefaultConf)
|
||||
|
|
@ -260,7 +262,7 @@ object ManageDependencies
|
|||
log.debug("Not checking Scala dependencies")
|
||||
Right(moduleAndConf)
|
||||
}
|
||||
|
||||
|
||||
this.synchronized // Ivy is not thread-safe. In particular, it uses a static DocumentBuilder, which is not thread-safe
|
||||
{
|
||||
val ivy = Ivy.newInstance(settings)
|
||||
|
|
@ -346,7 +348,7 @@ object ManageDependencies
|
|||
def doClean(ivy: Ivy, module: ModuleDescriptor, default: String) =
|
||||
Control.trapUnit("Could not clean cache: ", config.log)
|
||||
{ ivy.getSettings.getRepositoryCacheManagers.foreach(_.clean()); None }
|
||||
|
||||
|
||||
withIvy(config)(doClean)
|
||||
}
|
||||
/** Creates a Maven pom from the given Ivy configuration*/
|
||||
|
|
@ -404,7 +406,7 @@ object ManageDependencies
|
|||
}
|
||||
private def addConfigurations(configurations: Iterable[String], to: { def setConfs(c: Array[String]): AnyRef }): Unit =
|
||||
to.setConfs(configurations.toList.toArray)
|
||||
|
||||
|
||||
def install(ivyConfig: IvyConfiguration, from: String, to: String, validate: Boolean, overwrite: Boolean) =
|
||||
{
|
||||
def doInstall(ivy: Ivy, md: ModuleDescriptor, default: String) =
|
||||
|
|
@ -434,7 +436,7 @@ object ManageDependencies
|
|||
val revID = module.getModuleRevisionId
|
||||
val options = DeliverOptions.newInstance(ivy.getSettings).setStatus(status)
|
||||
options.setConfs(getConfigurations(module, configurations))
|
||||
|
||||
|
||||
ivy.deliver(revID, revID.getRevision, deliverIvyPattern, options)
|
||||
None
|
||||
}
|
||||
|
|
@ -482,7 +484,7 @@ object ManageDependencies
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
withIvy(ivyConfig)(processModule)
|
||||
}
|
||||
private def resolve(ivy: Ivy, updateConfig: UpdateConfiguration, module: ModuleDescriptor) =
|
||||
|
|
|
|||
|
|
@ -34,13 +34,12 @@ sealed trait SbtManager extends Manager
|
|||
def dependenciesXML: NodeSeq
|
||||
def configurations: Iterable[Configuration]
|
||||
def defaultConfiguration: Option[Configuration]
|
||||
def artifacts: Iterable[Artifact]
|
||||
}
|
||||
final class SimpleManager private[sbt] (val dependenciesXML: NodeSeq, val autodetectUnspecified: Boolean,
|
||||
val module: ModuleID, val resolvers: Seq[Resolver], explicitConfigurations: Iterable[Configuration],
|
||||
val defaultConfiguration: Option[Configuration], val artifacts: Iterable[Artifact], val dependencies: ModuleID*) extends SbtManager
|
||||
val defaultConfiguration: Option[Configuration], val dependencies: ModuleID*) extends SbtManager
|
||||
{
|
||||
def autodetect = dependencies.isEmpty && dependenciesXML.isEmpty && artifacts.isEmpty && explicitConfigurations.isEmpty && autodetectUnspecified
|
||||
def autodetect = dependencies.isEmpty && dependenciesXML.isEmpty && module.explicitArtifacts.isEmpty && explicitConfigurations.isEmpty && autodetectUnspecified
|
||||
def configurations =
|
||||
if(explicitConfigurations.isEmpty && !autodetect)
|
||||
{
|
||||
|
|
@ -121,7 +120,7 @@ sealed abstract class PatternsBasedRepository extends Resolver
|
|||
|
||||
/** The object representing the configured patterns for this repository. */
|
||||
def patterns: Patterns
|
||||
|
||||
|
||||
/** Enables maven 2 compatibility for this repository. */
|
||||
def mavenStyle() = copy(patterns.mavenStyle())
|
||||
/** Adds the given patterns for resolving/publishing Ivy files.*/
|
||||
|
|
@ -149,10 +148,10 @@ sealed abstract class SshBasedRepository extends PatternsBasedRepository
|
|||
type RepositoryType <: SshBasedRepository
|
||||
protected def copy(connection: SshConnection): RepositoryType
|
||||
private def copy(authentication: SshAuthentication): RepositoryType = copy(connection.copy(Some(authentication)))
|
||||
|
||||
|
||||
/** The object representing the configured ssh connection for this repository. */
|
||||
def connection: SshConnection
|
||||
|
||||
|
||||
/** Configures this to use the specified user name and password when connecting to the remote repository. */
|
||||
def as(user: String, password: String): RepositoryType = copy(new PasswordAuthentication(user, password))
|
||||
/** Configures this to use the specified keyfile and password for the keyfile when connecting to the remote repository. */
|
||||
|
|
@ -256,7 +255,7 @@ object Resolver
|
|||
}
|
||||
private def baseRepository[T](baseURI: java.net.URI)(construct: Patterns => T)(implicit basePatterns: Patterns): T =
|
||||
construct(resolvePatterns(baseURI.normalize, basePatterns))
|
||||
|
||||
|
||||
/** If `base` is None, `patterns` is returned unchanged.
|
||||
* Otherwise, the ivy file and artifact patterns in `patterns` are resolved against the given base. */
|
||||
private def resolvePatterns(base: Option[String], patterns: Patterns): Patterns =
|
||||
|
|
@ -274,7 +273,7 @@ object Resolver
|
|||
}
|
||||
/** Constructs a `URI` with the path component set to `path` and the other components set to null.*/
|
||||
private def pathURI(path: String) = new URI(null, null, path, null)
|
||||
|
||||
|
||||
def defaultFileConfiguration = FileConfiguration(true, None)
|
||||
def mavenStylePatterns = Patterns(Nil, mavenStyleBasePattern :: Nil, true)
|
||||
def ivyStylePatterns = Patterns(Nil, Nil, false)
|
||||
|
|
@ -282,11 +281,11 @@ object Resolver
|
|||
def defaultPatterns = mavenStylePatterns
|
||||
def mavenStyleBasePattern = "[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
|
||||
def localBasePattern = "[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
|
||||
|
||||
|
||||
def userRoot = System.getProperty("user.home")
|
||||
def userMavenRoot = userRoot + "/.m2/repository/"
|
||||
def userIvyRoot = userRoot + "/.ivy2/"
|
||||
|
||||
|
||||
def defaultLocal = defaultUserFileRepository("local")
|
||||
def defaultShared = defaultUserFileRepository("shared")
|
||||
def defaultUserFileRepository(id: String) = file(id, new File(userIvyRoot, id))(defaultIvyPatterns)
|
||||
|
|
@ -301,7 +300,7 @@ object Configurations
|
|||
{
|
||||
def config(name: String) = new Configuration(name)
|
||||
def defaultMavenConfigurations = Compile :: Runtime :: Test :: Provided :: System :: Optional :: Sources :: Javadoc :: Nil
|
||||
|
||||
|
||||
lazy val Default = config("default")
|
||||
lazy val Compile = config("compile")
|
||||
lazy val IntegrationTest = config("it") hide
|
||||
|
|
@ -314,16 +313,16 @@ object Configurations
|
|||
lazy val Optional = config("optional")
|
||||
|
||||
lazy val CompilerPlugin = config("plugin") hide
|
||||
|
||||
|
||||
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) =
|
||||
private[sbt] def defaultConfiguration(mavenStyle: Boolean) =
|
||||
{
|
||||
val base = if(mavenStyle) Configurations.Compile else Configurations.Default
|
||||
config(base.name + "->default(compile)")
|
||||
}
|
||||
|
||||
|
||||
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. */
|
||||
|
|
@ -383,7 +382,7 @@ object Credentials
|
|||
{
|
||||
val properties = new scala.collection.mutable.HashMap[String, String]
|
||||
def get(keys: List[String]) = keys.flatMap(properties.get).firstOption.toRight(keys.head + " not specified in credentials file: " + path)
|
||||
|
||||
|
||||
impl.MapUtilities.read(properties, path, log) orElse
|
||||
{
|
||||
List.separate( List(RealmKeys, HostKeys, UserKeys, PasswordKeys).map(get) ) match
|
||||
|
|
|
|||
Loading…
Reference in New Issue