mirror of https://github.com/sbt/sbt.git
Get rid of sources/docs configurations
This commit is contained in:
parent
4f2729c0b0
commit
565acc4e2a
|
|
@ -8,10 +8,10 @@ import java.net.URL
|
||||||
import sbt.serialization._
|
import sbt.serialization._
|
||||||
|
|
||||||
final case class Artifact(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Iterable[Configuration], url: Option[URL], extraAttributes: Map[String, String]) {
|
final case class Artifact(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Iterable[Configuration], url: Option[URL], extraAttributes: Map[String, String]) {
|
||||||
def extra(attributes: (String, String)*) = Artifact(name, `type`, extension, classifier, configurations, url, extraAttributes ++ ModuleID.checkE(attributes))
|
def extra(attributes: (String, String)*) = copy(extraAttributes = extraAttributes ++ ModuleID.checkE(attributes))
|
||||||
}
|
}
|
||||||
|
|
||||||
import Configurations.{ config, Docs, Optional, Pom, Sources, Test }
|
import Configurations.{ config, Optional, Pom, Test }
|
||||||
|
|
||||||
object Artifact {
|
object Artifact {
|
||||||
def apply(name: String): Artifact = Artifact(name, DefaultType, DefaultExtension, None, Nil, None)
|
def apply(name: String): Artifact = Artifact(name, DefaultType, DefaultExtension, None, Nil, None)
|
||||||
|
|
@ -30,12 +30,23 @@ object Artifact {
|
||||||
def javadoc(name: String) = classified(name, DocClassifier)
|
def javadoc(name: String) = classified(name, DocClassifier)
|
||||||
def pom(name: String) = Artifact(name, PomType, PomType, None, Pom :: Nil, None)
|
def pom(name: String) = Artifact(name, PomType, PomType, None, Pom :: Nil, None)
|
||||||
|
|
||||||
val DocClassifier = "javadoc"
|
// Possible ivy artifact types such that sbt will treat those artifacts at sources / docs
|
||||||
val SourceClassifier = "sources"
|
val DefaultSourceTypes = Set("src", "source", "sources")
|
||||||
val DocType = "doc"
|
val DefaultDocTypes = Set("doc", "docs", "javadoc", "javadocs")
|
||||||
val SourceType = "src"
|
|
||||||
val PomType = "pom"
|
val DocClassifier = "javadoc"
|
||||||
val TestsClassifier = "tests"
|
val SourceClassifier = "sources"
|
||||||
|
|
||||||
|
val TestsClassifier = "tests"
|
||||||
|
// Artifact types used when:
|
||||||
|
// * artifacts are explicitly created for Maven dependency resolution (see updateClassifiers)
|
||||||
|
// * declaring artifacts as part of publishing Ivy files.
|
||||||
|
val DocType = "doc"
|
||||||
|
val SourceType = "src"
|
||||||
|
val PomType = "pom"
|
||||||
|
|
||||||
|
assert (DefaultDocTypes contains DocType)
|
||||||
|
assert (DefaultSourceTypes contains SourceType)
|
||||||
|
|
||||||
def extract(url: URL, default: String): String = extract(url.toString, default)
|
def extract(url: URL, default: String): String = extract(url.toString, default)
|
||||||
def extract(name: String, default: String): String =
|
def extract(name: String, default: String): String =
|
||||||
|
|
@ -62,18 +73,18 @@ object Artifact {
|
||||||
base + "-" + module.revision + classifierStr + "." + artifact.extension
|
base + "-" + module.revision + classifierStr + "." + artifact.extension
|
||||||
}
|
}
|
||||||
|
|
||||||
val classifierConfMap = Map(SourceClassifier -> Sources, DocClassifier -> Docs)
|
val classifierTypeMap = Map(SourceClassifier -> SourceType, DocClassifier -> DocType)
|
||||||
val classifierTypeMap = Map(SourceClassifier -> SourceType, DocClassifier -> DocType)
|
// TODO this function shouldn't exist. Configuration should not just be conjured up like that.
|
||||||
def classifierConf(classifier: String): Configuration =
|
def classifierConf(classifier: String): Configuration =
|
||||||
if (classifier.startsWith(TestsClassifier))
|
if(classifier.startsWith(TestsClassifier))
|
||||||
Test
|
Test
|
||||||
else
|
else
|
||||||
classifierConfMap.getOrElse(classifier, Optional)
|
Optional
|
||||||
def classifierType(classifier: String): String = classifierTypeMap.getOrElse(classifier.stripPrefix(TestsClassifier + "-"), DefaultType)
|
def classifierType(classifier: String): String = classifierTypeMap.getOrElse(classifier.stripPrefix(TestsClassifier + "-"), DefaultType)
|
||||||
def classified(name: String, classifier: String): Artifact =
|
def classified(name: String, classifier: String): Artifact =
|
||||||
Artifact(name, classifierType(classifier), DefaultExtension, Some(classifier), classifierConf(classifier) :: Nil, None)
|
Artifact(name, classifierType(classifier), DefaultExtension, Some(classifier), classifierConf(classifier) :: Nil, None)
|
||||||
|
|
||||||
private val optStringPickler = implicitly[Pickler[Option[String]]]
|
private val optStringPickler = implicitly[Pickler[Option[String]]]
|
||||||
private val optStringUnpickler = implicitly[Unpickler[Option[String]]]
|
private val optStringUnpickler = implicitly[Unpickler[Option[String]]]
|
||||||
private val vectorConfigurationPickler = implicitly[Pickler[Vector[Configuration]]]
|
private val vectorConfigurationPickler = implicitly[Pickler[Vector[Configuration]]]
|
||||||
private val vectorConfigurationUnpickler = implicitly[Unpickler[Vector[Configuration]]]
|
private val vectorConfigurationUnpickler = implicitly[Unpickler[Vector[Configuration]]]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ object Configurations {
|
||||||
def default: Seq[Configuration] = defaultMavenConfigurations
|
def default: Seq[Configuration] = defaultMavenConfigurations
|
||||||
def defaultMavenConfigurations: Seq[Configuration] = Seq(Compile, Runtime, Test, Provided, Optional)
|
def defaultMavenConfigurations: Seq[Configuration] = Seq(Compile, Runtime, Test, Provided, Optional)
|
||||||
def defaultInternal: Seq[Configuration] = Seq(CompileInternal, RuntimeInternal, TestInternal)
|
def defaultInternal: Seq[Configuration] = Seq(CompileInternal, RuntimeInternal, TestInternal)
|
||||||
def auxiliary: Seq[Configuration] = Seq(Sources, Docs, Pom)
|
def auxiliary: Seq[Configuration] = Seq(Pom)
|
||||||
def names(cs: Seq[Configuration]) = cs.map(_.name)
|
def names(cs: Seq[Configuration]) = cs.map(_.name)
|
||||||
|
|
||||||
lazy val RuntimeInternal = optionalInternal(Runtime)
|
lazy val RuntimeInternal = optionalInternal(Runtime)
|
||||||
|
|
@ -34,10 +34,8 @@ object Configurations {
|
||||||
lazy val Compile = config("compile")
|
lazy val Compile = config("compile")
|
||||||
lazy val IntegrationTest = config("it") extend (Runtime)
|
lazy val IntegrationTest = config("it") extend (Runtime)
|
||||||
lazy val Provided = config("provided")
|
lazy val Provided = config("provided")
|
||||||
lazy val Docs = config("docs")
|
|
||||||
lazy val Runtime = config("runtime") extend (Compile)
|
lazy val Runtime = config("runtime") extend (Compile)
|
||||||
lazy val Test = config("test") extend (Runtime)
|
lazy val Test = config("test") extend (Runtime)
|
||||||
lazy val Sources = config("sources")
|
|
||||||
lazy val System = config("system")
|
lazy val System = config("system")
|
||||||
lazy val Optional = config("optional")
|
lazy val Optional = config("optional")
|
||||||
lazy val Pom = config("pom")
|
lazy val Pom = config("pom")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue