mirror of https://github.com/sbt/sbt.git
More for extra attributes from POM (#2)
This commit is contained in:
parent
0d5ac09aa1
commit
aa9a43b483
|
|
@ -31,8 +31,7 @@ case class CommonOptions(
|
|||
@HelpMessage("Do not add default repositories (~/.ivy2/local, and Central)")
|
||||
noDefault: Boolean = false,
|
||||
@HelpMessage("Modify names in Maven repository paths for SBT plugins")
|
||||
@ValueDescription("Attribute prefix (typically \"e\")")
|
||||
sbtPluginHack: String = "",
|
||||
sbtPluginHack: Boolean = false,
|
||||
@HelpMessage("Force module version")
|
||||
@ValueDescription("organization:name:forcedVersion")
|
||||
@ExtraName("V")
|
||||
|
|
|
|||
|
|
@ -118,9 +118,9 @@ class Helper(
|
|||
repositories0.collect { case Right(r) => r }
|
||||
|
||||
val repositories =
|
||||
if (common.sbtPluginHack.nonEmpty)
|
||||
if (common.sbtPluginHack)
|
||||
repositories1.map {
|
||||
case m: MavenRepository => m.copy(sbtAttrStub = Some(common.sbtPluginHack))
|
||||
case m: MavenRepository => m.copy(sbtAttrStub = true)
|
||||
case other => other
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ object Fetch {
|
|||
val task = lookups.foldLeft[F[Seq[String] \/ (Artifact.Source, Project)]](F.point(-\/(Nil))) {
|
||||
case (acc, (repo, eitherProjTask)) =>
|
||||
val looseModuleValidation = repo match {
|
||||
case m: MavenRepository => m.sbtAttrStub.nonEmpty // that sucks so much
|
||||
case m: MavenRepository => m.sbtAttrStub // that sucks so much
|
||||
case _ => false
|
||||
}
|
||||
val moduleCmp = if (looseModuleValidation) module.copy(attributes = Map.empty) else module
|
||||
|
|
@ -66,7 +66,7 @@ object Fetch {
|
|||
EitherT(F.map(task)(_.leftMap(_.reverse)))
|
||||
.map {case x @ (source, proj) =>
|
||||
val looseModuleValidation = source match {
|
||||
case m: MavenSource => m.sbtAttrStub.nonEmpty // omfg
|
||||
case m: MavenSource => m.sbtAttrStub // omfg
|
||||
case _ => false
|
||||
}
|
||||
val projModule =
|
||||
|
|
|
|||
|
|
@ -45,24 +45,16 @@ object MavenRepository {
|
|||
"test" -> Seq("runtime")
|
||||
)
|
||||
|
||||
def dirModuleName(module: Module, sbtAttrStub: Option[String]): String =
|
||||
sbtAttrStub.fold(module.name) { prefix =>
|
||||
def attr(name: String) = {
|
||||
val base = module.attributes.get(name)
|
||||
|
||||
if (prefix.isEmpty)
|
||||
base
|
||||
else
|
||||
base.orElse(module.attributes.get(s"$prefix:$name"))
|
||||
}
|
||||
|
||||
def dirModuleName(module: Module, sbtAttrStub: Boolean): String =
|
||||
if (sbtAttrStub) {
|
||||
var name = module.name
|
||||
for (scalaVersion <- attr("scalaVersion"))
|
||||
for (scalaVersion <- module.attributes.get("scalaVersion"))
|
||||
name = name + "_" + scalaVersion
|
||||
for (sbtVersion <- attr("sbtVersion"))
|
||||
for (sbtVersion <- module.attributes.get("sbtVersion"))
|
||||
name = name + "_" + sbtVersion
|
||||
name
|
||||
}
|
||||
} else
|
||||
module.name
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +63,7 @@ case class MavenRepository(
|
|||
ivyLike: Boolean = false,
|
||||
changing: Option[Boolean] = None,
|
||||
/** Hackish hack for sbt plugins mainly - what this does really sucks */
|
||||
sbtAttrStub: Option[String] = None
|
||||
sbtAttrStub: Boolean = false
|
||||
) extends Repository {
|
||||
|
||||
import Repository._
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ case class MavenSource(
|
|||
ivyLike: Boolean,
|
||||
changing: Option[Boolean] = None,
|
||||
/** See doc on MavenRepository */
|
||||
sbtAttrStub: Option[String] = None
|
||||
sbtAttrStub: Boolean
|
||||
) extends Artifact.Source {
|
||||
|
||||
import Repository._
|
||||
|
|
|
|||
|
|
@ -382,6 +382,8 @@ object Pom {
|
|||
"branch"
|
||||
)
|
||||
|
||||
val extraAttributeDropPrefix = "e:"
|
||||
|
||||
def extraAttribute(s: String): String \/ (Module, String) = {
|
||||
// vaguely does the same as:
|
||||
// https://github.com/apache/ant-ivy/blob/2.2.0/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java#L291
|
||||
|
|
@ -410,7 +412,7 @@ object Pom {
|
|||
parts <- partsOrError
|
||||
attrs = parts.grouped(2).collect {
|
||||
case Seq(k, v) if v != "NULL" =>
|
||||
k -> v
|
||||
k.stripPrefix(extraAttributeDropPrefix) -> v
|
||||
}.toMap
|
||||
org <- attrFrom(attrs, extraAttributeOrg)
|
||||
name <- attrFrom(attrs, extraAttributeName)
|
||||
|
|
|
|||
|
|
@ -119,7 +119,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, sbtAttrStub = Some("e")))
|
||||
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