mirror of https://github.com/sbt/sbt.git
Implement optional/provided configurations, closes #8
This commit is contained in:
parent
02421e46f5
commit
60eda4bb20
|
|
@ -290,11 +290,29 @@ object Configurations
|
||||||
{
|
{
|
||||||
def config(name: String) = new Configuration(name)
|
def config(name: String) = new Configuration(name)
|
||||||
def default: Seq[Configuration] = defaultMavenConfigurations
|
def default: Seq[Configuration] = defaultMavenConfigurations
|
||||||
def defaultMavenConfigurations: Seq[Configuration] = Compile :: Runtime :: Test :: Provided :: System :: Optional :: Sources :: Javadoc :: Nil
|
def defaultMavenConfigurations: Seq[Configuration] = Compile :: Runtime :: Test :: Provided :: Optional :: Nil
|
||||||
|
def defaultInternal: Seq[Configuration] = CompileInternal :: RuntimeInternal :: TestInternal :: Nil
|
||||||
|
|
||||||
|
lazy val RuntimeInternal = optionalInternal(Runtime)
|
||||||
|
lazy val TestInternal = fullInternal(Test)
|
||||||
|
lazy val IntegrationTestInternal = fullInternal(IntegrationTest)
|
||||||
|
lazy val CompileInternal = fullInternal(Compile)
|
||||||
|
|
||||||
|
def internalMap(c: Configuration) = c match {
|
||||||
|
case Compile => CompileInternal
|
||||||
|
case Test => TestInternal
|
||||||
|
case Runtime => RuntimeInternal
|
||||||
|
case IntegrationTest => IntegrationTestInternal
|
||||||
|
case _ => c
|
||||||
|
}
|
||||||
|
|
||||||
|
def internal(base: Configuration, ext: Configuration*) = config(base.name + "-internal") extend(ext : _*) hide;
|
||||||
|
def fullInternal(base: Configuration): Configuration = internal(base, base, Optional, Provided)
|
||||||
|
def optionalInternal(base: Configuration): Configuration = internal(base, base, Optional)
|
||||||
|
|
||||||
lazy val Default = config("default")
|
lazy val Default = config("default")
|
||||||
lazy val Compile = config("compile")
|
lazy val Compile = config("compile")
|
||||||
lazy val IntegrationTest = config("it") extend(Runtime) hide;
|
lazy val IntegrationTest = config("it") extend(Runtime);
|
||||||
lazy val Provided = config("provided")
|
lazy val Provided = config("provided")
|
||||||
lazy val Javadoc = config("javadoc")
|
lazy val Javadoc = config("javadoc")
|
||||||
lazy val Runtime = config("runtime") extend(Compile)
|
lazy val Runtime = config("runtime") extend(Compile)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ package sbt
|
||||||
import Scope.{GlobalScope, ThisScope}
|
import Scope.{GlobalScope, ThisScope}
|
||||||
import compiler.Discovery
|
import compiler.Discovery
|
||||||
import Project.{inConfig, Initialize, inScope, inTask, ScopedKey, Setting, SettingsDefinition}
|
import Project.{inConfig, Initialize, inScope, inTask, ScopedKey, Setting, SettingsDefinition}
|
||||||
import Configurations.{Compile, CompilerPlugin, Test}
|
import Configurations.{Compile, CompilerPlugin, IntegrationTest, Runtime, Test}
|
||||||
import complete._
|
import complete._
|
||||||
import std.TaskExtra._
|
import std.TaskExtra._
|
||||||
|
|
||||||
|
|
@ -43,6 +43,7 @@ object Defaults
|
||||||
def globalCore: Seq[Setting[_]] = inScope(GlobalScope)(Seq(
|
def globalCore: Seq[Setting[_]] = inScope(GlobalScope)(Seq(
|
||||||
pollInterval :== 500,
|
pollInterval :== 500,
|
||||||
autoCompilerPlugins :== true,
|
autoCompilerPlugins :== true,
|
||||||
|
internalConfigurationMap :== Configurations.internalMap _,
|
||||||
initialize :== (),
|
initialize :== (),
|
||||||
credentials :== Nil,
|
credentials :== Nil,
|
||||||
scalaHome :== None,
|
scalaHome :== None,
|
||||||
|
|
@ -319,8 +320,8 @@ object Defaults
|
||||||
target
|
target
|
||||||
}
|
}
|
||||||
|
|
||||||
def mainRunTask = run <<= runTask(fullClasspath in Configurations.Runtime, mainClass in run, runner in run)
|
def mainRunTask = run <<= runTask(fullClasspath in Runtime, mainClass in run, runner in run)
|
||||||
def mainRunMainTask = runMain <<= runMainTask(fullClasspath in Configurations.Runtime, runner in run)
|
def mainRunMainTask = runMain <<= runMainTask(fullClasspath in Runtime, runner in run)
|
||||||
|
|
||||||
def discoverMainClasses(analysis: inc.Analysis): Seq[String] =
|
def discoverMainClasses(analysis: inc.Analysis): Seq[String] =
|
||||||
Discovery.applications(Tests.allDefs(analysis)) collect { case (definition, discovered) if(discovered.hasMain) => definition.name }
|
Discovery.applications(Tests.allDefs(analysis)) collect { case (definition, discovered) if(discovered.hasMain) => definition.name }
|
||||||
|
|
@ -425,9 +426,10 @@ object Defaults
|
||||||
lazy val compileSettings = configSettings ++ (mainRunMainTask +: mainRunTask +: addBaseSources)
|
lazy val compileSettings = configSettings ++ (mainRunMainTask +: mainRunTask +: addBaseSources)
|
||||||
lazy val testSettings = configSettings ++ testTasks
|
lazy val testSettings = configSettings ++ testTasks
|
||||||
|
|
||||||
lazy val itSettings = inConfig(Configurations.IntegrationTest)(testSettings)
|
lazy val itSettings = inConfig(IntegrationTest)(testSettings)
|
||||||
lazy val defaultConfigs = inConfig(Compile)(compileSettings) ++ inConfig(Test)(testSettings)
|
lazy val defaultConfigs = inConfig(Compile)(compileSettings) ++ inConfig(Test)(testSettings)
|
||||||
|
|
||||||
|
|
||||||
// settings that are not specific to a configuration
|
// settings that are not specific to a configuration
|
||||||
lazy val projectBaseSettings: Seq[Setting[_]] = projectCore ++ paths ++ baseClasspaths ++ baseTasks ++ compileBase ++ disableAggregation
|
lazy val projectBaseSettings: Seq[Setting[_]] = projectCore ++ paths ++ baseClasspaths ++ baseTasks ++ compileBase ++ disableAggregation
|
||||||
lazy val defaultSettings: Seq[Setting[_]] = projectBaseSettings ++ defaultConfigs
|
lazy val defaultSettings: Seq[Setting[_]] = projectBaseSettings ++ defaultConfigs
|
||||||
|
|
@ -450,7 +452,8 @@ object Classpaths
|
||||||
internalDependencyClasspath <<= internalDependencies,
|
internalDependencyClasspath <<= internalDependencies,
|
||||||
unmanagedClasspath <<= unmanagedDependencies,
|
unmanagedClasspath <<= unmanagedDependencies,
|
||||||
products <<= makeProducts,
|
products <<= makeProducts,
|
||||||
managedClasspath <<= (configuration, classpathTypes, update) map managedJars,
|
classpathConfiguration <<= (internalConfigurationMap, configuration)( _ apply _ ),
|
||||||
|
managedClasspath <<= (classpathConfiguration, classpathTypes, update) map managedJars,
|
||||||
unmanagedJars <<= (configuration, unmanagedBase, classpathFilter, defaultExcludes) map { (config, base, filter, excl) =>
|
unmanagedJars <<= (configuration, unmanagedBase, classpathFilter, defaultExcludes) map { (config, base, filter, excl) =>
|
||||||
(base * (filter -- excl) +++ (base / config.name).descendentsExcept(filter, excl)).getFiles
|
(base * (filter -- excl) +++ (base / config.name).descendentsExcept(filter, excl)).getFiles
|
||||||
}
|
}
|
||||||
|
|
@ -525,8 +528,8 @@ object Classpaths
|
||||||
ivyConfiguration <<= (fullResolvers, ivyPaths, otherResolvers, moduleConfigurations, offline, checksums, appConfiguration, streams) map { (rs, paths, other, moduleConfs, off, check, app, s) =>
|
ivyConfiguration <<= (fullResolvers, ivyPaths, otherResolvers, moduleConfigurations, offline, checksums, appConfiguration, streams) map { (rs, paths, other, moduleConfs, off, check, app, s) =>
|
||||||
new InlineIvyConfiguration(paths, rs, other, moduleConfs, off, Some(lock(app)), check, s.log)
|
new InlineIvyConfiguration(paths, rs, other, moduleConfs, off, Some(lock(app)), check, s.log)
|
||||||
},
|
},
|
||||||
ivyConfigurations <<= (autoCompilerPlugins, thisProject) { (auto, project) =>
|
ivyConfigurations <<= (autoCompilerPlugins, internalConfigurationMap, thisProject) { (auto, internalMap, project) =>
|
||||||
project.configurations ++ (if(auto) CompilerPlugin :: Nil else Nil)
|
(project.configurations ++ project.configurations.map(internalMap) ++ (if(auto) CompilerPlugin :: Nil else Nil)).distinct
|
||||||
},
|
},
|
||||||
moduleSettings <<= moduleSettings0,
|
moduleSettings <<= moduleSettings0,
|
||||||
makePomConfiguration <<= (artifactPath in makePom)(file => makePomConfigurationTask(file)),
|
makePomConfiguration <<= (artifactPath in makePom)(file => makePomConfigurationTask(file)),
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,8 @@ object Keys
|
||||||
val dependencyClasspath = TaskKey[Classpath]("dependency-classpath")
|
val dependencyClasspath = TaskKey[Classpath]("dependency-classpath")
|
||||||
val fullClasspath = TaskKey[Classpath]("full-classpath")
|
val fullClasspath = TaskKey[Classpath]("full-classpath")
|
||||||
|
|
||||||
|
val internalConfigurationMap = SettingKey[Configuration => Configuration]("internal-configuration-map")
|
||||||
|
val classpathConfiguration = SettingKey[Configuration]("classpath-configuration")
|
||||||
val ivyConfiguration = TaskKey[IvyConfiguration]("ivy-configuration")
|
val ivyConfiguration = TaskKey[IvyConfiguration]("ivy-configuration")
|
||||||
val ivyConfigurations = SettingKey[Seq[Configuration]]("ivy-configurations")
|
val ivyConfigurations = SettingKey[Seq[Configuration]]("ivy-configurations")
|
||||||
val moduleSettings = TaskKey[ModuleSettings]("module-settings")
|
val moduleSettings = TaskKey[ModuleSettings]("module-settings")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue