forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModes.scala
29 lines (20 loc) · 1.1 KB
/
Modes.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sbt.{Project, ProjectReference, SettingsDefinition}
object Modes {
sealed trait Mode
object NonBootstrapped extends Mode
object Bootstrapped extends Mode
implicit class ProjectModesOps(val project: Project) extends AnyVal {
/** Applies the settings if mode is not bootstrapped */
def nonBootstrappedSettings(s: SettingsDefinition*)(implicit mode: Mode): Project =
if (mode == NonBootstrapped) project.settings(s: _*) else project
/** Applies the settings if mode is bootstrapped */
def bootstrappedSettings(s: SettingsDefinition*)(implicit mode: Mode): Project =
if (mode == NonBootstrapped) project else project.settings(s: _*)
/** Aggregate only if the mode is bootstrapped */
def bootstrappedAggregate(s: ProjectReference*)(implicit mode: Mode): Project =
if (mode == NonBootstrapped) project else project.aggregate(s: _*)
/** Depends only if the mode is bootstrapped */
def bootstrappedDependsOn(s: sbt.ClasspathDep[ProjectReference]*)(implicit mode: Mode): Project =
if (mode == NonBootstrapped) project else project.dependsOn(s: _*)
}
}