mirror of https://github.com/sbt/sbt.git
cleaning up artifact configurations
This commit is contained in:
parent
25edfc5eeb
commit
540f7df9e1
|
|
@ -290,8 +290,9 @@ object Configurations
|
|||
{
|
||||
def config(name: String) = new Configuration(name)
|
||||
def default: Seq[Configuration] = defaultMavenConfigurations
|
||||
def defaultMavenConfigurations: Seq[Configuration] = Compile :: Runtime :: Test :: Provided :: Optional :: Nil
|
||||
def defaultInternal: Seq[Configuration] = CompileInternal :: RuntimeInternal :: TestInternal :: Nil
|
||||
def defaultMavenConfigurations: Seq[Configuration] = Seq(Compile, Runtime, Test, Provided, Optional)
|
||||
def defaultInternal: Seq[Configuration] = Seq(CompileInternal, RuntimeInternal, TestInternal)
|
||||
def auxiliary: Seq[Configuration] = Seq(Sources, Docs, Pom)
|
||||
|
||||
lazy val RuntimeInternal = optionalInternal(Runtime)
|
||||
lazy val TestInternal = fullInternal(Test)
|
||||
|
|
@ -314,12 +315,13 @@ object Configurations
|
|||
lazy val Compile = config("compile")
|
||||
lazy val IntegrationTest = config("it") extend(Runtime)
|
||||
lazy val Provided = config("provided") intransitive ;
|
||||
lazy val Javadoc = config("javadoc")
|
||||
lazy val Docs = config("docs")
|
||||
lazy val Runtime = config("runtime") extend(Compile)
|
||||
lazy val Test = config("test") extend(Runtime)
|
||||
lazy val Sources = config("sources")
|
||||
lazy val System = config("system")
|
||||
lazy val Optional = config("optional")
|
||||
lazy val Pom = config("pom")
|
||||
|
||||
lazy val CompilerPlugin = config("plugin") hide
|
||||
|
||||
|
|
@ -347,6 +349,9 @@ final case class Artifact(name: String, `type`: String, extension: String, class
|
|||
{
|
||||
def extra(attributes: (String,String)*) = Artifact(name, `type`, extension, classifier, configurations, url, extraAttributes ++ ModuleID.checkE(attributes))
|
||||
}
|
||||
|
||||
import Configurations.{config, Docs, Optional, Pom, Sources}
|
||||
|
||||
object Artifact
|
||||
{
|
||||
def apply(name: String): Artifact = Artifact(name, defaultType, defaultExtension, None, Nil, None)
|
||||
|
|
@ -357,12 +362,18 @@ object Artifact
|
|||
def apply(name: String, url: URL): Artifact =Artifact(name, extract(url, defaultType), extract(url, defaultExtension), None, Nil, Some(url))
|
||||
def apply(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Iterable[Configuration], url: Option[URL]): Artifact =
|
||||
Artifact(name, `type`, extension, classifier, configurations, url, Map.empty)
|
||||
|
||||
val defaultExtension = "jar"
|
||||
val defaultType = "jar"
|
||||
|
||||
def sources(name: String) = classified(name, SourceClassifier)
|
||||
def javadoc(name: String) = classified(name, DocClassifier)
|
||||
def pom(name: String) = Artifact(name, PomType, PomType, None, Pom :: Nil, None)
|
||||
|
||||
val DocClassifier = "javadoc"
|
||||
val SourceClassifier = "sources"
|
||||
val PomType = "pom"
|
||||
|
||||
def extract(url: URL, default: String): String = extract(url.toString, default)
|
||||
def extract(name: String, default: String): String =
|
||||
{
|
||||
|
|
@ -388,9 +399,12 @@ object Artifact
|
|||
}
|
||||
def cross(enable: Boolean, scalaVersion: String): String = if(enable) "_" + scalaVersion else ""
|
||||
|
||||
val classifierTypeMap = Map("sources" -> "src", "javadoc" -> "doc")
|
||||
val classifierConfMap = Map(SourceClassifier -> Sources, DocClassifier -> Docs)
|
||||
val classifierTypeMap = Map(SourceClassifier -> "src", DocClassifier -> "doc")
|
||||
def classifierConf(classifier: String): Configuration = classifierConfMap.getOrElse(classifier, Optional)
|
||||
def classifierType(classifier: String): String = classifierTypeMap.getOrElse(classifier, defaultType)
|
||||
def classified(name: String, classifier: String): Artifact = Artifact(name, classifierType(classifier), defaultExtension, classifier)
|
||||
def classified(name: String, classifier: String): Artifact =
|
||||
Artifact(name, classifierType(classifier), defaultExtension, Some(classifier), classifierConf(classifier) :: Nil, None)
|
||||
}
|
||||
final case class ModuleConfiguration(organization: String, name: String, revision: String, resolver: Resolver)
|
||||
object ModuleConfiguration
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package sbt
|
|||
import Scope.{fillTaskAxis, GlobalScope, ThisScope}
|
||||
import compiler.Discovery
|
||||
import Project.{inConfig, Initialize, inScope, inTask, ScopedKey, Setting, SettingsDefinition}
|
||||
import Artifact.{DocClassifier, SourceClassifier}
|
||||
import Configurations.{Compile, CompilerPlugin, IntegrationTest, Runtime, Test}
|
||||
import complete._
|
||||
import std.TaskExtra._
|
||||
|
|
@ -292,9 +293,6 @@ object Defaults extends BuildCommon
|
|||
packageTasks(packageSrc, packageSrcTask) ++
|
||||
packageTasks(packageDoc, packageDocTask)
|
||||
|
||||
final val SourceClassifier = "sources"
|
||||
final val DocClassifier = "javadoc"
|
||||
|
||||
private[this] val allSubpaths = (dir: File) => (dir.*** --- dir) x (relativeTo(dir)|flat)
|
||||
|
||||
def packageBinTask = products map { ps => ps flatMap { p => allSubpaths(p) } }
|
||||
|
|
@ -329,9 +327,10 @@ object Defaults extends BuildCommon
|
|||
artifact <<= (artifact, artifactClassifier, configuration) { (a,classifier,c) =>
|
||||
val cPart = if(c == Compile) Nil else c.name :: Nil
|
||||
val combined = cPart ++ classifier.toList
|
||||
if(combined.isEmpty) a.copy(classifier = None) else {
|
||||
if(combined.isEmpty) a.copy(classifier = None, configurations = c :: Nil) else {
|
||||
val classifier = combined mkString "-"
|
||||
a.copy(classifier = Some(classifier), `type` = Artifact.classifierType(classifier))
|
||||
val confs = if(a.configurations.isEmpty) Artifact.classifierConf(classifier) :: Nil else a.configurations
|
||||
a.copy(classifier = Some(classifier), `type` = Artifact.classifierType(classifier), configurations = confs)
|
||||
}
|
||||
},
|
||||
cacheDirectory <<= cacheDirectory / key.key.label,
|
||||
|
|
@ -598,7 +597,7 @@ object Classpaths
|
|||
publishTo in GlobalScope :== None,
|
||||
artifactPath in makePom <<= artifactPathSetting(artifact in makePom),
|
||||
publishArtifact in makePom <<= publishMavenStyle.identity,
|
||||
artifact in makePom <<= moduleName( name => Artifact(name, "pom", "pom") ),
|
||||
artifact in makePom <<= moduleName(Artifact.pom),
|
||||
projectID <<= (organization,moduleName,version,artifacts,crossPaths){ (org,module,version,as,crossEnabled) =>
|
||||
ModuleID(org, module, version).cross(crossEnabled).artifacts(as : _*)
|
||||
},
|
||||
|
|
@ -611,6 +610,7 @@ object Classpaths
|
|||
ivyConfigurations <<= (autoCompilerPlugins, internalConfigurationMap, thisProject) { (auto, internalMap, project) =>
|
||||
(project.configurations ++ project.configurations.map(internalMap) ++ (if(auto) CompilerPlugin :: Nil else Nil)).distinct
|
||||
},
|
||||
ivyConfigurations ++= Configurations.auxiliary,
|
||||
moduleSettings <<= moduleSettings0,
|
||||
makePomConfiguration <<= (artifactPath in makePom, pomExtra, pomPostProcess, pomIncludeRepository, pomAllRepositories) {
|
||||
(file, extra, process, include, all) => new MakePomConfiguration(file, None, extra, process, include, all)
|
||||
|
|
@ -631,7 +631,7 @@ object Classpaths
|
|||
update <<= (ivyModule, updateConfiguration, cacheDirectory, scalaInstance, streams) map { (module, config, cacheDirectory, si, s) =>
|
||||
cachedUpdate(cacheDirectory / "update", module, config, Some(si), s.log)
|
||||
},
|
||||
transitiveClassifiers in GlobalScope :== Seq("sources", "javadoc"),
|
||||
transitiveClassifiers in GlobalScope :== Seq(SourceClassifier, DocClassifier),
|
||||
updateClassifiers <<= (ivySbt, projectID, update, transitiveClassifiers, updateConfiguration, ivyScala, streams) map { (is, pid, up, classifiers, c, ivyScala, s) =>
|
||||
IvyActions.transitive(is, pid, up, classifiers, c, ivyScala, s.log)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ package object sbt extends sbt.std.TaskExtra with sbt.Types with sbt.ProcessExtr
|
|||
def Runtime = C.Runtime
|
||||
def IntegrationTest = C.IntegrationTest
|
||||
def Default = C.Default
|
||||
def Javadoc = C.Javadoc
|
||||
def Docs = C.Docs
|
||||
def Sources = C.Sources
|
||||
def Provided = C.Provided
|
||||
// java.lang.System is more important, so don't alias this one
|
||||
|
|
|
|||
Loading…
Reference in New Issue