mirror of https://github.com/sbt/sbt.git
add scala-tool configuration and dependencies when configuring via pom.xml/ivy.xml
This commit is contained in:
parent
214cd62a2a
commit
769ecbace5
|
|
@ -168,6 +168,11 @@ final class IvySbt(val configuration: IvyConfiguration)
|
|||
val md = PomModuleDescriptorParser.getInstance.parseDescriptor(settings, toURL(pc.file), pc.validate)
|
||||
val dmd = IvySbt.toDefaultModuleDescriptor(md)
|
||||
IvySbt.addConfigurations(dmd, Configurations.defaultInternal)
|
||||
for( is <- pc.ivyScala) {
|
||||
val confParser = new CustomXmlParser.CustomParser(settings, Some(Configurations.DefaultMavenConfiguration.name))
|
||||
confParser.setMd(dmd)
|
||||
addScalaToolDependencies(dmd, confParser, is)
|
||||
}
|
||||
(dmd, "compile")
|
||||
}
|
||||
/** Parses the Ivy file 'ivyFile' from the given `IvyFileConfiguration`.*/
|
||||
|
|
@ -177,8 +182,14 @@ final class IvySbt(val configuration: IvyConfiguration)
|
|||
parser.setValidate(ifc.validate)
|
||||
parser.setSource(toURL(ifc.file))
|
||||
parser.parse()
|
||||
val md = parser.getModuleDescriptor()
|
||||
(IvySbt.toDefaultModuleDescriptor(md), parser.getDefaultConf)
|
||||
val dmd = IvySbt.toDefaultModuleDescriptor(parser.getModuleDescriptor())
|
||||
for( is <- ifc.ivyScala )
|
||||
addScalaToolDependencies(dmd, parser, is)
|
||||
(dmd, parser.getDefaultConf)
|
||||
}
|
||||
private def addScalaToolDependencies(dmd: DefaultModuleDescriptor, parser: CustomXmlParser.CustomParser, is: IvyScala) {
|
||||
IvySbt.addConfigurations(dmd, Configurations.ScalaTool :: Nil)
|
||||
IvySbt.addDependencies(dmd, ScalaArtifacts.toolDependencies(is.scalaOrganization, is.scalaFullVersion), parser)
|
||||
}
|
||||
private def toURL(file: File) = file.toURI.toURL
|
||||
private def configureEmpty(ec: EmptyConfiguration) =
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ final case class InlineConfiguration(module: ModuleID, moduleInfo: ModuleInfo, d
|
|||
def withConfigurations(configurations: Seq[Configuration]) = copy(configurations = configurations)
|
||||
def noScala = copy(ivyScala = None)
|
||||
}
|
||||
@deprecated("Define a module using inline Scala (InlineConfiguration), a pom.xml (PomConfiguration), or an ivy.xml (IvyFileConfiguration).", "0.13.0")
|
||||
final case class EmptyConfiguration(module: ModuleID, moduleInfo: ModuleInfo, ivyScala: Option[IvyScala], validate: Boolean) extends ModuleSettings
|
||||
{
|
||||
def noScala = copy(ivyScala = None)
|
||||
|
|
@ -100,6 +101,7 @@ object InlineConfiguration
|
|||
}
|
||||
object ModuleSettings
|
||||
{
|
||||
@deprecated("Explicitly select configuration from pom.xml, ivy.xml, or inline Scala.", "0.13.0")
|
||||
def apply(ivyScala: Option[IvyScala], validate: Boolean, module: => ModuleID, moduleInfo: => ModuleInfo)(baseDirectory: File, log: Logger): ModuleSettings =
|
||||
{
|
||||
log.debug("Autodetecting dependencies.")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@ object ScalaArtifacts
|
|||
val LibraryID = ScalaLibraryID
|
||||
val CompilerID = ScalaCompilerID
|
||||
def libraryDependency(version: String): ModuleID = ModuleID(Organization, LibraryID, version)
|
||||
|
||||
private[sbt] def toolDependencies(org: String, version: String): Seq[ModuleID] = Seq(
|
||||
scalaToolDependency(org, ScalaArtifacts.CompilerID, version),
|
||||
scalaToolDependency(org, ScalaArtifacts.LibraryID, version)
|
||||
)
|
||||
private[this] def scalaToolDependency(org: String, id: String, version: String): ModuleID =
|
||||
ModuleID(org, id, version, Some(Configurations.ScalaTool.name + "->default,optional(default)") )
|
||||
}
|
||||
object SbtArtifacts
|
||||
{
|
||||
|
|
@ -28,7 +35,7 @@ object SbtArtifacts
|
|||
|
||||
import ScalaArtifacts._
|
||||
|
||||
final case class IvyScala(scalaFullVersion: String, scalaBinaryVersion: String, configurations: Iterable[Configuration], checkExplicit: Boolean, filterImplicit: Boolean, overrideScalaVersion: Boolean)
|
||||
final case class IvyScala(scalaFullVersion: String, scalaBinaryVersion: String, configurations: Iterable[Configuration], checkExplicit: Boolean, filterImplicit: Boolean, overrideScalaVersion: Boolean, scalaOrganization: String = ScalaArtifacts.Organization)
|
||||
|
||||
private object IvyScala
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,13 +35,6 @@ object Defaults extends BuildCommon
|
|||
{
|
||||
final val CacheDirectoryName = "cache"
|
||||
|
||||
private[sbt] def scalaToolDependencies(org: String, version: String): Seq[ModuleID] = Seq(
|
||||
scalaToolDependency(org, ScalaArtifacts.CompilerID, version),
|
||||
scalaToolDependency(org, ScalaArtifacts.LibraryID, version)
|
||||
)
|
||||
private[this] def scalaToolDependency(org: String, id: String, version: String): ModuleID =
|
||||
ModuleID(org, id, version, Some(Configurations.ScalaTool.name + "->default,optional(default)") )
|
||||
|
||||
def configSrcSub(key: SettingKey[File]): Initialize[File] = (key in ThisScope.copy(config = Global), configuration) { (src, conf) => src / nameForSrc(conf.name) }
|
||||
def nameForSrc(config: String) = if(config == Configurations.Compile.name) "main" else config
|
||||
def prefix(config: String) = if(config == Configurations.Compile.name) "" else config + "-"
|
||||
|
|
@ -857,16 +850,16 @@ object Classpaths
|
|||
allDependencies := {
|
||||
val base = projectDependencies.value ++ libraryDependencies.value
|
||||
val pluginAdjust = if(sbtPlugin.value) sbtDependency.value.copy(configurations = Some(Provided.name)) +: base else base
|
||||
if(scalaHome.value.isDefined)
|
||||
if(scalaHome.value.isDefined || ivyScala.value.isEmpty)
|
||||
pluginAdjust
|
||||
else
|
||||
Defaults.scalaToolDependencies(scalaOrganization.value, scalaVersion.value) ++ pluginAdjust
|
||||
ScalaArtifacts.toolDependencies(scalaOrganization.value, scalaVersion.value) ++ pluginAdjust
|
||||
},
|
||||
ivyLoggingLevel in GlobalScope :== UpdateLogging.DownloadOnly,
|
||||
ivyXML in GlobalScope :== NodeSeq.Empty,
|
||||
ivyValidate in GlobalScope :== false,
|
||||
ivyScala <<= ivyScala or (scalaHome, scalaVersion in update, scalaBinaryVersion in update) { (sh,fv,bv) =>
|
||||
Some(new IvyScala(fv, bv, Nil, filterImplicit = false, checkExplicit = true, overrideScalaVersion = sh.isEmpty))
|
||||
ivyScala <<= ivyScala or (scalaHome, scalaVersion in update, scalaBinaryVersion in update, scalaOrganization) { (sh,fv,bv,so) =>
|
||||
Some(new IvyScala(fv, bv, Nil, filterImplicit = false, checkExplicit = true, overrideScalaVersion = sh.isEmpty, scalaOrganization = so))
|
||||
},
|
||||
moduleConfigurations in GlobalScope :== Nil,
|
||||
publishTo in GlobalScope :== None,
|
||||
|
|
|
|||
Loading…
Reference in New Issue