mirror of https://github.com/sbt/sbt.git
Accept configurations to be specified for dependencies in the CLI tools
This commit is contained in:
parent
5bbe01bfdd
commit
49eb37b1a3
|
|
@ -54,6 +54,10 @@ case class CommonOptions(
|
|||
@Value("classifier1,classifier2,...")
|
||||
@Short("C")
|
||||
classifier: List[String],
|
||||
@Help("Default configuration (default(compile) by default)")
|
||||
@Value("configuration")
|
||||
@Short("c")
|
||||
defaultConfiguration: String = "default(compile)",
|
||||
@Help("Maximum number of parallel downloads (default: 6)")
|
||||
@Short("n")
|
||||
parallel: Int = 6,
|
||||
|
|
@ -316,7 +320,7 @@ case class Launch(
|
|||
} else {
|
||||
// Trying to get the main class of the first artifact
|
||||
val mainClassOpt = for {
|
||||
(module, _) <- helper.moduleVersions.headOption
|
||||
(module, _, _) <- helper.moduleVersionConfigs.headOption
|
||||
mainClass <- mainClasses.collectFirst {
|
||||
case ((org, name), mainClass)
|
||||
if org == module.organization && (
|
||||
|
|
|
|||
|
|
@ -118,10 +118,10 @@ class Helper(
|
|||
}
|
||||
|
||||
|
||||
val (modVerErrors, moduleVersions) = Parse.moduleVersions(rawDependencies)
|
||||
val (modVerCfgErrors, moduleVersionConfigs) = Parse.moduleVersionConfigs(rawDependencies)
|
||||
|
||||
prematureExitIf(modVerErrors.nonEmpty) {
|
||||
s"Cannot parse dependencies:\n" + modVerErrors.map(" "+_).mkString("\n")
|
||||
prematureExitIf(modVerCfgErrors.nonEmpty) {
|
||||
s"Cannot parse dependencies:\n" + modVerCfgErrors.map(" "+_).mkString("\n")
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -164,12 +164,12 @@ class Helper(
|
|||
(mod.organization, mod.name)
|
||||
}.toSet
|
||||
|
||||
val dependencies = moduleVersions.map {
|
||||
case (module, version) =>
|
||||
val dependencies = moduleVersionConfigs.map {
|
||||
case (module, version, configOpt) =>
|
||||
Dependency(
|
||||
module,
|
||||
version,
|
||||
configuration = "default(compile)",
|
||||
configuration = configOpt.getOrElse(defaultConfiguration),
|
||||
exclusions = excludes,
|
||||
transitive = !intransitive
|
||||
)
|
||||
|
|
|
|||
|
|
@ -81,14 +81,52 @@ object Parse {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses coordinates like
|
||||
* org:name:version
|
||||
* possibly with attributes, like
|
||||
* org:name;attr1=val1;attr2=val2:version
|
||||
* and a configuration, like
|
||||
* org:name:version:config
|
||||
* or
|
||||
* org:name;attr1=val1;attr2=val2:version:config
|
||||
*/
|
||||
def moduleVersionConfig(s: String): Either[String, (Module, String, Option[String])] = {
|
||||
|
||||
val parts = s.split(":", 4)
|
||||
|
||||
parts match {
|
||||
case Array(org, rawName, version, config) =>
|
||||
module(s"$org:$rawName")
|
||||
.right
|
||||
.map((_, version, Some(config)))
|
||||
|
||||
case Array(org, rawName, version) =>
|
||||
module(s"$org:$rawName")
|
||||
.right
|
||||
.map((_, version, None))
|
||||
|
||||
case _ =>
|
||||
Left(s"Malformed coordinates: $s")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a sequence of coordinates.
|
||||
*
|
||||
* @return Sequence of errors, and sequence of modules/versions
|
||||
* @return Sequence of errors, and sequence of modules / versions
|
||||
*/
|
||||
def moduleVersions(l: Seq[String]): (Seq[String], Seq[(Module, String)]) =
|
||||
valuesAndErrors(moduleVersion, l)
|
||||
|
||||
/**
|
||||
* Parses a sequence of coordinates having an optional configuration.
|
||||
*
|
||||
* @return Sequence of errors, and sequence of modules / versions / optional configurations
|
||||
*/
|
||||
def moduleVersionConfigs(l: Seq[String]): (Seq[String], Seq[(Module, String, Option[String])]) =
|
||||
valuesAndErrors(moduleVersionConfig, l)
|
||||
|
||||
def repository(s: String): Repository =
|
||||
if (s == "central")
|
||||
MavenRepository("https://repo1.maven.org/maven2")
|
||||
|
|
|
|||
Loading…
Reference in New Issue