mirror of https://github.com/sbt/sbt.git
Merge pull request #2524 from eed3si9n/wip/buildscala
sbt.Build => sbt.internal.BuildDef
This commit is contained in:
commit
19461668c4
|
|
@ -9,6 +9,7 @@ import Def.{ displayFull, ScopedKey, ScopeLocal, Setting }
|
|||
import BuildPaths.outputDirectory
|
||||
import Scope.GlobalScope
|
||||
import BuildStreams.Streams
|
||||
import sbt.internal.{ BuildDef, Load }
|
||||
import sbt.io.Path._
|
||||
import sbt.internal.util.{ Attributed, AttributeEntry, AttributeKey, AttributeMap, Settings }
|
||||
import sbt.internal.util.Attributed.data
|
||||
|
|
@ -74,9 +75,9 @@ final class LoadedBuildUnit(val unit: BuildUnit, val defined: Map[String, Resolv
|
|||
* @param base The base directory of the build definition, typically `<build base>/project/`.
|
||||
* @param loader The ClassLoader containing all classes and plugins for the build definition project.
|
||||
* Note that this does not include classes for .sbt files.
|
||||
* @param builds The list of [[Build]]s for the build unit.
|
||||
* In addition to auto-discovered [[Build]]s, this includes any auto-generated default [[Build]]s.
|
||||
* @param projects The list of all [[Project]]s from all [[Build]]s.
|
||||
* @param builds The list of [[BuildDef]]s for the build unit.
|
||||
* In addition to auto-discovered [[BuildDef]]s, this includes any auto-generated default [[BuildDef]]s.
|
||||
* @param projects The list of all [[Project]]s from all [[BuildDef]]s.
|
||||
* These projects have not yet been resolved, but they have had auto-plugins applied.
|
||||
* In particular, each [[Project]]'s `autoPlugins` field is populated according to their configured `plugins`
|
||||
* and their `settings` and `configurations` updated as appropriate.
|
||||
|
|
@ -86,14 +87,14 @@ final class LoadedDefinitions(
|
|||
val base: File,
|
||||
val target: Seq[File],
|
||||
val loader: ClassLoader,
|
||||
val builds: Seq[Build],
|
||||
val builds: Seq[BuildDef],
|
||||
val projects: Seq[Project],
|
||||
val buildNames: Seq[String],
|
||||
val dslDefinitions: DefinedSbtValues) {
|
||||
def this(base: File,
|
||||
target: Seq[File],
|
||||
loader: ClassLoader,
|
||||
builds: Seq[Build],
|
||||
builds: Seq[BuildDef],
|
||||
projects: Seq[Project],
|
||||
buildNames: Seq[String]) = this(base, target, loader, builds, projects, buildNames, DefinedSbtValues.empty)
|
||||
}
|
||||
|
|
@ -122,7 +123,7 @@ case class DetectedAutoPlugin(name: String, value: AutoPlugin, hasAutoImport: Bo
|
|||
*
|
||||
* @param builds The [[Build]]s detected in the build definition. This does not include the default [[Build]] that sbt creates if none is defined.
|
||||
*/
|
||||
final class DetectedPlugins(val plugins: DetectedModules[Plugin], val autoPlugins: Seq[DetectedAutoPlugin], val builds: DetectedModules[Build]) {
|
||||
final class DetectedPlugins(val plugins: DetectedModules[Plugin], val autoPlugins: Seq[DetectedAutoPlugin], val builds: DetectedModules[BuildDef]) {
|
||||
/** Sequence of import expressions for the build definition. This includes the names of the [[Plugin]], [[Build]], and [[AutoImport]] modules, but not the [[AutoPlugin]] modules. */
|
||||
lazy val imports: Seq[String] = BuildUtil.getImports(plugins.names ++ builds.names) ++
|
||||
BuildUtil.importAllRoot(autoImports(autoPluginAutoImports)) ++
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.util.{ Relation, Settings, Dag }
|
||||
import sbt.internal.Load
|
||||
|
||||
import java.net.URI
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.{ ErrorHandling, RMap, Show, Signals, Types }
|
||||
import sbt.util.Logger
|
||||
import sbt.librarymanagement.{ Resolver, UpdateReport }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import Project._
|
||||
import Scope.GlobalScope
|
||||
import Def.{ ScopedKey, Setting }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package sbt
|
|||
import sbt.librarymanagement.{ Configuration, Configurations, ModuleID, Resolver, SbtArtifacts, UpdateReport }
|
||||
import sbt.internal.util.Attributed
|
||||
|
||||
import Load.{ BuildStructure => _, _ }
|
||||
import sbt.internal.{ Load, LoadBuildConfiguration }
|
||||
import Def.{ ScopedKey, Setting }
|
||||
import Scoped._
|
||||
import Keys._
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.Attributed
|
||||
import sbt.util.{ Level, Logger }
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.{ AttributeKey, AttributeMap, complete, ConsoleOut, GlobalLogging, LineRange, MainLogging, SimpleReader, Types }
|
||||
import sbt.util.{ Level, Logger }
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package sbt
|
||||
|
||||
import Def.Setting
|
||||
|
||||
// TODO 0.14.0: decide if Plugin should be deprecated in favor of AutoPlugin
|
||||
trait Plugin {
|
||||
@deprecated("Override projectSettings or buildSettings instead.", "0.12.0")
|
||||
def settings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended to all projects in a build. */
|
||||
def projectSettings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended at the build scope. */
|
||||
def buildSettings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended at the global scope. */
|
||||
def globalSettings: Seq[Setting[_]] = Nil
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.util.Attributed
|
||||
|
||||
import sbt.internal.{ BuildDef, IncompatiblePluginsException }
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import Attributed.data
|
||||
import Build.analyzed
|
||||
import sbt.internal.BuildDef.analyzed
|
||||
import xsbt.api.{ Discovered, Discovery }
|
||||
import xsbti.compile.CompileAnalysis
|
||||
import sbt.internal.inc.ModuleUtilities
|
||||
|
|
@ -22,7 +22,7 @@ object PluginDiscovery {
|
|||
final val Plugins = "sbt/sbt.plugins"
|
||||
final val Builds = "sbt/sbt.builds"
|
||||
}
|
||||
/** Names of top-level modules that subclass sbt plugin-related classes: [[Plugin]], [[AutoPlugin]], and [[Build]]. */
|
||||
/** Names of top-level modules that subclass sbt plugin-related classes: [[Plugin]], [[AutoPlugin]], and [[BuildDef]]. */
|
||||
final class DiscoveredNames(val plugins: Seq[String], val autoPlugins: Seq[String], val builds: Seq[String])
|
||||
|
||||
def emptyDiscoveredNames: DiscoveredNames = new DiscoveredNames(Nil, Nil, Nil)
|
||||
|
|
@ -45,7 +45,7 @@ object PluginDiscovery {
|
|||
case (name, value) =>
|
||||
DetectedAutoPlugin(name, value, sbt.Plugins.hasAutoImportGetter(value, loader))
|
||||
}
|
||||
new DetectedPlugins(discover[Plugin](Plugins), allAutoPlugins, discover[Build](Builds))
|
||||
new DetectedPlugins(discover[Plugin](Plugins), allAutoPlugins, discover[BuildDef](Builds))
|
||||
}
|
||||
|
||||
/** Discovers the sbt-plugin-related top-level modules from the provided source `analysis`. */
|
||||
|
|
@ -53,7 +53,7 @@ object PluginDiscovery {
|
|||
{
|
||||
def discover[T](implicit classTag: reflect.ClassTag[T]): Seq[String] =
|
||||
sourceModuleNames(analysis, classTag.runtimeClass.getName)
|
||||
new DiscoveredNames(discover[Plugin], discover[AutoPlugin], discover[Build])
|
||||
new DiscoveredNames(discover[Plugin], discover[AutoPlugin], discover[BuildDef])
|
||||
}
|
||||
|
||||
// TODO: for 0.14.0, consider consolidating into a single file, which would make the classpath search 4x faster
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import Project.{ Initialize => _, Setting => _, _ }
|
|||
import Keys.{ appConfiguration, stateBuildStructure, commands, configuration, historyPath, projectCommand, sessionSettings, shellPrompt, thisProject, thisProjectRef, watch }
|
||||
import Scope.{ GlobalScope, ThisScope }
|
||||
import Def.{ Flattened, Initialize, ScopedKey, Setting }
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.Types.{ const, idFun }
|
||||
import sbt.internal.util.complete.DefaultParsers
|
||||
import sbt.librarymanagement.Configuration
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.complete
|
||||
|
||||
import ProjectNavigation._
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package sbt
|
||||
|
||||
import sbt.internal.BuildLoader
|
||||
import sbt.internal.librarymanagement.StringUtilities
|
||||
|
||||
import sbt.io.{ Hash, IO }
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package sbt
|
|||
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import BuildLoader.ResolveInfo
|
||||
import sbt.internal.BuildLoader.ResolveInfo
|
||||
import Def.{ ScopedKey, Setting }
|
||||
|
||||
object RetrieveUnit {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.{ AttributeKey, Dag, Types }
|
||||
|
||||
import sbt.librarymanagement.Configuration
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.librarymanagement.Configurations
|
||||
|
||||
import sbt.util.Level
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.{ AttributeKey, complete, Relation, Settings, Show, Types, Util }
|
||||
|
||||
import sbt.librarymanagement.Configuration
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt
|
||||
package internal
|
||||
|
||||
import java.io.File
|
||||
import Keys.{ name, organization, thisProject, autoGeneratedProject }
|
||||
|
|
@ -10,8 +11,7 @@ import sbt.io.Hash
|
|||
import sbt.internal.util.Attributed
|
||||
import sbt.internal.inc.ReflectUtilities
|
||||
|
||||
// name is more like BuildDefinition, but that is too long
|
||||
trait Build {
|
||||
trait BuildDef {
|
||||
def projectDefinitions(baseDirectory: File): Seq[Project] = projects
|
||||
def projects: Seq[Project] = ReflectUtilities.allVals[Project](this).values.toSeq
|
||||
// TODO: Should we grab the build core setting shere or in a plugin?
|
||||
|
|
@ -23,31 +23,16 @@ trait Build {
|
|||
*/
|
||||
def rootProject: Option[Project] = None
|
||||
}
|
||||
// TODO 0.14.0: decide if Plugin should be deprecated in favor of AutoPlugin
|
||||
trait Plugin {
|
||||
@deprecated("Override projectSettings or buildSettings instead.", "0.12.0")
|
||||
def settings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended to all projects in a build. */
|
||||
def projectSettings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended at the build scope. */
|
||||
def buildSettings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended at the global scope. */
|
||||
def globalSettings: Seq[Setting[_]] = Nil
|
||||
}
|
||||
|
||||
object Build {
|
||||
val defaultEmpty: Build = new Build { override def projects = Nil }
|
||||
val default: Build = new Build { override def projectDefinitions(base: File) = defaultProject(defaultID(base), base) :: Nil }
|
||||
def defaultAggregated(id: String, aggregate: Seq[ProjectRef]): Build = new Build {
|
||||
private[sbt] object BuildDef {
|
||||
val defaultEmpty: BuildDef = new BuildDef { override def projects = Nil }
|
||||
val default: BuildDef = new BuildDef { override def projectDefinitions(base: File) = defaultProject(defaultID(base), base) :: Nil }
|
||||
def defaultAggregated(id: String, aggregate: Seq[ProjectRef]): BuildDef = new BuildDef {
|
||||
override def projectDefinitions(base: File) = defaultAggregatedProject(id, base, aggregate) :: Nil
|
||||
}
|
||||
|
||||
def defaultID(base: File, prefix: String = "default"): String = prefix + "-" + Hash.trimHashString(base.getAbsolutePath, 6)
|
||||
@deprecated("Explicitly specify the ID", "0.13.0")
|
||||
def defaultProject(base: File): Project = defaultProject(defaultID(base), base)
|
||||
|
||||
def defaultProject(id: String, base: File): Project = Project(id, base).settings(defaultProjectSettings)
|
||||
def defaultAggregatedProject(id: String, base: File, agg: Seq[ProjectRef]): Project =
|
||||
defaultProject(id, base).aggregate(agg: _*)
|
||||
|
|
@ -66,8 +51,5 @@ object Build {
|
|||
},
|
||||
autoGeneratedProject := true
|
||||
)
|
||||
|
||||
@deprecated("Use Attributed.data", "0.13.0")
|
||||
def data[T](in: Seq[Attributed[T]]): Seq[T] = Attributed.data(in)
|
||||
def analyzed(in: Seq[Attributed[_]]): Seq[xsbti.compile.CompileAnalysis] = in.flatMap { _.metadata.get(Keys.analysis) }
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt
|
||||
package internal
|
||||
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt
|
||||
package internal
|
||||
|
||||
import sbt.internal.util.{ Settings, Show, ~> }
|
||||
import sbt.librarymanagement.{ Configuration, Configurations, Resolver }
|
||||
|
|
@ -31,7 +32,7 @@ import sbt.internal.io.Alternatives
|
|||
import sbt.util.Logger
|
||||
import xsbti.compile.Compilers
|
||||
|
||||
object Load {
|
||||
private[sbt] object Load {
|
||||
// note that there is State passed in but not pulled out
|
||||
def defaultLoad(state: State, baseDirectory: File, log: Logger, isPlugin: Boolean = false, topLevelExtras: List[URI] = Nil): (() => Eval, sbt.BuildStructure) =
|
||||
{
|
||||
|
|
@ -45,7 +46,7 @@ object Load {
|
|||
definesClass.clear()
|
||||
result
|
||||
}
|
||||
def defaultPreGlobal(state: State, baseDirectory: File, definesClass: DefinesClass, globalBase: File, log: Logger): sbt.LoadBuildConfiguration =
|
||||
def defaultPreGlobal(state: State, baseDirectory: File, definesClass: DefinesClass, globalBase: File, log: Logger): LoadBuildConfiguration =
|
||||
{
|
||||
val provider = state.configuration.provider
|
||||
val scalaProvider = provider.scalaProvider
|
||||
|
|
@ -64,7 +65,7 @@ object Load {
|
|||
val initialID = baseDirectory.getName
|
||||
val pluginMgmt = PluginManagement(loader)
|
||||
val inject = InjectSettings(injectGlobal(state), Nil, const(Nil))
|
||||
new sbt.LoadBuildConfiguration(stagingDirectory, classpath, loader, compilers, evalPluginDef, definesClass, delegates,
|
||||
new LoadBuildConfiguration(stagingDirectory, classpath, loader, compilers, evalPluginDef, definesClass, delegates,
|
||||
EvaluateTask.injectStreams, pluginMgmt, inject, None, Nil, log)
|
||||
}
|
||||
private def bootIvyHome(app: xsbti.AppConfiguration): Option[File] =
|
||||
|
|
@ -74,7 +75,7 @@ object Load {
|
|||
(appConfiguration in GlobalScope :== state.configuration) +:
|
||||
LogManager.settingsLogger(state) +:
|
||||
EvaluateTask.injectSettings
|
||||
def defaultWithGlobal(state: State, base: File, rawConfig: sbt.LoadBuildConfiguration, globalBase: File, log: Logger): sbt.LoadBuildConfiguration =
|
||||
def defaultWithGlobal(state: State, base: File, rawConfig: LoadBuildConfiguration, globalBase: File, log: Logger): LoadBuildConfiguration =
|
||||
{
|
||||
val globalPluginsDir = getGlobalPluginsDirectory(state, globalBase)
|
||||
val withGlobal = loadGlobal(state, base, globalPluginsDir, rawConfig)
|
||||
|
|
@ -82,13 +83,13 @@ object Load {
|
|||
loadGlobalSettings(base, globalBase, globalSettings, withGlobal)
|
||||
}
|
||||
|
||||
def loadGlobalSettings(base: File, globalBase: File, files: Seq[File], config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
|
||||
def loadGlobalSettings(base: File, globalBase: File, files: Seq[File], config: LoadBuildConfiguration): LoadBuildConfiguration =
|
||||
{
|
||||
val compiled: ClassLoader => Seq[Setting[_]] =
|
||||
if (files.isEmpty || base == globalBase) const(Nil) else buildGlobalSettings(globalBase, files, config)
|
||||
config.copy(injectSettings = config.injectSettings.copy(projectLoaded = compiled))
|
||||
}
|
||||
def buildGlobalSettings(base: File, files: Seq[File], config: sbt.LoadBuildConfiguration): ClassLoader => Seq[Setting[_]] =
|
||||
def buildGlobalSettings(base: File, files: Seq[File], config: LoadBuildConfiguration): ClassLoader => Seq[Setting[_]] =
|
||||
{
|
||||
val eval = mkEval(data(config.globalPluginClasspath), base, defaultEvalOptions)
|
||||
|
||||
|
|
@ -103,7 +104,7 @@ object Load {
|
|||
loaded.settings
|
||||
}
|
||||
}
|
||||
def loadGlobal(state: State, base: File, global: File, config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
|
||||
def loadGlobal(state: State, base: File, global: File, config: LoadBuildConfiguration): LoadBuildConfiguration =
|
||||
if (base != global && global.exists) {
|
||||
val gp = GlobalPlugin.load(global, state, config)
|
||||
config.copy(globalPlugin = Some(gp))
|
||||
|
|
@ -144,7 +145,7 @@ object Load {
|
|||
// 6) Load all configurations using build definitions and plugins (their classpaths and loaded instances).
|
||||
// 7) Combine settings from projects, plugins, and configurations
|
||||
// 8) Evaluate settings
|
||||
def apply(rootBase: File, s: State, config: sbt.LoadBuildConfiguration): (() => Eval, sbt.BuildStructure) =
|
||||
def apply(rootBase: File, s: State, config: LoadBuildConfiguration): (() => Eval, sbt.BuildStructure) =
|
||||
{
|
||||
// load, which includes some resolution, but can't fill in project IDs yet, so follow with full resolution
|
||||
val loaded = resolveProjects(load(rootBase, s, config))
|
||||
|
|
@ -292,9 +293,9 @@ object Load {
|
|||
if (srcs.isEmpty) const(LoadedSbtFile.empty)
|
||||
else EvaluateConfigurations(eval(), srcs, imports)
|
||||
|
||||
def load(file: File, s: State, config: sbt.LoadBuildConfiguration): sbt.PartBuild =
|
||||
def load(file: File, s: State, config: LoadBuildConfiguration): sbt.PartBuild =
|
||||
load(file, builtinLoader(s, config.copy(pluginManagement = config.pluginManagement.shift, extraBuilds = Nil)), config.extraBuilds.toList)
|
||||
def builtinLoader(s: State, config: sbt.LoadBuildConfiguration): BuildLoader =
|
||||
def builtinLoader(s: State, config: LoadBuildConfiguration): BuildLoader =
|
||||
{
|
||||
val fail = (uri: URI) => sys.error("Invalid build URI (no handler available): " + uri)
|
||||
val resolver = (info: BuildLoader.ResolveInfo) => RetrieveUnit(info)
|
||||
|
|
@ -443,7 +444,7 @@ object Load {
|
|||
def noProject(uri: URI, id: String) = sys.error(s"No project '$id' defined in '$uri'.")
|
||||
def noConfiguration(uri: URI, id: String, conf: String) = sys.error(s"No configuration '$conf' defined in project '$id' in '$uri'")
|
||||
|
||||
def loadUnit(uri: URI, localBase: File, s: State, config: sbt.LoadBuildConfiguration): sbt.BuildUnit =
|
||||
def loadUnit(uri: URI, localBase: File, s: State, config: LoadBuildConfiguration): sbt.BuildUnit =
|
||||
{
|
||||
val normBase = localBase.getCanonicalFile
|
||||
val defDir = projectStandard(normBase)
|
||||
|
|
@ -470,12 +471,12 @@ object Load {
|
|||
val hasRoot = loadedProjectsRaw.projects.exists(_.base == normBase) || defsScala.exists(_.rootProject.isDefined)
|
||||
val (loadedProjects, defaultBuildIfNone, keepClassFiles) =
|
||||
if (hasRoot)
|
||||
(loadedProjectsRaw.projects, Build.defaultEmpty, loadedProjectsRaw.generatedConfigClassFiles)
|
||||
(loadedProjectsRaw.projects, BuildDef.defaultEmpty, loadedProjectsRaw.generatedConfigClassFiles)
|
||||
else {
|
||||
val existingIDs = loadedProjectsRaw.projects.map(_.id)
|
||||
val refs = existingIDs.map(id => ProjectRef(uri, id))
|
||||
val defaultID = autoID(normBase, config.pluginManagement.context, existingIDs)
|
||||
val b = Build.defaultAggregated(defaultID, refs)
|
||||
val b = BuildDef.defaultAggregated(defaultID, refs)
|
||||
val defaultProjects = loadProjects(projectsFromBuild(b, normBase), false)
|
||||
(defaultProjects.projects ++ loadedProjectsRaw.projects, b, defaultProjects.generatedConfigClassFiles ++ loadedProjectsRaw.generatedConfigClassFiles)
|
||||
}
|
||||
|
|
@ -500,19 +501,19 @@ object Load {
|
|||
case Left(msg) => sys.error(autoIDError(f, msg))
|
||||
}
|
||||
def nthParentName(f: File, i: Int): String =
|
||||
if (f eq null) Build.defaultID(localBase) else if (i <= 0) normalizeID(f) else nthParentName(f.getParentFile, i - 1)
|
||||
if (f eq null) BuildDef.defaultID(localBase) else if (i <= 0) normalizeID(f) else nthParentName(f.getParentFile, i - 1)
|
||||
val pluginDepth = context.pluginProjectDepth
|
||||
val postfix = "-build" * pluginDepth
|
||||
val idBase = if (context.globalPluginProject) "global-plugins" else nthParentName(localBase, pluginDepth)
|
||||
val tryID = idBase + postfix
|
||||
if (existingIDs.contains(tryID)) Build.defaultID(localBase) else tryID
|
||||
if (existingIDs.contains(tryID)) BuildDef.defaultID(localBase) else tryID
|
||||
}
|
||||
|
||||
private[this] def autoIDError(base: File, reason: String): String =
|
||||
"Could not derive root project ID from directory " + base.getAbsolutePath + ":\n" +
|
||||
reason + "\nRename the directory or explicitly define a root project."
|
||||
|
||||
private[this] def projectsFromBuild(b: Build, base: File): Seq[Project] =
|
||||
private[this] def projectsFromBuild(b: BuildDef, base: File): Seq[Project] =
|
||||
b.projectDefinitions(base).map(resolveBase(base))
|
||||
|
||||
// Lame hackery to keep track of our state.
|
||||
|
|
@ -605,8 +606,8 @@ object Load {
|
|||
val existingIds = otherProjects.projects map (_.id)
|
||||
val refs = existingIds map (id => ProjectRef(buildUri, id))
|
||||
val defaultID = autoID(buildBase, context, existingIds)
|
||||
val root0 = if (discovered.isEmpty || java.lang.Boolean.getBoolean("sbt.root.ivyplugin")) Build.defaultAggregatedProject(defaultID, buildBase, refs)
|
||||
else Build.generatedRootWithoutIvyPlugin(defaultID, buildBase, refs)
|
||||
val root0 = if (discovered.isEmpty || java.lang.Boolean.getBoolean("sbt.root.ivyplugin")) BuildDef.defaultAggregatedProject(defaultID, buildBase, refs)
|
||||
else BuildDef.generatedRootWithoutIvyPlugin(defaultID, buildBase, refs)
|
||||
val root = finalizeProject(root0, files)
|
||||
val result = root +: (acc ++ otherProjects.projects)
|
||||
log.debug(s"[Loading] Done in ${buildBase}, returning: ${result.map(_.id).mkString("(", ", ", ")")}")
|
||||
|
|
@ -785,17 +786,17 @@ object Load {
|
|||
cp filter { f => !files.contains(f.data) }
|
||||
}
|
||||
|
||||
def enableSbtPlugin(config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
|
||||
def enableSbtPlugin(config: LoadBuildConfiguration): LoadBuildConfiguration =
|
||||
config.copy(injectSettings = config.injectSettings.copy(
|
||||
global = autoPluginSettings ++ config.injectSettings.global,
|
||||
project = config.pluginManagement.inject ++ config.injectSettings.project
|
||||
))
|
||||
def activateGlobalPlugin(config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
|
||||
def activateGlobalPlugin(config: LoadBuildConfiguration): LoadBuildConfiguration =
|
||||
config.globalPlugin match {
|
||||
case Some(gp) => config.copy(injectSettings = config.injectSettings.copy(project = gp.inject))
|
||||
case None => config
|
||||
}
|
||||
def plugins(dir: File, s: State, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
def plugins(dir: File, s: State, config: LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
if (hasDefinition(dir))
|
||||
buildPlugins(dir, s, enableSbtPlugin(activateGlobalPlugin(config)))
|
||||
else
|
||||
|
|
@ -806,21 +807,21 @@ object Load {
|
|||
import Path._
|
||||
(dir * -GlobFilter(DefaultTargetName)).get.nonEmpty
|
||||
}
|
||||
def noPlugins(dir: File, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
def noPlugins(dir: File, config: LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
loadPluginDefinition(dir, config, PluginData(config.globalPluginClasspath, None, None))
|
||||
def buildPlugins(dir: File, s: State, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
def buildPlugins(dir: File, s: State, config: LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
loadPluginDefinition(dir, config, buildPluginDefinition(dir, s, config))
|
||||
|
||||
def loadPluginDefinition(dir: File, config: sbt.LoadBuildConfiguration, pluginData: PluginData): sbt.LoadedPlugins =
|
||||
def loadPluginDefinition(dir: File, config: LoadBuildConfiguration, pluginData: PluginData): sbt.LoadedPlugins =
|
||||
{
|
||||
val (definitionClasspath, pluginLoader) = pluginDefinitionLoader(config, pluginData)
|
||||
loadPlugins(dir, pluginData.copy(dependencyClasspath = definitionClasspath), pluginLoader)
|
||||
}
|
||||
def pluginDefinitionLoader(config: sbt.LoadBuildConfiguration, dependencyClasspath: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
|
||||
def pluginDefinitionLoader(config: LoadBuildConfiguration, dependencyClasspath: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
|
||||
pluginDefinitionLoader(config, dependencyClasspath, Nil)
|
||||
def pluginDefinitionLoader(config: sbt.LoadBuildConfiguration, pluginData: PluginData): (Seq[Attributed[File]], ClassLoader) =
|
||||
def pluginDefinitionLoader(config: LoadBuildConfiguration, pluginData: PluginData): (Seq[Attributed[File]], ClassLoader) =
|
||||
pluginDefinitionLoader(config, pluginData.dependencyClasspath, pluginData.definitionClasspath)
|
||||
def pluginDefinitionLoader(config: sbt.LoadBuildConfiguration, depcp: Seq[Attributed[File]], defcp: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
|
||||
def pluginDefinitionLoader(config: LoadBuildConfiguration, depcp: Seq[Attributed[File]], defcp: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
|
||||
{
|
||||
val definitionClasspath =
|
||||
if (depcp.isEmpty)
|
||||
|
|
@ -841,20 +842,20 @@ object Load {
|
|||
}
|
||||
(definitionClasspath, pluginLoader)
|
||||
}
|
||||
def buildPluginDefinition(dir: File, s: State, config: sbt.LoadBuildConfiguration): PluginData =
|
||||
def buildPluginDefinition(dir: File, s: State, config: LoadBuildConfiguration): PluginData =
|
||||
{
|
||||
val (eval, pluginDef) = apply(dir, s, config)
|
||||
val pluginState = Project.setProject(Load.initialSession(pluginDef, eval), pluginDef, s)
|
||||
config.evalPluginDef(Project.structure(pluginState), pluginState)
|
||||
}
|
||||
|
||||
@deprecated("Use ModuleUtilities.getCheckedObjects[Build].", "0.13.2")
|
||||
def loadDefinitions(loader: ClassLoader, defs: Seq[String]): Seq[Build] =
|
||||
@deprecated("Use ModuleUtilities.getCheckedObjects[BuildDef].", "0.13.2")
|
||||
def loadDefinitions(loader: ClassLoader, defs: Seq[String]): Seq[BuildDef] =
|
||||
defs map { definition => loadDefinition(loader, definition) }
|
||||
|
||||
@deprecated("Use ModuleUtilities.getCheckedObject[Build].", "0.13.2")
|
||||
def loadDefinition(loader: ClassLoader, definition: String): Build =
|
||||
ModuleUtilities.getObject(definition, loader).asInstanceOf[Build]
|
||||
@deprecated("Use ModuleUtilities.getCheckedObject[BuildDef].", "0.13.2")
|
||||
def loadDefinition(loader: ClassLoader, definition: String): BuildDef =
|
||||
ModuleUtilities.getObject(definition, loader).asInstanceOf[BuildDef]
|
||||
|
||||
def loadPlugins(dir: File, data: PluginData, loader: ClassLoader): sbt.LoadedPlugins =
|
||||
new sbt.LoadedPlugins(dir, data, loader, PluginDiscovery.discoverAll(data, loader))
|
||||
|
|
@ -883,7 +884,7 @@ object Load {
|
|||
def findPlugins(analysis: Analysis): Seq[String] = discover(analysis, "sbt.Plugin")
|
||||
|
||||
@deprecated("No longer used.", "0.13.2")
|
||||
def findDefinitions(analysis: Analysis): Seq[String] = discover(analysis, "sbt.Build")
|
||||
def findDefinitions(analysis: Analysis): Seq[String] = discover(analysis, "sbt.internal.BuildDef")
|
||||
|
||||
@deprecated("Use PluginDiscovery.sourceModuleNames", "0.13.2")
|
||||
def discover(analysis: Analysis, subclasses: String*): Seq[String] =
|
||||
|
|
@ -928,37 +929,9 @@ object Load {
|
|||
|
||||
def referenced[PR <: ProjectReference](definitions: Seq[ProjectDefinition[PR]]): Seq[PR] = definitions flatMap { _.referenced }
|
||||
|
||||
@deprecated("LoadedBuildUnit is now top-level", "0.13.0")
|
||||
type LoadedBuildUnit = sbt.LoadedBuildUnit
|
||||
|
||||
@deprecated("BuildStructure is now top-level", "0.13.0")
|
||||
type BuildStructure = sbt.BuildStructure
|
||||
|
||||
@deprecated("StructureIndex is now top-level", "0.13.0")
|
||||
type StructureIndex = sbt.StructureIndex
|
||||
|
||||
@deprecated("LoadBuildConfiguration is now top-level", "0.13.0")
|
||||
type LoadBuildConfiguration = sbt.LoadBuildConfiguration
|
||||
@deprecated("LoadBuildConfiguration is now top-level", "0.13.0")
|
||||
val LoadBuildConfiguration = sbt.LoadBuildConfiguration
|
||||
|
||||
final class EvaluatedConfigurations(val eval: Eval, val settings: Seq[Setting[_]])
|
||||
final case class InjectSettings(global: Seq[Setting[_]], project: Seq[Setting[_]], projectLoaded: ClassLoader => Seq[Setting[_]])
|
||||
|
||||
@deprecated("LoadedDefinitions is now top-level", "0.13.0")
|
||||
type LoadedDefinitions = sbt.LoadedDefinitions
|
||||
@deprecated("LoadedPlugins is now top-level", "0.13.0")
|
||||
type LoadedPlugins = sbt.LoadedPlugins
|
||||
@deprecated("BuildUnit is now top-level", "0.13.0")
|
||||
type BuildUnit = sbt.BuildUnit
|
||||
@deprecated("LoadedBuild is now top-level", "0.13.0")
|
||||
type LoadedBuild = sbt.LoadedBuild
|
||||
@deprecated("PartBuild is now top-level", "0.13.0")
|
||||
type PartBuild = sbt.PartBuild
|
||||
@deprecated("BuildUnitBase is now top-level", "0.13.0")
|
||||
type BuildUnitBase = sbt.BuildUnitBase
|
||||
@deprecated("PartBuildUnit is now top-level", "0.13.0")
|
||||
type PartBuildUnit = sbt.PartBuildUnit
|
||||
@deprecated("Use BuildUtil.apply", "0.13.0")
|
||||
def buildUtil(root: URI, units: Map[URI, sbt.LoadedBuildUnit], keyIndex: KeyIndex, data: Settings[Scope]): BuildUtil[ResolvedProject] = BuildUtil(root, units, keyIndex, data)
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import java.io._
|
|||
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import sbt.internal.{ Load, BuildDef }
|
||||
import sbt.internal.util.{ AttributeEntry, AttributeMap, ConsoleOut, GlobalLogging, MainLogging, Settings }
|
||||
|
||||
object PluginCommandTestPlugin0 extends AutoPlugin
|
||||
|
|
@ -83,7 +84,7 @@ object FakeState {
|
|||
|
||||
val pluginData = PluginData(Nil, Nil, None, None, Nil)
|
||||
val detectedModules: DetectedModules[Plugin] = new DetectedModules(Nil)
|
||||
val builds: DetectedModules[Build] = new DetectedModules[Build](Nil)
|
||||
val builds: DetectedModules[BuildDef] = new DetectedModules[BuildDef](Nil)
|
||||
|
||||
val detectedAutoPlugins: Seq[DetectedAutoPlugin] = plugins.map(p => DetectedAutoPlugin(p.label, p, hasAutoImport = false))
|
||||
val detectedPlugins = new DetectedPlugins(detectedModules, detectedAutoPlugins, builds)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
lazy val root = (project in file("."))
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
lazy val root = (project in file(".")).
|
||||
aggregate((if(file("aggregate").exists) Seq(sub: sbt.ProjectReference) else Nil): _*)
|
||||
|
||||
lazy val sub = (project in file("sub")).
|
||||
aggregate(sub2)
|
||||
|
||||
lazy val sub2 = (project in file("sub") / "sub")
|
||||
|
|
@ -3,16 +3,20 @@ import Keys._
|
|||
import Import._
|
||||
import Project.Initialize
|
||||
|
||||
trait Marker
|
||||
object Marker extends AutoPlugin
|
||||
{
|
||||
final lazy val Mark = TaskKey[Unit]("mark")
|
||||
final def mark: Initialize[Task[Unit]] = mark(baseDirectory)
|
||||
final def mark(project: Reference): Initialize[Task[Unit]] = mark(baseDirectory in project)
|
||||
final def mark(baseKey: SettingKey[File]): Initialize[Task[Unit]] = baseKey map { base =>
|
||||
val toMark = base / "ran"
|
||||
if(toMark.exists)
|
||||
error("Already ran (" + toMark + " exists)")
|
||||
else
|
||||
IO touch toMark
|
||||
}
|
||||
override def trigger = allRequirements
|
||||
override def requires = sbt.plugins.JvmPlugin
|
||||
object autoImport {
|
||||
final lazy val Mark = TaskKey[Unit]("mark")
|
||||
final def mark: Initialize[Task[Unit]] = mark(baseDirectory)
|
||||
final def mark(project: Reference): Initialize[Task[Unit]] = mark(baseDirectory in project)
|
||||
final def mark(baseKey: SettingKey[File]): Initialize[Task[Unit]] = baseKey map { base =>
|
||||
val toMark = base / "ran"
|
||||
if(toMark.exists)
|
||||
error("Already ran (" + toMark + " exists)")
|
||||
else
|
||||
IO touch toMark
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
|
||||
object SingleBuild extends Build with Marker
|
||||
{
|
||||
override def projects = if(file("multi").exists) Seq(root, sub, sub2) else Seq(root)
|
||||
lazy val root = Project("root", file("."), aggregate = if(file("aggregate").exists) Seq(sub) else Nil )
|
||||
lazy val sub = Project("sub", file("sub"), aggregate = Seq(sub2))
|
||||
lazy val sub2 = Project("sub2", file("sub") / "sub")
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ $ delete ran
|
|||
|
||||
# switch to multi-project, no aggregation yet. 'reload' will drop session settings
|
||||
$ touch multi
|
||||
$ copy-file changes/build.sbt build.sbt
|
||||
$ mkdir sub sub/sub
|
||||
> reload
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
// tests that errors are properly propagated for dependsOn, map, and flatMap
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
a <<= baseDirectory map (b => if( (b / "succeed").exists) () else sys.error("fail")),
|
||||
b <<= a.task(at => nop dependsOn(at) ),
|
||||
c <<= a map { _ => () },
|
||||
d <<= a flatMap { _ => task { () } }
|
||||
)
|
||||
lazy val a = TaskKey[Unit]("a")
|
||||
lazy val b = TaskKey[Unit]("b")
|
||||
lazy val c = TaskKey[Unit]("c")
|
||||
lazy val d = TaskKey[Unit]("d")
|
||||
|
||||
lazy val input = (project in file("input")).
|
||||
settings(
|
||||
f <<= inputTask { _ map { args => if(args(0) == "succeed") () else sys.error("fail") } },
|
||||
j := sys.error("j"),
|
||||
g <<= f dependsOn(j),
|
||||
h <<= f map { _ => IO.touch(file("h")) }
|
||||
)
|
||||
lazy val f = InputKey[Unit]("f")
|
||||
lazy val g = InputKey[Unit]("g")
|
||||
lazy val h = InputKey[Unit]("h")
|
||||
lazy val j = TaskKey[Unit]("j")
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
// tests that errors are properly propagated for dependsOn, map, and flatMap
|
||||
object B extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
a <<= baseDirectory map (b => if( (b / "succeed").exists) () else sys.error("fail")),
|
||||
b <<= a.task(at => nop dependsOn(at) ),
|
||||
c <<= a map { _ => () },
|
||||
d <<= a flatMap { _ => task { () } }
|
||||
)
|
||||
lazy val a = TaskKey[Unit]("a")
|
||||
lazy val b = TaskKey[Unit]("b")
|
||||
lazy val c = TaskKey[Unit]("c")
|
||||
lazy val d = TaskKey[Unit]("d")
|
||||
|
||||
lazy val input = Project("input", file("input")) settings(
|
||||
f <<= inputTask { _ map { args => if(args(0) == "succeed") () else sys.error("fail") } },
|
||||
j := sys.error("j"),
|
||||
g <<= f dependsOn(j),
|
||||
h <<= f map { _ => IO.touch(file("h")) }
|
||||
)
|
||||
lazy val f = InputKey[Unit]("f")
|
||||
lazy val g = InputKey[Unit]("g")
|
||||
lazy val h = InputKey[Unit]("h")
|
||||
lazy val j = TaskKey[Unit]("j")
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
lazy val root = (project in file(".")).
|
||||
aggregate(sub).
|
||||
settings(
|
||||
TaskKey[Unit]("f") := sys.error("f")
|
||||
)
|
||||
|
||||
lazy val sub = (project in file("sub")).
|
||||
settings(
|
||||
TaskKey[Unit]("f") := {}
|
||||
)
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
|
||||
object TestBuild extends Build
|
||||
{
|
||||
lazy val root1 = Project("root1", file(".")) dependsOn(root2)
|
||||
lazy val root2 = ProjectRef(uri("external"), "root2")
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
lazy val root1 = (project in file(".")).
|
||||
aggregate(root2)
|
||||
|
||||
lazy val root2 = ProjectRef(uri("external"), "root2")
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
lazy val root2 = (project in file("root2")).
|
||||
settings(
|
||||
TaskKey[Unit]("g") := {}
|
||||
)
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
|
||||
object Ext extends Build
|
||||
{
|
||||
lazy val root2 = Project("root2", file("root2")) settings(
|
||||
TaskKey[Unit]("g") := {}
|
||||
)
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
|
||||
object TestBuild extends Build
|
||||
{
|
||||
lazy val root = Project("root", file("."), aggregate = Seq(sub)) settings(
|
||||
TaskKey[Unit]("f") := sys.error("f")
|
||||
)
|
||||
lazy val sub = Project("sub", file("sub")) settings(
|
||||
TaskKey[Unit]("f") := {}
|
||||
)
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
> f
|
||||
> reload
|
||||
> f
|
||||
$ copy-file changes/Changed.scala project/TestProject.scala
|
||||
$ copy-file changes/changed.sbt build.sbt
|
||||
> reload
|
||||
-> f
|
||||
> project {external}root2
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
myRun,
|
||||
fork in demo := true,
|
||||
javaOptions in demo := "-Dsbt.check.forked=true" :: Nil,
|
||||
myIn
|
||||
)
|
||||
|
||||
lazy val demoIn = InputKey[Unit]("demo-in", "Demo run input task", demo)
|
||||
lazy val demo = TaskKey[Unit]("demo", "Demo run task")
|
||||
|
||||
def myRun = fullRunTask( demo, Compile, "A", "1", "1")
|
||||
def myIn = fullRunInputTask( demoIn, Compile, "A", "1")
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object B extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
myRun,
|
||||
fork in demo := true,
|
||||
javaOptions in demo := "-Dsbt.check.forked=true" :: Nil,
|
||||
myIn
|
||||
)
|
||||
|
||||
lazy val demoIn = InputKey[Unit]("demo-in", "Demo run input task", demo)
|
||||
lazy val demo = TaskKey[Unit]("demo", "Demo run task")
|
||||
|
||||
def myRun = fullRunTask( demo, Compile, "A", "1", "1")
|
||||
def myIn = fullRunInputTask( demoIn, Compile, "A", "1")
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
import Import._
|
||||
import complete.Parser
|
||||
import complete.DefaultParsers._
|
||||
import sbinary.DefaultProtocol._
|
||||
import Project.Initialize
|
||||
|
||||
val keep = TaskKey[Int]("keep")
|
||||
val persisted = TaskKey[Int]("persist")
|
||||
val checkKeep = InputKey[Unit]("check-keep")
|
||||
val checkPersisted = InputKey[Unit]("check-persist")
|
||||
|
||||
val updateDemo = TaskKey[Int]("demo")
|
||||
val check = InputKey[Unit]("check")
|
||||
val sample = AttributeKey[Int]("demo-key")
|
||||
|
||||
def updateDemoInit = state map { s => (s get sample getOrElse 9) + 1 }
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
updateDemo <<= updateDemoInit updateState demoState,
|
||||
check <<= checkInit,
|
||||
inMemorySetting,
|
||||
persistedSetting,
|
||||
inMemoryCheck,
|
||||
persistedCheck
|
||||
)
|
||||
|
||||
def demoState(s: State, i: Int): State = s put (sample, i + 1)
|
||||
|
||||
def checkInit: Initialize[InputTask[Unit]] = InputTask( (_: State) => token(Space ~> IntBasic) ~ token(Space ~> IntBasic).?) { key =>
|
||||
(key, updateDemo, state) map { case ((curExpected, prevExpected), value, s) =>
|
||||
val prev = s get sample
|
||||
assert(value == curExpected, "Expected current value to be " + curExpected + ", got " + value)
|
||||
assert(prev == prevExpected, "Expected previous value to be " + prevExpected + ", got " + prev)
|
||||
}
|
||||
}
|
||||
|
||||
def inMemorySetting = keep <<= getPrevious(keep) map { case None => 3; case Some(x) => x + 1} keepAs(keep)
|
||||
def persistedSetting = persisted <<= loadPrevious(persisted) map { case None => 17; case Some(x) => x + 1} storeAs(persisted)
|
||||
|
||||
def inMemoryCheck = checkKeep <<= inputCheck( (ctx, s) => Space ~> str(getFromContext(keep, ctx, s)) )
|
||||
def persistedCheck = checkPersisted <<= inputCheck( (ctx, s) => Space ~> str(loadFromContext(persisted, ctx, s)) )
|
||||
|
||||
def inputCheck[T](f: (ScopedKey[_], State) => Parser[T]): Initialize[InputTask[Unit]] =
|
||||
InputTask( resolvedScoped(ctx => (s: State) => f(ctx, s)) )( dummyTask )
|
||||
|
||||
def dummyTask = (key: Any) => maxErrors map { _ => () }
|
||||
def str(o: Option[Int]) = o match { case None => "blue"; case Some(i) => i.toString }
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
import complete.Parser
|
||||
import complete.DefaultParsers._
|
||||
import sbinary.DefaultProtocol._
|
||||
import Project.Initialize
|
||||
|
||||
object MyBuild extends Build
|
||||
{
|
||||
val keep = TaskKey[Int]("keep")
|
||||
val persisted = TaskKey[Int]("persist")
|
||||
val checkKeep = InputKey[Unit]("check-keep")
|
||||
val checkPersisted = InputKey[Unit]("check-persist")
|
||||
|
||||
val updateDemo = TaskKey[Int]("demo")
|
||||
val check = InputKey[Unit]("check")
|
||||
val sample = AttributeKey[Int]("demo-key")
|
||||
|
||||
def updateDemoInit = state map { s => (s get sample getOrElse 9) + 1 }
|
||||
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
updateDemo <<= updateDemoInit updateState demoState,
|
||||
check <<= checkInit,
|
||||
inMemorySetting,
|
||||
persistedSetting,
|
||||
inMemoryCheck,
|
||||
persistedCheck
|
||||
)
|
||||
def demoState(s: State, i: Int): State = s put (sample, i + 1)
|
||||
|
||||
def checkInit: Initialize[InputTask[Unit]] = InputTask( (_: State) => token(Space ~> IntBasic) ~ token(Space ~> IntBasic).?) { key =>
|
||||
(key, updateDemo, state) map { case ((curExpected, prevExpected), value, s) =>
|
||||
val prev = s get sample
|
||||
assert(value == curExpected, "Expected current value to be " + curExpected + ", got " + value)
|
||||
assert(prev == prevExpected, "Expected previous value to be " + prevExpected + ", got " + prev)
|
||||
}
|
||||
}
|
||||
|
||||
def inMemorySetting = keep <<= getPrevious(keep) map { case None => 3; case Some(x) => x + 1} keepAs(keep)
|
||||
def persistedSetting = persisted <<= loadPrevious(persisted) map { case None => 17; case Some(x) => x + 1} storeAs(persisted)
|
||||
|
||||
def inMemoryCheck = checkKeep <<= inputCheck( (ctx, s) => Space ~> str(getFromContext(keep, ctx, s)) )
|
||||
def persistedCheck = checkPersisted <<= inputCheck( (ctx, s) => Space ~> str(loadFromContext(persisted, ctx, s)) )
|
||||
|
||||
def inputCheck[T](f: (ScopedKey[_], State) => Parser[T]): Initialize[InputTask[Unit]] =
|
||||
InputTask( resolvedScoped(ctx => (s: State) => f(ctx, s)) )( dummyTask )
|
||||
|
||||
def dummyTask = (key: Any) => maxErrors map { _ => () }
|
||||
def str(o: Option[Int]) = o match { case None => "blue"; case Some(i) => i.toString }
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
lazy val akey = AttributeKey[Int]("TestKey")
|
||||
lazy val t = TaskKey[String]("test-task")
|
||||
lazy val check = InputKey[Unit]("check")
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
aggregate(a, b).
|
||||
settings(
|
||||
check := checkState(checkParser.parsed, state.value)
|
||||
)
|
||||
|
||||
lazy val a = project.
|
||||
settings(
|
||||
t := sys.error("Failing")
|
||||
)
|
||||
|
||||
lazy val b = project.
|
||||
settings(
|
||||
t <<= Def.task("").updateState(updater)
|
||||
)
|
||||
|
||||
def checkState(runs: Int, s: State): Unit = {
|
||||
val stored = s.get(akey).getOrElse(0)
|
||||
assert(stored == runs, "Expected " + runs + ", got " + stored)
|
||||
}
|
||||
|
||||
def updater(s: State, a: AnyRef): State = s.update(akey)(_.getOrElse(0) + 1)
|
||||
|
||||
import complete.DefaultParsers._
|
||||
|
||||
lazy val checkParser = token(Space ~> IntBasic)
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object TestBuild extends Build
|
||||
{
|
||||
lazy val akey = AttributeKey[Int]("TestKey")
|
||||
lazy val t = TaskKey[String]("test-task")
|
||||
lazy val check = InputKey[Unit]("check")
|
||||
lazy val root = Project("root", file(".")).aggregate(a, b).settings(
|
||||
check := checkState(checkParser.parsed, state.value)
|
||||
)
|
||||
|
||||
lazy val a = Project("a", file("a")).settings(t := sys.error("Failing"))
|
||||
|
||||
lazy val b = Project("b", file("b")).settings(t <<= Def.task("").updateState(updater))
|
||||
|
||||
def checkState(runs: Int, s: State): Unit = {
|
||||
val stored = s.get(akey).getOrElse(0)
|
||||
assert(stored == runs, "Expected " + runs + ", got " + stored)
|
||||
}
|
||||
|
||||
def updater(s: State, a: AnyRef): State = s.update(akey)(_.getOrElse(0) + 1)
|
||||
|
||||
import complete.DefaultParsers._
|
||||
|
||||
lazy val checkParser = token(Space ~> IntBasic)
|
||||
}
|
||||
|
|
@ -2,9 +2,6 @@ ivyPaths in ThisBuild := {
|
|||
val base = (baseDirectory in ThisBuild).value
|
||||
new IvyPaths(base, Some(base / "ivy-cache"))
|
||||
}
|
||||
|
||||
managedScalaInstance in ThisBuild := false
|
||||
|
||||
autoScalaLibrary in ThisBuild := false
|
||||
|
||||
crossPaths in ThisBuild := false
|
||||
crossPaths in ThisBuild := false
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
lazy val root = (project in file(".")).
|
||||
aggregate(a,b).
|
||||
settings(
|
||||
name := "use",
|
||||
version := "1.0",
|
||||
organization in ThisBuild := "org.example",
|
||||
version in ThisBuild := "2.0-SNAPSHOT",
|
||||
libraryDependencies += "org.example" % "b" % "2.0-SNAPSHOT",
|
||||
ivyPaths := (ivyPaths in ThisBuild).value
|
||||
)
|
||||
|
||||
lazy val a = project.
|
||||
dependsOn(b).
|
||||
settings(
|
||||
name := "a",
|
||||
ivyPaths := (ivyPaths in ThisBuild).value
|
||||
)
|
||||
|
||||
lazy val b = project.
|
||||
settings(
|
||||
name := "b",
|
||||
ivyPaths := (ivyPaths in ThisBuild).value
|
||||
)
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object B extends Build {
|
||||
|
||||
override def settings = super.settings ++ Seq(
|
||||
organization := "org.example",
|
||||
version := "2.0-SNAPSHOT"
|
||||
)
|
||||
|
||||
lazy val root = proj("root", ".") aggregate(a,b)
|
||||
lazy val a = proj("a", "a") dependsOn(b)
|
||||
lazy val b = proj("b", "b")
|
||||
private[this] def proj(id: String, f: String): Project = Project(id, file(f)).settings( ivyPaths <<= ivyPaths in ThisBuild )
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
lazy val root = (project in file(".")).
|
||||
aggregate(a,b).
|
||||
settings(
|
||||
organization in ThisBuild := "org.example",
|
||||
version in ThisBuild := "2.0-SNAPSHOT",
|
||||
ivyPaths := (ivyPaths in ThisBuild).value
|
||||
)
|
||||
|
||||
lazy val a = project.
|
||||
dependsOn(b).
|
||||
settings(
|
||||
name := "a",
|
||||
ivyPaths := (ivyPaths in ThisBuild).value
|
||||
)
|
||||
|
||||
lazy val b = project.
|
||||
settings(
|
||||
name := "b",
|
||||
ivyPaths := (ivyPaths in ThisBuild).value
|
||||
)
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
name := "use"
|
||||
|
||||
organization := "org.example"
|
||||
|
||||
version := "1.0"
|
||||
|
||||
libraryDependencies += "org.example" % "b" % "2.0-SNAPSHOT"
|
||||
|
||||
ivyPaths <<= ivyPaths in ThisBuild
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
name := "use",
|
||||
organization := "org.example",
|
||||
version := "1.0",
|
||||
libraryDependencies += "org.example" % "b" % "2.0-SNAPSHOT",
|
||||
ivyPaths := (ivyPaths in ThisBuild).value
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Publish the def/{a,b} projects to the local repository
|
||||
|
||||
$ copy-file changes/def/Build.scala project/Build.scala
|
||||
$ copy-file changes/def/build.sbt build.sbt
|
||||
$ copy-file changes/def/Def.java b/Def.java
|
||||
> reload
|
||||
> publish-local
|
||||
|
|
@ -11,7 +11,7 @@ $ copy-file changes/def/Def.java b/Def.java
|
|||
# The resolver will be marked as local in the cache
|
||||
# The dependency on def/b will be properly resolved
|
||||
|
||||
$ delete project/Build.scala
|
||||
$ delete build.sbt
|
||||
$ delete b/Def.java
|
||||
$ copy-file changes/use/build.sbt build.sbt
|
||||
$ copy-file changes/use/Use.java Use.java
|
||||
|
|
@ -23,7 +23,8 @@ $ copy-file changes/use/Use.java Use.java
|
|||
# Publish the def/{a,b} projects to the local repository again
|
||||
# This will change the resolver in the cache to be inter-project
|
||||
|
||||
$ copy-file changes/def/Build.scala project/Build.scala
|
||||
$ delete build.sbt
|
||||
$ copy-file changes/both/build.sbt build.sbt
|
||||
$ copy-file changes/def/Def.java b/Def.java
|
||||
> reload
|
||||
> publish-local
|
||||
|
|
@ -33,7 +34,7 @@ $ copy-file changes/def/Def.java b/Def.java
|
|||
# Resolve from local again. This will succeed, but the jars
|
||||
# won't be on the classpath if the resolver isn't ignoredy.
|
||||
|
||||
$ delete project/Build.scala
|
||||
$ delete build.sbt
|
||||
$ delete b/Def.java
|
||||
$ copy-file changes/use/build.sbt build.sbt
|
||||
$ copy-file changes/use/Use.java Use.java
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
lazy val root = (project in file(".")).
|
||||
aggregate(logic, ui)
|
||||
|
||||
lazy val logic = (project in file("logic")).
|
||||
delegateTo(LocalProject("root"))
|
||||
|
||||
lazy val ui = (project in file("ui")).
|
||||
delegateTo(LocalProject("root"))
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object B extends Build
|
||||
{
|
||||
lazy val root: Project = Project("root", file(".")) aggregate(logic, ui)
|
||||
lazy val logic: Project = Project("logic", file("logic"), delegates = root :: Nil)
|
||||
lazy val ui: Project = Project("ui", file("ui"), delegates = root :: Nil) dependsOn(logic)
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
libraryDependencies <+= baseDirectory(transitive("javax.mail" % "mail" % "1.4.1")),
|
||||
TaskKey[Unit]("check-transitive") <<= check(true),
|
||||
TaskKey[Unit]("check-intransitive") <<= check(false)
|
||||
)
|
||||
|
||||
def transitive(dep: ModuleID)(base: File) =
|
||||
if((base / "transitive").exists) dep else dep.intransitive()
|
||||
|
||||
def check(transitive: Boolean) =
|
||||
(dependencyClasspath in Compile) map { downloaded =>
|
||||
val jars = downloaded.size
|
||||
if(transitive) {
|
||||
if (jars <= 2)
|
||||
sys.error(s"Transitive dependencies not downloaded, found:\n * ${downloaded.mkString("\n * ")}")
|
||||
else ()
|
||||
} else {
|
||||
if (jars > 2)
|
||||
sys.error(s"Transitive dependencies not downloaded, found:\n * ${downloaded.mkString("\n * ")}")
|
||||
else ()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
|
||||
object TestProject extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
libraryDependencies <+= baseDirectory(transitive("javax.mail" % "mail" % "1.4.1")),
|
||||
TaskKey[Unit]("check-transitive") <<= check(true),
|
||||
TaskKey[Unit]("check-intransitive") <<= check(false)
|
||||
)
|
||||
|
||||
def transitive(dep: ModuleID)(base: File) =
|
||||
if((base / "transitive").exists) dep else dep.intransitive()
|
||||
|
||||
private def check(transitive: Boolean) =
|
||||
(dependencyClasspath in Compile) map { downloaded =>
|
||||
val jars = downloaded.size
|
||||
if(transitive) {
|
||||
if (jars <= 2)
|
||||
sys.error(s"Transitive dependencies not downloaded, found:\n * ${downloaded.mkString("\n * ")}")
|
||||
else ()
|
||||
} else {
|
||||
if (jars > 2)
|
||||
sys.error(s"Transitive dependencies not downloaded, found:\n * ${downloaded.mkString("\n * ")}")
|
||||
else ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
libraryDependencies <++= baseDirectory (libraryDeps),
|
||||
TaskKey[Unit]("check-forced") <<= check("1.2.14"),
|
||||
TaskKey[Unit]("check-depend") <<= check("1.2.13")
|
||||
)
|
||||
|
||||
def libraryDeps(base: File) = {
|
||||
val slf4j = Seq("org.slf4j" % "slf4j-log4j12" % "1.1.0") // Uses log4j 1.2.13
|
||||
if ((base / "force").exists) slf4j :+ ("log4j" % "log4j" % "1.2.14" force()) else slf4j
|
||||
}
|
||||
|
||||
def check(ver: String) =
|
||||
(dependencyClasspath in Compile) map { jars =>
|
||||
val log4j = jars map (_.data) collect {
|
||||
case f if f.getName contains "log4j-" => f.getName
|
||||
}
|
||||
if (log4j.size != 1 || !log4j.head.contains(ver))
|
||||
error("Did not download the correct jar.")
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
|
||||
object TestProject extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
libraryDependencies <++= baseDirectory (libraryDeps),
|
||||
TaskKey[Unit]("check-forced") <<= check("1.2.14"),
|
||||
TaskKey[Unit]("check-depend") <<= check("1.2.13")
|
||||
)
|
||||
|
||||
def libraryDeps(base: File) = {
|
||||
val slf4j = Seq("org.slf4j" % "slf4j-log4j12" % "1.1.0") // Uses log4j 1.2.13
|
||||
if ((base / "force").exists) slf4j :+ ("log4j" % "log4j" % "1.2.14" force()) else slf4j
|
||||
}
|
||||
|
||||
def check(ver: String) =
|
||||
(dependencyClasspath in Compile) map { jars =>
|
||||
val log4j = jars map (_.data) collect {
|
||||
case f if f.getName contains "log4j-" => f.getName
|
||||
}
|
||||
if (log4j.size != 1 || !log4j.head.contains(ver))
|
||||
error("Did not download the correct jar.")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
import scala.xml._
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
ivyXML <<= (customInfo, organization, moduleName, version) apply inlineXML,
|
||||
scalaVersion := "2.9.1",
|
||||
projectID ~= (_ cross false),
|
||||
customInfo <<= baseDirectory{_ / "info" exists },
|
||||
TaskKey[Unit]("check-download") <<= checkDownload,
|
||||
delivered <<= deliverLocal map XML.loadFile,
|
||||
TaskKey[Unit]("check-info") <<= checkInfo
|
||||
)
|
||||
|
||||
lazy val delivered = TaskKey[NodeSeq]("delivered")
|
||||
lazy val customInfo = SettingKey[Boolean]("custom-info")
|
||||
|
||||
def inlineXML(addInfo: Boolean, organization: String, moduleID: String, version: String): NodeSeq =
|
||||
if(addInfo)
|
||||
(<info organisation={organization} module={moduleID} revision={version}>
|
||||
<license name="Two-clause BSD-style" url="http://github.com/szeiger/scala-query/blob/master/LICENSE.txt" />
|
||||
<description homepage="http://github.com/szeiger/scala-query/">
|
||||
ScalaQuery is a type-safe database query API for Scala.
|
||||
</description>
|
||||
</info>
|
||||
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>)
|
||||
else
|
||||
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>
|
||||
|
||||
def checkDownload = (dependencyClasspath in Compile) map { cp => if(cp.isEmpty) sys.error("Dependency not downloaded"); () }
|
||||
def checkInfo = (customInfo, delivered) map { (addInfo, d) =>
|
||||
if((d \ "info").isEmpty)
|
||||
sys.error("No info tag generated")
|
||||
else if(addInfo) {
|
||||
if( !deliveredWithCustom(d) ) sys.error("Expected 'license' and 'description' tags in info tag, got: \n" + (d \ "info")) else ()
|
||||
} else
|
||||
if( deliveredWithCustom(d) ) sys.error("Expected empty 'info' tag, got: \n" + (d \ "info")) else ()
|
||||
}
|
||||
def deliveredWithCustom(d: NodeSeq) = (d \ "info" \ "license").nonEmpty && (d \ "info" \ "description").nonEmpty
|
||||
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
import scala.xml._
|
||||
|
||||
object InfoTest extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
ivyXML <<= (customInfo, organization, moduleName, version) apply inlineXML,
|
||||
scalaVersion := "2.9.1",
|
||||
projectID ~= (_ cross false),
|
||||
customInfo <<= baseDirectory{_ / "info" exists },
|
||||
TaskKey[Unit]("check-download") <<= checkDownload,
|
||||
delivered <<= deliverLocal map XML.loadFile,
|
||||
TaskKey[Unit]("check-info") <<= checkInfo
|
||||
)
|
||||
lazy val delivered = TaskKey[NodeSeq]("delivered")
|
||||
lazy val customInfo = SettingKey[Boolean]("custom-info")
|
||||
|
||||
def inlineXML(addInfo: Boolean, organization: String, moduleID: String, version: String): NodeSeq =
|
||||
if(addInfo)
|
||||
(<info organisation={organization} module={moduleID} revision={version}>
|
||||
<license name="Two-clause BSD-style" url="http://github.com/szeiger/scala-query/blob/master/LICENSE.txt" />
|
||||
<description homepage="http://github.com/szeiger/scala-query/">
|
||||
ScalaQuery is a type-safe database query API for Scala.
|
||||
</description>
|
||||
</info>
|
||||
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>)
|
||||
else
|
||||
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>
|
||||
|
||||
def checkDownload = (dependencyClasspath in Compile) map { cp => if(cp.isEmpty) sys.error("Dependency not downloaded"); () }
|
||||
def checkInfo = (customInfo, delivered) map { (addInfo, d) =>
|
||||
if((d \ "info").isEmpty)
|
||||
sys.error("No info tag generated")
|
||||
else if(addInfo) {
|
||||
if( !deliveredWithCustom(d) ) sys.error("Expected 'license' and 'description' tags in info tag, got: \n" + (d \ "info")) else ()
|
||||
} else
|
||||
if( deliveredWithCustom(d) ) sys.error("Expected empty 'info' tag, got: \n" + (d \ "info")) else ()
|
||||
}
|
||||
def deliveredWithCustom(d: NodeSeq) = (d \ "info" \ "license").nonEmpty && (d \ "info" \ "description").nonEmpty
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
lazy val root = (project in file("."))
|
||||
lazy val a = project.dependsOn(b)
|
||||
lazy val b = project
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object P extends Build
|
||||
{
|
||||
lazy val root = Project("root", file("."))
|
||||
lazy val a = Project("a", file("a")) dependsOn(b)
|
||||
lazy val b = Project("b", file("b"))
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
lazy val commonSettings = Seq(
|
||||
autoScalaLibrary := false,
|
||||
ivyScala := None,
|
||||
unmanagedJars in Compile <++= scalaInstance map (_.allJars.toSeq),
|
||||
publishArtifact in packageSrc := false,
|
||||
publishArtifact in packageDoc := false,
|
||||
publishMavenStyle := false
|
||||
)
|
||||
|
||||
lazy val dep = project.
|
||||
settings(
|
||||
commonSettings,
|
||||
organization := "org.example",
|
||||
version := "1.0",
|
||||
publishTo <<= baseDirectory in ThisBuild apply { base =>
|
||||
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
|
||||
}
|
||||
)
|
||||
|
||||
lazy val use = project.
|
||||
settings(
|
||||
commonSettings,
|
||||
libraryDependencies += "org.example" %% "dep" % "1.0",
|
||||
externalIvySettings(),
|
||||
publishTo <<= baseDirectory { base =>
|
||||
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
|
||||
},
|
||||
TaskKey[Unit]("check") <<= baseDirectory map {base =>
|
||||
val inCache = ( (base / "target" / "use-cache") ** "*.jar").get
|
||||
assert(inCache.isEmpty, "Cache contained jars: " + inCache)
|
||||
}
|
||||
)
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
|
||||
object B extends Build
|
||||
{
|
||||
lazy val dep = Project("dep", file("dep")) settings( baseSettings : _*) settings(
|
||||
organization := "org.example",
|
||||
version := "1.0",
|
||||
publishTo <<= baseDirectory in ThisBuild apply { base =>
|
||||
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
|
||||
}
|
||||
)
|
||||
lazy val use = Project("use", file("use")) settings(baseSettings : _*) settings(
|
||||
libraryDependencies += "org.example" %% "dep" % "1.0",
|
||||
externalIvySettings(),
|
||||
publishTo <<= baseDirectory { base =>
|
||||
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
|
||||
},
|
||||
TaskKey[Unit]("check") <<= baseDirectory map {base =>
|
||||
val inCache = ( (base / "target" / "use-cache") ** "*.jar").get
|
||||
assert(inCache.isEmpty, "Cache contained jars: " + inCache)
|
||||
}
|
||||
)
|
||||
lazy val baseSettings = Seq(
|
||||
autoScalaLibrary := false,
|
||||
ivyScala := None,
|
||||
unmanagedJars in Compile <++= scalaInstance map (_.allJars.toSeq),
|
||||
publishArtifact in packageSrc := false,
|
||||
publishArtifact in packageDoc := false,
|
||||
publishMavenStyle := false
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
lazy val commonSettings = Seq(
|
||||
autoScalaLibrary := false,
|
||||
unmanagedJars in Compile <++= scalaInstance map (_.allJars.toSeq)
|
||||
)
|
||||
|
||||
lazy val dep = project.
|
||||
settings(
|
||||
commonSettings,
|
||||
organization := "org.example",
|
||||
version := "1.0"
|
||||
)
|
||||
|
||||
lazy val use = project.
|
||||
dependsOn(dep).
|
||||
settings(
|
||||
commonSettings,
|
||||
libraryDependencies += "junit" % "junit" % "4.5",
|
||||
externalIvySettings()
|
||||
)
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object B extends Build
|
||||
{
|
||||
lazy val dep = Project("dep", file("dep")) settings( baseSettings : _*) settings(
|
||||
organization := "org.example",
|
||||
version := "1.0"
|
||||
)
|
||||
lazy val use = Project("use", file("use")) dependsOn(dep) settings(baseSettings : _*) settings(
|
||||
libraryDependencies += "junit" % "junit" % "4.5",
|
||||
externalIvySettings()
|
||||
)
|
||||
lazy val baseSettings = Seq(
|
||||
autoScalaLibrary := false,
|
||||
unmanagedJars in Compile <++= scalaInstance map (_.allJars.toSeq)
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
lazy val a = (project in file(".")).
|
||||
settings(externalIvySettings()) dependsOn(b)
|
||||
|
||||
lazy val b = (project in file("b")).
|
||||
settings(externalIvySettings( (baseDirectory in ThisBuild) / "ivysettings.xml" ))
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object Build extends Build
|
||||
{
|
||||
lazy val a = Project("a", file(".")) settings(externalIvySettings()) dependsOn(b)
|
||||
lazy val b = Project("b", file("b")) settings(externalIvySettings( (baseDirectory in ThisBuild) / "ivysettings.xml" ))
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
lazy val p1 = (project in file("p1")).
|
||||
settings(
|
||||
checkTask(expectedMongo),
|
||||
libraryDependencies += "org.mongodb" %% "casbah" % "2.4.1" pomOnly(),
|
||||
inThisBuild(List(
|
||||
organization := "org.example",
|
||||
version := "1.0",
|
||||
scalaVersion := "2.9.2",
|
||||
autoScalaLibrary := false
|
||||
))
|
||||
)
|
||||
|
||||
lazy val p2 = (project in file("p2")).
|
||||
dependsOn(p1).
|
||||
settings(
|
||||
checkTask(expectedInter)
|
||||
)
|
||||
|
||||
lazy val expectedMongo =
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>casbah_2.9.2</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
lazy val expectedInter =
|
||||
<dependency>
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>p1_2.9.2</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
def checkTask(expectedDep: xml.Elem) = TaskKey[Unit]("check-pom") <<= makePom map { file =>
|
||||
val pom = xml.XML.loadFile(file)
|
||||
val actual = pom \\ "dependencies"
|
||||
val expected = <d>
|
||||
{expectedDep}
|
||||
</d>
|
||||
def dropTopElem(s:String): String = s.split("""\n""").drop(1).dropRight(1).mkString("\n")
|
||||
val pp = new xml.PrettyPrinter(Int.MaxValue, 0)
|
||||
val expectedString = dropTopElem(pp.format(expected))
|
||||
val actualString = dropTopElem(pp.formatNodes(actual))
|
||||
assert(expectedString == actualString, "Expected dependencies section:\n" + expectedString + "\n\nActual:\n" + actualString)
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object build extends Build {
|
||||
override def settings = super.settings ++ Seq(
|
||||
organization := "org.example",
|
||||
version := "1.0",
|
||||
scalaVersion := "2.9.2",
|
||||
autoScalaLibrary := false
|
||||
)
|
||||
|
||||
lazy val p1 = Project("p1",file("p1")) settings(
|
||||
checkTask(expectedMongo),
|
||||
libraryDependencies += "org.mongodb" %% "casbah" % "2.4.1" pomOnly()
|
||||
)
|
||||
lazy val p2 = Project("p2", file("p2")) dependsOn(p1) settings(
|
||||
checkTask(expectedInter)
|
||||
)
|
||||
|
||||
lazy val expectedMongo =
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>casbah_2.9.2</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
lazy val expectedInter =
|
||||
<dependency>
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>p1_2.9.2</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
def checkTask(expectedDep: xml.Elem) = TaskKey[Unit]("check-pom") <<= makePom map { file =>
|
||||
val pom = xml.XML.loadFile(file)
|
||||
val actual = pom \\ "dependencies"
|
||||
val expected = <d>
|
||||
{expectedDep}
|
||||
</d>
|
||||
def dropTopElem(s:String): String = s.split("""\n""").drop(1).dropRight(1).mkString("\n")
|
||||
val pp = new xml.PrettyPrinter(Int.MaxValue, 0)
|
||||
val expectedString = dropTopElem(pp.format(expected))
|
||||
val actualString = dropTopElem(pp.formatNodes(actual))
|
||||
assert(expectedString == actualString, "Expected dependencies section:\n" + expectedString + "\n\nActual:\n" + actualString)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
import scala.xml._
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
readPom <<= makePom map XML.loadFile,
|
||||
TaskKey[Unit]("check-pom") <<= checkPom,
|
||||
TaskKey[Unit]("check-extra") <<= checkExtra,
|
||||
TaskKey[Unit]("check-version-plus-mapping") <<= checkVersionPlusMapping,
|
||||
resolvers += Resolver.sonatypeRepo("snapshots"),
|
||||
makePomConfiguration ~= { _.copy(extra = <extra-tag/>) },
|
||||
libraryDependencies += "com.google.code.findbugs" % "jsr305" % "1.3.+"
|
||||
)
|
||||
|
||||
val readPom = TaskKey[Elem]("read-pom")
|
||||
|
||||
val fakeName = "fake"
|
||||
val fakeURL = "http://example.org"
|
||||
val fakeRepo = fakeName at fakeURL
|
||||
def extraTagName = "extra-tag"
|
||||
|
||||
def checkProject(pom: Elem) = if(pom.label != "project") sys.error("Top level element was not 'project': " + pom.label)
|
||||
|
||||
def withRepositories[T](pomXML: Elem)(f: NodeSeq => T) =
|
||||
{
|
||||
val repositoriesElement = pomXML \ "repositories"
|
||||
if(repositoriesElement.size == 1) f(repositoriesElement) else sys.error("'repositories' element not found in generated pom")
|
||||
}
|
||||
|
||||
lazy val checkExtra = readPom map { pomXML =>
|
||||
checkProject(pomXML)
|
||||
val extra = pomXML \ extraTagName
|
||||
if(extra.isEmpty) sys.error("'" + extraTagName + "' not found in generated pom.xml.") else ()
|
||||
}
|
||||
|
||||
lazy val checkVersionPlusMapping = (readPom) map { (pomXml) =>
|
||||
var found = false
|
||||
for {
|
||||
dep <- pomXml \ "dependencies" \ "dependency"
|
||||
if (dep \ "artifactId").text == "jsr305"
|
||||
// TODO - Ignore space here.
|
||||
if (dep \ "version").text != "[1.3,1.4)"
|
||||
} sys.error(s"Found dependency with invalid maven version: $dep")
|
||||
()
|
||||
}
|
||||
|
||||
lazy val checkPom = (readPom, fullResolvers) map { (pomXML, ivyRepositories) =>
|
||||
checkProject(pomXML)
|
||||
withRepositories(pomXML) { repositoriesElement =>
|
||||
val repositories = repositoriesElement \ "repository"
|
||||
val writtenRepositories = repositories.map(read).distinct
|
||||
val mavenStyleRepositories = ivyRepositories.collect {
|
||||
case x: MavenRepository if (x.name != "public") && (x.name != "jcenter") => normalize(x)
|
||||
} distinct;
|
||||
|
||||
lazy val explain = (("Written:" +: writtenRepositories) ++ ("Declared:" +: mavenStyleRepositories)).mkString("\n\t")
|
||||
|
||||
if( writtenRepositories != mavenStyleRepositories )
|
||||
sys.error("Written repositories did not match declared repositories.\n\t" + explain)
|
||||
else
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
def read(repository: xml.Node): MavenRepository =
|
||||
(repository \ "name").text at normalize((repository \ "url").text)
|
||||
|
||||
def normalize(url: String): String =
|
||||
{
|
||||
val base = uri( url ).normalize.toString
|
||||
if(base.endsWith("/")) base else (base + "/")
|
||||
}
|
||||
def normalize(repo: MavenRepository): MavenRepository = new MavenRepository(repo.name, normalize(repo.root))
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
import sbt.{Node =>_,_}
|
||||
import Import._
|
||||
import Keys._
|
||||
import scala.xml._
|
||||
|
||||
object MakePomTest extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
readPom <<= makePom map XML.loadFile,
|
||||
TaskKey[Unit]("check-pom") <<= checkPom,
|
||||
TaskKey[Unit]("check-extra") <<= checkExtra,
|
||||
TaskKey[Unit]("check-version-plus-mapping") <<= checkVersionPlusMapping,
|
||||
resolvers += Resolver.sonatypeRepo("snapshots"),
|
||||
makePomConfiguration ~= { _.copy(extra = <extra-tag/>) },
|
||||
libraryDependencies += "com.google.code.findbugs" % "jsr305" % "1.3.+"
|
||||
)
|
||||
|
||||
val readPom = TaskKey[Elem]("read-pom")
|
||||
|
||||
val fakeName = "fake"
|
||||
val fakeURL = "http://example.org"
|
||||
val fakeRepo = fakeName at fakeURL
|
||||
def extraTagName = "extra-tag"
|
||||
|
||||
def checkProject(pom: Elem) = if(pom.label != "project") sys.error("Top level element was not 'project': " + pom.label)
|
||||
|
||||
def withRepositories[T](pomXML: Elem)(f: NodeSeq => T) =
|
||||
{
|
||||
val repositoriesElement = pomXML \ "repositories"
|
||||
if(repositoriesElement.size == 1) f(repositoriesElement) else sys.error("'repositories' element not found in generated pom")
|
||||
}
|
||||
|
||||
lazy val checkExtra = readPom map { pomXML =>
|
||||
checkProject(pomXML)
|
||||
val extra = pomXML \ extraTagName
|
||||
if(extra.isEmpty) sys.error("'" + extraTagName + "' not found in generated pom.xml.") else ()
|
||||
}
|
||||
|
||||
lazy val checkVersionPlusMapping = (readPom) map { (pomXml) =>
|
||||
var found = false
|
||||
for {
|
||||
dep <- pomXml \ "dependencies" \ "dependency"
|
||||
if (dep \ "artifactId").text == "jsr305"
|
||||
// TODO - Ignore space here.
|
||||
if (dep \ "version").text != "[1.3,1.4)"
|
||||
} sys.error(s"Found dependency with invalid maven version: $dep")
|
||||
()
|
||||
}
|
||||
|
||||
lazy val checkPom = (readPom, fullResolvers) map { (pomXML, ivyRepositories) =>
|
||||
checkProject(pomXML)
|
||||
withRepositories(pomXML) { repositoriesElement =>
|
||||
val repositories = repositoriesElement \ "repository"
|
||||
val writtenRepositories = repositories.map(read).distinct
|
||||
val mavenStyleRepositories = ivyRepositories.collect {
|
||||
case x: MavenRepository if (x.name != "public") && (x.name != "jcenter") => normalize(x)
|
||||
} distinct;
|
||||
|
||||
lazy val explain = (("Written:" +: writtenRepositories) ++ ("Declared:" +: mavenStyleRepositories)).mkString("\n\t")
|
||||
|
||||
if( writtenRepositories != mavenStyleRepositories )
|
||||
sys.error("Written repositories did not match declared repositories.\n\t" + explain)
|
||||
else
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
def read(repository: Node): MavenRepository =
|
||||
(repository \ "name").text at normalize((repository \ "url").text)
|
||||
|
||||
def normalize(url: String): String =
|
||||
{
|
||||
val base = uri( url ).normalize.toString
|
||||
if(base.endsWith("/")) base else (base + "/")
|
||||
}
|
||||
def normalize(repo: MavenRepository): MavenRepository = new MavenRepository(repo.name, normalize(repo.root))
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
lazy val parent = (project in file(".")).
|
||||
aggregate(core, reporters).
|
||||
settings(
|
||||
name := "Flowmodel"
|
||||
)
|
||||
|
||||
lazy val core = (project in file("core")).
|
||||
settings(
|
||||
name := "Flowmodel-core"
|
||||
)
|
||||
|
||||
lazy val reporters = (project in file("reporters")).
|
||||
aggregate(jfreechart).
|
||||
dependsOn(jfreechart).
|
||||
settings(
|
||||
name := "Extra-reporters"
|
||||
)
|
||||
|
||||
lazy val jfreechart = (project in file("jfreechart")).
|
||||
dependsOn(core).
|
||||
settings(
|
||||
name := "JFreeChart-reporters"
|
||||
)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
|
||||
object ParentTest extends Build
|
||||
{
|
||||
lazy val parent: Project = Project("Flowmodel", file(".")) aggregate(core, reporters)
|
||||
lazy val core: Project = Project("Flowmodel-core", file("core"), delegates = parent :: Nil)
|
||||
lazy val reporters: Project = Project("Extra-reporters", file("reporters"), delegates = parent :: Nil) aggregate(jfreechart) dependsOn(jfreechart)
|
||||
lazy val jfreechart: Project = Project("JFreeChart-reporters", file("jfreechart")/*, delegates = reporters :: Nil*/) dependsOn(core)
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import complete.DefaultParsers._
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
resolvers ++= Seq(local, Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")),
|
||||
InputKey[Unit]("check-pom") <<= InputTask(_ => spaceDelimited("<args>")) { result => (makePom, result, streams) map checkPomRepositories },
|
||||
makePomConfiguration <<= (makePomConfiguration, baseDirectory) { (conf, base) =>
|
||||
conf.copy(filterRepositories = pomIncludeRepository(base, conf.filterRepositories) )
|
||||
},
|
||||
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home")))
|
||||
)
|
||||
|
||||
val local = "local-maven-repo" at "file://" + (Path.userHome / ".m2" /"repository").absolutePath
|
||||
|
||||
def pomIncludeRepository(base: File, prev: MavenRepository => Boolean) = (r: MavenRepository) =>
|
||||
if(base / "repo.none" exists) false else if(base / "repo.all" exists) true else prev(r)
|
||||
|
||||
def addSlash(s: String): String =
|
||||
s match {
|
||||
case s if s endsWith "/" => s
|
||||
case _ => s + "/"
|
||||
}
|
||||
|
||||
def checkPomRepositories(file: File, args: Seq[String], s: TaskStreams)
|
||||
{
|
||||
val repositories = scala.xml.XML.loadFile(file) \\ "repository"
|
||||
val extracted = repositories.map { repo => MavenRepository(repo \ "name" text, addSlash(repo \ "url" text)) }
|
||||
val expected = args.map(GlobFilter.apply)
|
||||
s.log.info("Extracted: " + extracted.mkString("\n\t", "\n\t", "\n"))
|
||||
s.log.info("Expected: " + args.mkString("\n\t", "\n\t", "\n"))
|
||||
extracted.find { e => !expected.exists(_.accept(e.root)) } map { "Repository should not be exported: " + _ } orElse
|
||||
(expected.find { e => !extracted.exists(r => e.accept(r.root)) } map { "Repository should be exported: " + _ } ) foreach error
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
import complete.DefaultParsers._
|
||||
|
||||
object PomRepoTest extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
resolvers ++= Seq(local, Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")),
|
||||
InputKey[Unit]("check-pom") <<= InputTask(_ => spaceDelimited("<args>")) { result => (makePom, result, streams) map checkPomRepositories },
|
||||
makePomConfiguration <<= (makePomConfiguration, baseDirectory) { (conf, base) =>
|
||||
conf.copy(filterRepositories = pomIncludeRepository(base, conf.filterRepositories) )
|
||||
},
|
||||
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home")))
|
||||
)
|
||||
|
||||
val local = "local-maven-repo" at "file://" + (Path.userHome / ".m2" /"repository").absolutePath
|
||||
|
||||
def pomIncludeRepository(base: File, prev: MavenRepository => Boolean) = (r: MavenRepository) =>
|
||||
if(base / "repo.none" exists) false else if(base / "repo.all" exists) true else prev(r)
|
||||
|
||||
def addSlash(s: String): String =
|
||||
s match {
|
||||
case s if s endsWith "/" => s
|
||||
case _ => s + "/"
|
||||
}
|
||||
|
||||
def checkPomRepositories(file: File, args: Seq[String], s: TaskStreams)
|
||||
{
|
||||
val repositories = scala.xml.XML.loadFile(file) \\ "repository"
|
||||
val extracted = repositories.map { repo => MavenRepository(repo \ "name" text, addSlash(repo \ "url" text)) }
|
||||
val expected = args.map(GlobFilter.apply)
|
||||
s.log.info("Extracted: " + extracted.mkString("\n\t", "\n\t", "\n"))
|
||||
s.log.info("Expected: " + args.mkString("\n\t", "\n\t", "\n"))
|
||||
extracted.find { e => !expected.exists(_.accept(e.root)) } map { "Repository should not be exported: " + _ } orElse
|
||||
(expected.find { e => !extracted.exists(r => e.accept(r.root)) } map { "Repository should be exported: " + _ } ) foreach error
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import complete._
|
||||
import complete.DefaultParsers._
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
externalPom(),
|
||||
scalaVersion := "2.9.0-1",
|
||||
check <<= checkTask,
|
||||
managedClasspath in Provided <<= (classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) }
|
||||
)
|
||||
|
||||
def checkTask = InputTask(_ => parser ) { result =>
|
||||
(result, managedClasspath in Provided, fullClasspath in Compile, fullClasspath in Test, fullClasspath in Runtime) map { case ((conf, names), p, c, t, r) =>
|
||||
println("Checking: " + conf.name)
|
||||
checkClasspath(conf match {
|
||||
case Provided => p
|
||||
case Compile => c
|
||||
case Test => t
|
||||
case Runtime => r
|
||||
}, names.toSet)
|
||||
}
|
||||
}
|
||||
|
||||
lazy val check = InputKey[Unit]("check")
|
||||
def parser: Parser[(Configuration,Seq[String])] = (Space ~> token(cp(Compile) | cp(Runtime) | cp(Provided) | cp(Test))) ~ spaceDelimited("<module-names>")
|
||||
def cp(c: Configuration): Parser[Configuration] = c.name ^^^ c
|
||||
def checkClasspath(cp: Seq[Attributed[File]], names: Set[String]) =
|
||||
{
|
||||
val fs = cp.files filter { _.getName endsWith ".jar" }
|
||||
val intersect = fs filter { f => names exists { f.getName startsWith _ } }
|
||||
assert(intersect == fs, "Expected:" + seqStr(names.toSeq) + "Got: " + seqStr(fs))
|
||||
()
|
||||
}
|
||||
def seqStr(s: Seq[_]) = s.mkString("\n\t", "\n\t", "\n")
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
import complete._
|
||||
import complete.DefaultParsers._
|
||||
|
||||
object MyBuild extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings( externalPom() :_*) settings(
|
||||
scalaVersion := "2.9.0-1",
|
||||
check <<= checkTask,
|
||||
managedClasspath in Provided <<= (classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) }
|
||||
)
|
||||
|
||||
def checkTask = InputTask(_ => parser ) { result =>
|
||||
(result, managedClasspath in Provided, fullClasspath in Compile, fullClasspath in Test, fullClasspath in Runtime) map { case ((conf, names), p, c, t, r) =>
|
||||
println("Checking: " + conf.name)
|
||||
checkClasspath(conf match {
|
||||
case Provided => p
|
||||
case Compile => c
|
||||
case Test => t
|
||||
case Runtime => r
|
||||
}, names.toSet)
|
||||
}
|
||||
}
|
||||
|
||||
lazy val check = InputKey[Unit]("check")
|
||||
def parser: Parser[(Configuration,Seq[String])] = (Space ~> token(cp(Compile) | cp(Runtime) | cp(Provided) | cp(Test))) ~ spaceDelimited("<module-names>")
|
||||
def cp(c: Configuration): Parser[Configuration] = c.name ^^^ c
|
||||
def checkClasspath(cp: Seq[Attributed[File]], names: Set[String]) =
|
||||
{
|
||||
val fs = cp.files filter { _.getName endsWith ".jar" }
|
||||
val intersect = fs filter { f => names exists { f.getName startsWith _ } }
|
||||
assert(intersect == fs, "Expected:" + seqStr(names.toSeq) + "Got: " + seqStr(fs))
|
||||
()
|
||||
}
|
||||
def seqStr(s: Seq[_]) = s.mkString("\n\t", "\n\t", "\n")
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
import sbt.Def.Initialize
|
||||
|
||||
lazy val checkPom = taskKey[Unit]("")
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
checkPom in ThisBuild := checkPomTask.value
|
||||
)
|
||||
|
||||
lazy val subJar = (project in file("subJar"))
|
||||
|
||||
lazy val subWar = (project in file("subWar")).
|
||||
settings(
|
||||
warArtifact
|
||||
)
|
||||
|
||||
lazy val subParent = (project in file("subParent")).
|
||||
settings(
|
||||
publishArtifact in Compile := false
|
||||
)
|
||||
|
||||
def art(p: ProjectReference) = makePom in p
|
||||
def checkPomTask: Initialize[Task[Unit]] =
|
||||
(art(subJar), art(subWar), art(subParent)) map { (jar, war, pom) =>
|
||||
checkPackaging(jar, "jar")
|
||||
checkPackaging(war, "war")
|
||||
checkPackaging(pom, "pom")
|
||||
}
|
||||
|
||||
def checkPackaging(pom: File, expected: String) =
|
||||
{
|
||||
val packaging = (xml.XML.loadFile(pom) \\ "packaging").text
|
||||
if(packaging != expected) sys.error("Incorrect packaging for '" + pom + "'. Expected '" + expected + "', but got '" + packaging + "'")
|
||||
}
|
||||
def warArtifact = artifact in (Compile, packageBin) ~= { _.copy(`type` = "war", extension = "war") }
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object PomTest extends Build
|
||||
{
|
||||
override def settings = super.settings :+ (TaskKey[Unit]("check-pom") <<= checkPom)
|
||||
|
||||
lazy val subJar = Project("sub-jar", file("subJar"))
|
||||
lazy val subWar = Project("sub-war", file("subWar")) settings( warArtifact)
|
||||
lazy val subParent = Project("sub-parent", file("subParent")) settings( publishArtifact in Compile := false )
|
||||
|
||||
def art(p: ProjectReference) = makePom in p
|
||||
def checkPom = (art(subJar), art(subWar), art(subParent)) map { (jar, war, pom) =>
|
||||
checkPackaging(jar, "jar")
|
||||
checkPackaging(war, "war")
|
||||
checkPackaging(pom, "pom")
|
||||
}
|
||||
def checkPackaging(pom: File, expected: String) =
|
||||
{
|
||||
val packaging = (xml.XML.loadFile(pom) \\ "packaging").text
|
||||
if(packaging != expected) sys.error("Incorrect packaging for '" + pom + "'. Expected '" + expected + "', but got '" + packaging + "'")
|
||||
}
|
||||
def warArtifact = artifact in (Compile, packageBin) ~= { _.copy(`type` = "war", extension = "war") }
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
> check-pom
|
||||
> checkPom
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
lazy val custom = config("custom")
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
configs(custom).
|
||||
settings(
|
||||
TaskKey[Unit]("check-pom") <<= checkPom,
|
||||
libraryDependencies ++= Seq(
|
||||
"a" % "a" % "1.0",
|
||||
"b" % "b" % "1.0" % "runtime,optional",
|
||||
"c" % "c" % "1.0" % "optional",
|
||||
"d" % "d" % "1.0" % "test",
|
||||
"e" % "e" % "1.0" % "custom",
|
||||
"f" % "f" % "1.0" % "custom,optional,runtime",
|
||||
"g" % "g" % "1.0" % "custom,runtime" classifier "foo",
|
||||
"h" % "h" % "1.0" % "custom,optional,runtime" classifier "foo"
|
||||
)
|
||||
)
|
||||
|
||||
def checkPom = makePom map { pom =>
|
||||
val expected = Seq(
|
||||
("a", None, false, None),
|
||||
("b", Some("runtime"), true, None),
|
||||
("c", None, true, None),
|
||||
("d", Some("test"), false, None),
|
||||
("e", None, false, None),
|
||||
("f", Some("runtime"), true, None),
|
||||
("g", Some("runtime"), false, Some("foo")),
|
||||
("h", Some("runtime"), true, Some("foo"))
|
||||
)
|
||||
val loaded = xml.XML.loadFile(pom)
|
||||
val deps = loaded \\ "dependency"
|
||||
expected foreach { case (id, scope, opt, classifier) =>
|
||||
val dep = deps.find(d => (d \ "artifactId").text == id).getOrElse( sys.error("Dependency '" + id + "' not written to pom:\n" + loaded))
|
||||
val actualOpt = java.lang.Boolean.parseBoolean( (dep \\ "optional").text )
|
||||
assert(opt == actualOpt, "Invalid 'optional' section '" + (dep \\ "optional") + "' for " + id + ", expected optional=" + opt)
|
||||
|
||||
val actualScope = (dep \\ "scope") match { case Seq() => None; case x => Some(x.text) }
|
||||
val actualClassifier = (dep \\ "classifier") match { case Seq() => None; case x => Some(x.text) }
|
||||
assert(actualScope == scope, "Invalid 'scope' section '" + (dep \\ "scope") + "' for " + id + ", expected scope=" + scope)
|
||||
assert(actualClassifier == classifier, "Invalid 'classifier' section '" + (dep \\ "classifier") + "' for " + id + ", expected classifier=" + classifier)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object PomTest extends Build
|
||||
{
|
||||
lazy val custom = config("custom")
|
||||
lazy val root = Project("root", file("root")) configs(custom) settings(
|
||||
TaskKey[Unit]("check-pom") <<= checkPom,
|
||||
libraryDependencies ++= Seq(
|
||||
"a" % "a" % "1.0",
|
||||
"b" % "b" % "1.0" % "runtime,optional",
|
||||
"c" % "c" % "1.0" % "optional",
|
||||
"d" % "d" % "1.0" % "test",
|
||||
"e" % "e" % "1.0" % "custom",
|
||||
"f" % "f" % "1.0" % "custom,optional,runtime",
|
||||
"g" % "g" % "1.0" % "custom,runtime" classifier "foo",
|
||||
"h" % "h" % "1.0" % "custom,optional,runtime" classifier "foo"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
def checkPom = makePom map { pom =>
|
||||
val expected = Seq(
|
||||
("a", None, false, None),
|
||||
("b", Some("runtime"), true, None),
|
||||
("c", None, true, None),
|
||||
("d", Some("test"), false, None),
|
||||
("e", None, false, None),
|
||||
("f", Some("runtime"), true, None),
|
||||
("g", Some("runtime"), false, Some("foo")),
|
||||
("h", Some("runtime"), true, Some("foo"))
|
||||
)
|
||||
val loaded = xml.XML.loadFile(pom)
|
||||
val deps = loaded \\ "dependency"
|
||||
expected foreach { case (id, scope, opt, classifier) =>
|
||||
val dep = deps.find(d => (d \ "artifactId").text == id).getOrElse( sys.error("Dependency '" + id + "' not written to pom:\n" + loaded))
|
||||
val actualOpt = java.lang.Boolean.parseBoolean( (dep \\ "optional").text )
|
||||
assert(opt == actualOpt, "Invalid 'optional' section '" + (dep \\ "optional") + "' for " + id + ", expected optional=" + opt)
|
||||
|
||||
val actualScope = (dep \\ "scope") match { case Seq() => None; case x => Some(x.text) }
|
||||
val actualClassifier = (dep \\ "classifier") match { case Seq() => None; case x => Some(x.text) }
|
||||
assert(actualScope == scope, "Invalid 'scope' section '" + (dep \\ "scope") + "' for " + id + ", expected scope=" + scope)
|
||||
assert(actualClassifier == classifier, "Invalid 'classifier' section '" + (dep \\ "classifier") + "' for " + id + ", expected classifier=" + classifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object P extends Build
|
||||
{
|
||||
override def settings = super.settings ++ Seq(
|
||||
scalaBinaryVersion in update := "2.9.0"
|
||||
)
|
||||
|
||||
def configIvyScala =
|
||||
ivyScala ~= { _.map(_.copy(checkExplicit = false)) }
|
||||
|
||||
val declared = SettingKey[Boolean]("declared")
|
||||
lazy val a = Project("A", file("a")) settings(
|
||||
libraryDependencies += "org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided",
|
||||
configIvyScala
|
||||
)
|
||||
|
||||
lazy val b = Project("B", file("b")) dependsOn(a) settings(
|
||||
libraryDependencies <<= declared(d => if(d) Seq("org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided") else Nil),
|
||||
declared <<= baseDirectory(_ / "declare.lib" exists),
|
||||
configIvyScala
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
def configIvyScala =
|
||||
ivyScala ~= { _.map(_.copy(checkExplicit = false)) }
|
||||
|
||||
val declared = SettingKey[Boolean]("declared")
|
||||
lazy val a = project.
|
||||
settings(
|
||||
libraryDependencies += "org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided",
|
||||
configIvyScala,
|
||||
scalaBinaryVersion in update := "2.9.0"
|
||||
)
|
||||
|
||||
lazy val b = project.
|
||||
dependsOn(a).
|
||||
settings(
|
||||
libraryDependencies <<= declared(d => if(d) Seq("org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided") else Nil),
|
||||
declared <<= baseDirectory(_ / "declare.lib" exists),
|
||||
configIvyScala,
|
||||
scalaBinaryVersion in update := "2.9.0"
|
||||
)
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
$ copy-file changes/P.scala project/P.scala
|
||||
$ copy-file changes/p.sbt p.sbt
|
||||
$ copy-file changes/A.scala a/src/main/scala/A.scala
|
||||
$ copy-file changes/B.scala b/src/main/scala/B.scala
|
||||
> reload
|
||||
|
||||
> A/compile
|
||||
-> B/compile
|
||||
> a/compile
|
||||
-> b/compile
|
||||
|
||||
$ touch b/declare.lib
|
||||
> reload
|
||||
> compile
|
||||
> compile
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
import complete.DefaultParsers._
|
||||
|
||||
val provided = SettingKey[Boolean]("provided")
|
||||
val check = InputKey[Unit]("check")
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
provided <<= baseDirectory(_ / "useProvided" exists),
|
||||
configuration <<= provided(p => if(p) Provided else Compile),
|
||||
libraryDependencies <+= configuration(c => "javax.servlet" % "servlet-api" % "2.5" % c.name),
|
||||
managedClasspath in Provided <<= (classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) },
|
||||
check <<= InputTask(_ => Space ~> token(Compile.name.id | Runtime.name | Provided.name | Test.name) ~ token(Space ~> Bool)) { result =>
|
||||
(result, managedClasspath in Provided, fullClasspath in Runtime, fullClasspath in Compile, fullClasspath in Test) map { case ((conf, expected), p, r, c, t) =>
|
||||
val cp = if(conf == Compile.name) c else if(conf == Runtime.name) r else if(conf == Provided.name) p else if(conf == Test.name) t else sys.error("Invalid config: " + conf)
|
||||
checkServletAPI(cp.files, expected, conf)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
def checkServletAPI(paths: Seq[File], shouldBeIncluded: Boolean, label: String) =
|
||||
{
|
||||
val servletAPI = paths.find(_.getName contains "servlet-api")
|
||||
if(shouldBeIncluded)
|
||||
{
|
||||
if(servletAPI.isEmpty)
|
||||
sys.error("Servlet API should have been included in " + label + ".")
|
||||
}
|
||||
else
|
||||
servletAPI.foreach(s => sys.error(s + " incorrectly included in " + label + "."))
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
import complete.DefaultParsers._
|
||||
|
||||
object TestProject extends Build
|
||||
{
|
||||
val provided = SettingKey[Boolean]("provided")
|
||||
val check = InputKey[Unit]("check")
|
||||
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
provided <<= baseDirectory(_ / "useProvided" exists),
|
||||
configuration <<= provided(p => if(p) Provided else Compile),
|
||||
libraryDependencies <+= configuration(c => "javax.servlet" % "servlet-api" % "2.5" % c.name),
|
||||
managedClasspath in Provided <<= (classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) },
|
||||
check <<= InputTask(_ => Space ~> token(Compile.name.id | Runtime.name | Provided.name | Test.name) ~ token(Space ~> Bool)) { result =>
|
||||
(result, managedClasspath in Provided, fullClasspath in Runtime, fullClasspath in Compile, fullClasspath in Test) map { case ((conf, expected), p, r, c, t) =>
|
||||
val cp = if(conf == Compile.name) c else if(conf == Runtime.name) r else if(conf == Provided.name) p else if(conf == Test.name) t else sys.error("Invalid config: " + conf)
|
||||
checkServletAPI(cp.files, expected, conf)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
private def checkServletAPI(paths: Seq[File], shouldBeIncluded: Boolean, label: String) =
|
||||
{
|
||||
val servletAPI = paths.find(_.getName contains "servlet-api")
|
||||
if(shouldBeIncluded)
|
||||
{
|
||||
if(servletAPI.isEmpty)
|
||||
sys.error("Servlet API should have been included in " + label + ".")
|
||||
}
|
||||
else
|
||||
servletAPI.foreach(s => sys.error(s + " incorrectly included in " + label + "."))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
lazy val root = (project in file(".")).
|
||||
dependsOn(sub).
|
||||
aggregate(sub).
|
||||
settings(inThisBuild(List(
|
||||
organization := "A",
|
||||
version := "1.0",
|
||||
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy" / "cache")) ),
|
||||
externalResolvers <<= baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }
|
||||
)),
|
||||
mavenStyle,
|
||||
interProject,
|
||||
name := "Publish Test"
|
||||
)
|
||||
|
||||
lazy val sub = project.
|
||||
settings(
|
||||
mavenStyle,
|
||||
name := "Sub Project"
|
||||
)
|
||||
|
||||
lazy val mavenStyle = publishMavenStyle <<= baseDirectory { base => (base / "mavenStyle") exists }
|
||||
|
||||
def interProject =
|
||||
projectDependencies <<= (publishMavenStyle, publishMavenStyle in sub, projectDependencies) map { (style, subStyle, pd) => if(style == subStyle) pd else Nil }
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
lazy val root = (project in file(".")).
|
||||
settings(inThisBuild(List(
|
||||
organization := "A",
|
||||
version := "1.0",
|
||||
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy" / "cache")) ),
|
||||
externalResolvers <<= baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }
|
||||
)),
|
||||
mavenStyle,
|
||||
name := "Retrieve Test",
|
||||
libraryDependencies <<= publishMavenStyle { style => if(style) mavenStyleDependencies else ivyStyleDependencies }
|
||||
)
|
||||
|
||||
|
||||
lazy val mavenStyle = publishMavenStyle <<= baseDirectory { base => (base / "mavenStyle") exists }
|
||||
|
||||
def ivyStyleDependencies = parentDep("A") :: subDep("A") :: subDep("B") ::parentDep("D") :: Nil
|
||||
def mavenStyleDependencies = parentDep("B") :: parentDep("C") :: subDep("C") :: subDep("D") :: Nil
|
||||
|
||||
def parentDep(org: String) = org %% "publish-test" % "1.0"
|
||||
def subDep(org: String) = org %% "sub-project" % "1.0"
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
|
||||
object MultiPublishTest extends Build
|
||||
{
|
||||
override lazy val settings = super.settings ++ Seq(
|
||||
organization := "A",
|
||||
version := "1.0",
|
||||
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy" / "cache")) ),
|
||||
externalResolvers <<= baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }
|
||||
)
|
||||
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
name := "Retrieve Test",
|
||||
mavenStyle,
|
||||
libraryDependencies <<= publishMavenStyle { style => if(style) mavenStyleDependencies else ivyStyleDependencies }
|
||||
)
|
||||
|
||||
lazy val mavenStyle = publishMavenStyle <<= baseDirectory { base => (base / "mavenStyle") exists }
|
||||
|
||||
def ivyStyleDependencies = parentDep("A") :: subDep("A") :: subDep("B") ::parentDep("D") :: Nil
|
||||
def mavenStyleDependencies = parentDep("B") :: parentDep("C") :: subDep("C") :: subDep("D") :: Nil
|
||||
|
||||
def parentDep(org: String) = org %% "publish-test" % "1.0"
|
||||
def subDep(org: String) = org %% "sub-project" % "1.0"
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
|
||||
object MultiPublishTest extends Build
|
||||
{
|
||||
override lazy val settings = super.settings ++ Seq(
|
||||
organization := "A",
|
||||
version := "1.0",
|
||||
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy" / "cache")) ),
|
||||
externalResolvers <<= baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }
|
||||
)
|
||||
|
||||
lazy val root = Project("root", file(".")) dependsOn(sub) aggregate(sub) settings( mavenStyle, interProject, name := "Publish Test" )
|
||||
|
||||
lazy val sub = Project("sub", file("sub")) settings( mavenStyle, name := "Sub Project" )
|
||||
|
||||
lazy val mavenStyle = publishMavenStyle <<= baseDirectory { base => (base / "mavenStyle") exists }
|
||||
|
||||
def interProject =
|
||||
projectDependencies <<= (publishMavenStyle, publishMavenStyle in sub, projectDependencies) map { (style, subStyle, pd) => if(style == subStyle) pd else Nil }
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
import sbt.internal.librarymanagement.syntax._
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
libraryDependencies += "net.liftweb" % "lift-webkit" % "1.0" intransitive(),
|
||||
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.5" intransitive(),
|
||||
autoScalaLibrary := false,
|
||||
managedScalaInstance := false,
|
||||
transitiveClassifiers := Seq("sources"),
|
||||
TaskKey[Unit]("check-sources") <<= updateClassifiers map checkSources,
|
||||
TaskKey[Unit]("check-binaries") <<= update map checkBinaries
|
||||
)
|
||||
|
||||
def getSources(report: UpdateReport) = report.matching(artifactFilter(`classifier` = "sources") )
|
||||
def checkSources(report: UpdateReport): Unit =
|
||||
{
|
||||
val srcs = getSources(report)
|
||||
if(srcs.isEmpty)
|
||||
sys.error("No sources retrieved")
|
||||
else if(srcs.size != 2)
|
||||
sys.error("Incorrect sources retrieved:\n\t" + srcs.mkString("\n\t"))
|
||||
else
|
||||
()
|
||||
}
|
||||
|
||||
def checkBinaries(report: UpdateReport): Unit =
|
||||
{
|
||||
val srcs = getSources(report)
|
||||
if(srcs.nonEmpty) sys.error("Sources retrieved:\n\t" + srcs.mkString("\n\t"))
|
||||
else ()
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
import sbt.internal.librarymanagement.syntax._
|
||||
|
||||
object Test extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
libraryDependencies += "net.liftweb" % "lift-webkit" % "1.0" intransitive(),
|
||||
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.5" intransitive(),
|
||||
autoScalaLibrary := false,
|
||||
managedScalaInstance := false,
|
||||
transitiveClassifiers := Seq("sources"),
|
||||
TaskKey[Unit]("check-sources") <<= updateClassifiers map checkSources,
|
||||
TaskKey[Unit]("check-binaries") <<= update map checkBinaries
|
||||
)
|
||||
def getSources(report: UpdateReport) = report.matching(artifactFilter(`classifier` = "sources") )
|
||||
def checkSources(report: UpdateReport): Unit =
|
||||
{
|
||||
val srcs = getSources(report)
|
||||
if(srcs.isEmpty)
|
||||
sys.error("No sources retrieved")
|
||||
else if(srcs.size != 2)
|
||||
sys.error("Incorrect sources retrieved:\n\t" + srcs.mkString("\n\t"))
|
||||
else
|
||||
()
|
||||
}
|
||||
def checkBinaries(report: UpdateReport): Unit =
|
||||
{
|
||||
val srcs = getSources(report)
|
||||
if(srcs.nonEmpty) sys.error("Sources retrieved:\n\t" + srcs.mkString("\n\t")) else ()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import classpath.ClasspathUtilities
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
libraryDependencies += "slinky" % "slinky" % "2.1" % "test" from "http://slinky2.googlecode.com/svn/artifacts/2.1/slinky.jar",
|
||||
TaskKey[Unit]("check-in-test") <<= checkClasspath(Test),
|
||||
TaskKey[Unit]("check-in-compile") <<= checkClasspath(Compile)
|
||||
)
|
||||
|
||||
def checkClasspath(conf: Configuration) =
|
||||
fullClasspath in conf map { cp =>
|
||||
try
|
||||
{
|
||||
val loader = ClasspathUtilities.toLoader(cp.files)
|
||||
Class.forName("slinky.http.Application", false, loader)
|
||||
()
|
||||
}
|
||||
catch
|
||||
{
|
||||
case _: ClassNotFoundException => sys.error("Dependency not downloaded.")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
import sbt._
|
||||
import Import._
|
||||
import Keys._
|
||||
import classpath.ClasspathUtilities
|
||||
|
||||
object TestProject extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
libraryDependencies += "slinky" % "slinky" % "2.1" % "test" from "http://slinky2.googlecode.com/svn/artifacts/2.1/slinky.jar",
|
||||
TaskKey[Unit]("check-in-test") <<= checkClasspath(Test),
|
||||
TaskKey[Unit]("check-in-compile") <<= checkClasspath(Compile)
|
||||
)
|
||||
|
||||
private def checkClasspath(conf: Configuration) =
|
||||
fullClasspath in conf map { cp =>
|
||||
try
|
||||
{
|
||||
val loader = ClasspathUtilities.toLoader(cp.files)
|
||||
Class.forName("slinky.http.Application", false, loader)
|
||||
()
|
||||
}
|
||||
catch
|
||||
{
|
||||
case _: ClassNotFoundException => sys.error("Dependency not downloaded.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
import AddSettings._
|
||||
|
||||
// version should be from explicit/a.txt
|
||||
lazy val root = proj("root", "1.4").settingSets(
|
||||
buildScalaFiles,
|
||||
userSettings,
|
||||
sbtFiles(file("explicit/a.txt"))
|
||||
)
|
||||
|
||||
// version should be from global/user.sbt
|
||||
lazy val a = proj("a", "1.1").
|
||||
settingSets( buildScalaFiles, userSettings )
|
||||
|
||||
// version should be the default 0.1-SNAPSHOT
|
||||
lazy val b = proj("b", "0.1-SNAPSHOT").
|
||||
settingSets(buildScalaFiles)
|
||||
|
||||
// version should be from the explicit settings call
|
||||
lazy val c = proj("c", "0.9").settings(version := "0.9").
|
||||
settingSets(buildScalaFiles)
|
||||
|
||||
// version should be from d/build.sbt
|
||||
lazy val d = proj("d", "1.3").settings(version := "0.9").
|
||||
settingSets( buildScalaFiles, defaultSbtFiles )
|
||||
|
||||
// version should be from global/user.sbt
|
||||
lazy val e = proj("e", "1.1").settings(version := "0.9").
|
||||
settingSets( buildScalaFiles, defaultSbtFiles, sbtFiles(file("../explicit/a.txt")), userSettings )
|
||||
|
||||
def proj(id: String, expectedVersion: String): Project =
|
||||
Project(id, if(id == "root") file(".") else file(id)).
|
||||
settings(
|
||||
TaskKey[Unit]("check") := {
|
||||
assert(version.value == expectedVersion,
|
||||
"Expected version '" + expectedVersion + "', got: " + version.value + " in " + id)
|
||||
}
|
||||
)
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
import AddSettings._
|
||||
import Import._
|
||||
|
||||
object B extends Build
|
||||
{
|
||||
// version should be from explicit/a.txt
|
||||
lazy val root = project("root", "1.4") settingSets( buildScalaFiles, userSettings, sbtFiles(file("explicit/a.txt")) )
|
||||
|
||||
// version should be from global/user.sbt
|
||||
lazy val a = project("a", "1.1") settingSets( buildScalaFiles, userSettings )
|
||||
|
||||
// version should be the default 0.1-SNAPSHOT
|
||||
lazy val b = project("b", "0.1-SNAPSHOT") settingSets(buildScalaFiles)
|
||||
|
||||
// version should be from the explicit settings call
|
||||
lazy val c = project("c", "0.9") settings(version := "0.9") settingSets(buildScalaFiles)
|
||||
|
||||
// version should be from d/build.sbt
|
||||
lazy val d = project("d", "1.3") settings(version := "0.9") settingSets( buildScalaFiles, defaultSbtFiles )
|
||||
|
||||
// version should be from global/user.sbt
|
||||
lazy val e = project("e", "1.1") settings(version := "0.9") settingSets( buildScalaFiles, defaultSbtFiles, sbtFiles(file("../explicit/a.txt")), userSettings )
|
||||
|
||||
def project(id: String, expectedVersion: String): Project = Project(id, if(id == "root") file(".") else file(id)) settings(
|
||||
TaskKey[Unit]("check") <<= version map { v =>
|
||||
assert(v == expectedVersion, "Expected version '" + expectedVersion + "', got: " + v)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -22,7 +22,3 @@ object A extends AutoPlugin {
|
|||
check := {}
|
||||
)
|
||||
}
|
||||
|
||||
object B extends Build {
|
||||
lazy val extra = project.enablePlugins(bN)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
lazy val root = (project in file("."))
|
||||
lazy val a = project
|
||||
lazy val b = project
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
buildDependencies in Global <<= (buildDependencies in Global, thisProjectRef, thisProjectRef in a) { (deps, refB, refA) =>
|
||||
buildDependencies in Global <<= (buildDependencies in Global, thisProjectRef, thisProjectRef in LocalProject("a")) { (deps, refB, refA) =>
|
||||
deps.addClasspath(refA, ResolvedClasspathDependency(refB, None))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object B extends Build
|
||||
{
|
||||
lazy val root = Project("root", file("."))
|
||||
lazy val a = Project("a", file("a"))
|
||||
lazy val b = Project("b", file("b"))
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import Import._
|
||||
|
||||
object EmptyLoaderBuild extends Build {
|
||||
override def buildLoaders = BuildLoader.transform(_.unit) :: Nil
|
||||
lazy val root = (
|
||||
project in file(".")
|
||||
settings(
|
||||
name := "foo"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# Just making sure the build compiles is enough of a test.
|
||||
> name
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
lazy val root = (project in file(".")).
|
||||
aggregate(LocalProject("sub"))
|
||||
|
||||
lazy val sub = project.
|
||||
dependsOn(root)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue