mirror of https://github.com/sbt/sbt.git
Better handling of attributes from SBT
This commit is contained in:
parent
d188cb0b1a
commit
5d32358c2e
|
|
@ -30,6 +30,8 @@ case class CommonOptions(
|
|||
repository: List[String],
|
||||
@HelpMessage("Do not add default repositories (~/.ivy2/local, and Central)")
|
||||
noDefault: Boolean = false,
|
||||
@HelpMessage("Modify names in Maven repository paths for SBT plugins")
|
||||
sbtPluginHack: Boolean = false,
|
||||
@HelpMessage("Force module version")
|
||||
@ValueDescription("organization:name:forcedVersion")
|
||||
@ExtraName("V")
|
||||
|
|
|
|||
|
|
@ -114,10 +114,19 @@ class Helper(
|
|||
sys.exit(255)
|
||||
}
|
||||
|
||||
val repositories =
|
||||
val repositories1 =
|
||||
(if (common.noDefault) Nil else defaultRepositories) ++
|
||||
repositories0.collect { case Right(r) => r }
|
||||
|
||||
val repositories =
|
||||
if (common.sbtPluginHack)
|
||||
repositories1.map {
|
||||
case m: MavenRepository => m.copy(sbtAttrStub = true)
|
||||
case other => other
|
||||
}
|
||||
else
|
||||
repositories1
|
||||
|
||||
val (rawDependencies, extraArgs) = {
|
||||
val idxOpt = Some(remainingArgs.indexOf("--")).filter(_ >= 0)
|
||||
idxOpt.fold((remainingArgs, Seq.empty[String])) { idx =>
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@ object MavenRepository {
|
|||
case class MavenRepository(
|
||||
root: String,
|
||||
ivyLike: Boolean = false,
|
||||
changing: Option[Boolean] = None
|
||||
changing: Option[Boolean] = None,
|
||||
/** Hackish hack for sbt plugins mainly - what this does really sucks */
|
||||
sbtAttrStub: Boolean = false
|
||||
) extends Repository {
|
||||
|
||||
import Repository._
|
||||
|
|
@ -58,6 +60,17 @@ case class MavenRepository(
|
|||
val root0 = if (root.endsWith("/")) root else root + "/"
|
||||
val source = MavenSource(root0, ivyLike)
|
||||
|
||||
private def dirModuleName(module: Module): String =
|
||||
if (sbtAttrStub) {
|
||||
var name = module.name
|
||||
for (scalaVersion <- module.attributes.get("scalaVersion"))
|
||||
name = name + "_" + scalaVersion
|
||||
for (sbtVersion <- module.attributes.get("sbtVersion"))
|
||||
name = name + "_" + sbtVersion
|
||||
name
|
||||
} else
|
||||
module.name
|
||||
|
||||
def projectArtifact(
|
||||
module: Module,
|
||||
version: String,
|
||||
|
|
@ -68,7 +81,7 @@ case class MavenRepository(
|
|||
if (ivyLike)
|
||||
ivyLikePath(
|
||||
module.organization,
|
||||
module.name,
|
||||
dirModuleName(module), // maybe not what we should do here, don't know
|
||||
versioningValue getOrElse version,
|
||||
"poms",
|
||||
"",
|
||||
|
|
@ -76,7 +89,7 @@ case class MavenRepository(
|
|||
)
|
||||
else
|
||||
module.organization.split('.').toSeq ++ Seq(
|
||||
module.name,
|
||||
dirModuleName(module),
|
||||
version,
|
||||
s"${module.name}-${versioningValue getOrElse version}.pom"
|
||||
)
|
||||
|
|
@ -98,7 +111,7 @@ case class MavenRepository(
|
|||
else {
|
||||
val path = (
|
||||
module.organization.split('.').toSeq ++ Seq(
|
||||
module.name,
|
||||
dirModuleName(module),
|
||||
"maven-metadata.xml"
|
||||
)
|
||||
) .map(encodeURIComponent)
|
||||
|
|
@ -125,7 +138,7 @@ case class MavenRepository(
|
|||
else {
|
||||
val path = (
|
||||
module.organization.split('.').toSeq ++ Seq(
|
||||
module.name,
|
||||
dirModuleName(module),
|
||||
version,
|
||||
"maven-metadata.xml"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ object FromSbt {
|
|||
} yield (from, to)
|
||||
}
|
||||
|
||||
def attributes(attr: Map[String, String]): Map[String, String] =
|
||||
attr.map { case (k, v) =>
|
||||
k.stripPrefix("e:") -> v
|
||||
}
|
||||
|
||||
def dependencies(
|
||||
module: ModuleID,
|
||||
scalaVersion: String,
|
||||
|
|
@ -39,7 +44,7 @@ object FromSbt {
|
|||
val fullName = sbtModuleIdName(module, scalaVersion, scalaBinaryVersion)
|
||||
|
||||
val dep = Dependency(
|
||||
Module(module.organization, fullName, module.extraAttributes),
|
||||
Module(module.organization, fullName, FromSbt.attributes(module.extraAttributes)),
|
||||
module.revision,
|
||||
exclusions = module.exclusions.map { rule =>
|
||||
// FIXME Other `rule` fields are ignored here
|
||||
|
|
@ -82,7 +87,7 @@ object FromSbt {
|
|||
Module(
|
||||
projectID.organization,
|
||||
sbtModuleIdName(projectID, scalaVersion, scalaBinaryVersion),
|
||||
projectID.extraAttributes
|
||||
FromSbt.attributes(projectID.extraAttributes)
|
||||
),
|
||||
projectID.revision,
|
||||
deps,
|
||||
|
|
@ -102,7 +107,7 @@ object FromSbt {
|
|||
case sbt.MavenRepository(_, root) =>
|
||||
if (root.startsWith("http://") || root.startsWith("https://")) {
|
||||
val root0 = if (root.endsWith("/")) root else root + "/"
|
||||
Some(MavenRepository(root0))
|
||||
Some(MavenRepository(root0, sbtAttrStub = true))
|
||||
} else {
|
||||
Console.err.println(s"Warning: unrecognized Maven repository protocol in $root, ignoring it")
|
||||
None
|
||||
|
|
|
|||
Loading…
Reference in New Issue