mirror of https://github.com/sbt/sbt.git
This commit is contained in:
parent
d07cdb92ad
commit
162ed3f320
|
|
@ -45,7 +45,13 @@ object Build {
|
||||||
def defaultID(base: File, prefix: String = "default"): String = prefix + "-" + Hash.trimHashString(base.getAbsolutePath, 6)
|
def defaultID(base: File, prefix: String = "default"): String = prefix + "-" + Hash.trimHashString(base.getAbsolutePath, 6)
|
||||||
@deprecated("Explicitly specify the ID", "0.13.0")
|
@deprecated("Explicitly specify the ID", "0.13.0")
|
||||||
def defaultProject(base: File): Project = defaultProject(defaultID(base), base)
|
def defaultProject(base: File): Project = defaultProject(defaultID(base), base)
|
||||||
def defaultProject(id: String, base: File): Project = Project(id, base).settings(
|
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: _*)
|
||||||
|
|
||||||
|
private[sbt] def generatedRootWithoutIvyPlugin(id: String, base: File, agg: Seq[ProjectRef]): Project =
|
||||||
|
Project.mkGeneratedRoot(id, base, agg).settings(defaultProjectSettings: _*)
|
||||||
|
private[sbt] def defaultProjectSettings: Seq[Setting[_]] = Seq(
|
||||||
// TODO - Can we move this somewhere else? ordering of settings is causing this to get borked.
|
// TODO - Can we move this somewhere else? ordering of settings is causing this to get borked.
|
||||||
// if the user has overridden the name, use the normal organization that is derived from the name.
|
// if the user has overridden the name, use the normal organization that is derived from the name.
|
||||||
organization := {
|
organization := {
|
||||||
|
|
@ -57,8 +63,6 @@ object Build {
|
||||||
},
|
},
|
||||||
autoGeneratedProject := true
|
autoGeneratedProject := true
|
||||||
)
|
)
|
||||||
def defaultAggregatedProject(id: String, base: File, agg: Seq[ProjectRef]): Project =
|
|
||||||
defaultProject(id, base).aggregate(agg: _*)
|
|
||||||
|
|
||||||
@deprecated("Use Attributed.data", "0.13.0")
|
@deprecated("Use Attributed.data", "0.13.0")
|
||||||
def data[T](in: Seq[Attributed[T]]): Seq[T] = Attributed.data(in)
|
def data[T](in: Seq[Attributed[T]]): Seq[T] = Attributed.data(in)
|
||||||
|
|
|
||||||
|
|
@ -135,8 +135,21 @@ final class DetectedPlugins(val plugins: DetectedModules[Plugin], val autoPlugin
|
||||||
}.partition(nonTopLevelPlugin)
|
}.partition(nonTopLevelPlugin)
|
||||||
|
|
||||||
/** A function to select the right [[AutoPlugin]]s from [[autoPlugins]] for a [[Project]]. */
|
/** A function to select the right [[AutoPlugin]]s from [[autoPlugins]] for a [[Project]]. */
|
||||||
|
@deprecated("Use deducePluginsFromProject", "0.13.8")
|
||||||
lazy val deducePlugins: (Plugins, Logger) => Seq[AutoPlugin] = Plugins.deducer(autoPlugins.toList map { _.value })
|
lazy val deducePlugins: (Plugins, Logger) => Seq[AutoPlugin] = Plugins.deducer(autoPlugins.toList map { _.value })
|
||||||
|
|
||||||
|
/** Selects the right [[AutoPlugin]]s from a [[Project]]. */
|
||||||
|
def deducePluginsFromProject(p: Project, log: Logger): Seq[AutoPlugin] =
|
||||||
|
{
|
||||||
|
val ps0 = p.plugins
|
||||||
|
val allDetected = autoPlugins.toList map { _.value }
|
||||||
|
val detected = p match {
|
||||||
|
case _: GeneratedRootProject => allDetected filterNot { _ == sbt.plugins.IvyPlugin }
|
||||||
|
case _ => allDetected
|
||||||
|
}
|
||||||
|
Plugins.deducer(detected)(ps0, log)
|
||||||
|
}
|
||||||
|
|
||||||
private[this] def autoImports(pluginNames: Seq[String]) = pluginNames.map(_ + ".autoImport")
|
private[this] def autoImports(pluginNames: Seq[String]) = pluginNames.map(_ + ".autoImport")
|
||||||
|
|
||||||
private[this] def nonTopLevelPlugin(name: String) = name.contains('.')
|
private[this] def nonTopLevelPlugin(name: String) = name.contains('.')
|
||||||
|
|
|
||||||
|
|
@ -585,9 +585,9 @@ object Load {
|
||||||
val existingIds = otherProjects.projects map (_.id)
|
val existingIds = otherProjects.projects map (_.id)
|
||||||
val refs = existingIds map (id => ProjectRef(buildUri, id))
|
val refs = existingIds map (id => ProjectRef(buildUri, id))
|
||||||
val defaultID = autoID(buildBase, context, existingIds)
|
val defaultID = autoID(buildBase, context, existingIds)
|
||||||
val root1 = Build.defaultAggregatedProject(defaultID, buildBase, refs)
|
val root0 = if (discovered.isEmpty) Build.defaultAggregatedProject(defaultID, buildBase, refs)
|
||||||
val root2 = if (discovered.isEmpty) root1 else root1.settings(Keys.publish := (()), Keys.publishLocal := (()))
|
else Build.generatedRootWithoutIvyPlugin(defaultID, buildBase, refs)
|
||||||
val root = finalizeProject(root2, files)
|
val root = finalizeProject(root0, files)
|
||||||
val result = root +: (acc ++ otherProjects.projects)
|
val result = root +: (acc ++ otherProjects.projects)
|
||||||
log.debug(s"[Loading] Done in ${buildBase}, returning: ${result.map(_.id).mkString("(", ", ", ")")}")
|
log.debug(s"[Loading] Done in ${buildBase}, returning: ${result.map(_.id).mkString("(", ", ", ")")}")
|
||||||
LoadedProjects(result, generated ++ otherGenerated ++ generatedConfigClassFiles)
|
LoadedProjects(result, generated ++ otherGenerated ++ generatedConfigClassFiles)
|
||||||
|
|
@ -647,7 +647,7 @@ object Load {
|
||||||
}
|
}
|
||||||
// 2. Discover all the autoplugins and contributed configurations.
|
// 2. Discover all the autoplugins and contributed configurations.
|
||||||
val autoPlugins =
|
val autoPlugins =
|
||||||
try loadedPlugins.detected.deducePlugins(transformedProject.plugins, log)
|
try loadedPlugins.detected.deducePluginsFromProject(transformedProject, log)
|
||||||
catch { case e: AutoPluginException => throw translateAutoPluginException(e, transformedProject) }
|
catch { case e: AutoPluginException => throw translateAutoPluginException(e, transformedProject) }
|
||||||
val autoConfigs = autoPlugins.flatMap(_.projectConfigurations)
|
val autoConfigs = autoPlugins.flatMap(_.projectConfigurations)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,13 @@ object Project extends ProjectExtra {
|
||||||
auto: AddSettings = AddSettings.allDefaults): Project =
|
auto: AddSettings = AddSettings.allDefaults): Project =
|
||||||
unresolved(id, base, aggregate, dependencies, delegates, settings, configurations, auto, Plugins.empty, Nil) // Note: JvmModule/IvyModule auto included...
|
unresolved(id, base, aggregate, dependencies, delegates, settings, configurations, auto, Plugins.empty, Nil) // Note: JvmModule/IvyModule auto included...
|
||||||
|
|
||||||
|
/** This is a variation of def apply that mixes in */
|
||||||
|
private[sbt] def mkGeneratedRoot(id: String, base: File, aggregate: => Seq[ProjectReference]): Project =
|
||||||
|
{
|
||||||
|
validProjectID(id).foreach(errMsg => sys.error("Invalid project ID: " + errMsg))
|
||||||
|
new ProjectDef[ProjectReference](id, base, aggregate, Nil, Nil, Nil, Nil, AddSettings.allDefaults, Plugins.empty, Nil) with Project with GeneratedRootProject
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns None if `id` is a valid Project ID or Some containing the parser error message if it is not.*/
|
/** Returns None if `id` is a valid Project ID or Some containing the parser error message if it is not.*/
|
||||||
def validProjectID(id: String): Option[String] = DefaultParsers.parse(id, DefaultParsers.ID).left.toOption
|
def validProjectID(id: String): Option[String] = DefaultParsers.parse(id, DefaultParsers.ID).left.toOption
|
||||||
private[this] def validProjectIDStart(id: String): Boolean = DefaultParsers.parse(id, DefaultParsers.IDStart).isRight
|
private[this] def validProjectIDStart(id: String): Boolean = DefaultParsers.parse(id, DefaultParsers.IDStart).isRight
|
||||||
|
|
@ -571,6 +578,8 @@ object Project extends ProjectExtra {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private[sbt] trait GeneratedRootProject
|
||||||
|
|
||||||
trait ProjectExtra {
|
trait ProjectExtra {
|
||||||
implicit def configDependencyConstructor[T <% ProjectReference](p: T): Constructor = new Constructor(p)
|
implicit def configDependencyConstructor[T <% ProjectReference](p: T): Constructor = new Constructor(p)
|
||||||
implicit def classpathDependency[T <% ProjectReference](p: T): ClasspathDependency = new ClasspathDependency(p, None)
|
implicit def classpathDependency[T <% ProjectReference](p: T): ClasspathDependency = new ClasspathDependency(p, None)
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
- Fixes eviction warning being too noisy. [#1615][1615] by [@eed3si9n][@eed3si9n]
|
- Fixes eviction warning being too noisy. [#1615][1615] by [@eed3si9n][@eed3si9n]
|
||||||
- Issues warning if multiple dependencies to a same library is found with different version. [#1634][1634] by [@eed3si9n][@eed3si9n]
|
- Issues warning if multiple dependencies to a same library is found with different version. [#1634][1634] by [@eed3si9n][@eed3si9n]
|
||||||
- Removes "No main class detected" warning. [#1766][1766] by [@eed3si9n][@eed3si9n]
|
- Removes "No main class detected" warning. [#1766][1766] by [@eed3si9n][@eed3si9n]
|
||||||
- Disable publishing artificial root by default. [#1871][1871]/[#1869][1869] by [@dwijnand][@dwijnand]
|
- Disable publishing on implicitly created root project by not enabling `IvyPlugin` by default. [#1871][1871]/[#1869][1869] by [@dwijnand][@dwijnand]
|
||||||
|
|
||||||
### Rolling back XML parsing workaround
|
### Rolling back XML parsing workaround
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue