SlideShare a Scribd company logo
Who doesn’t use SBT?
How many SBT projects
does your team maintain?
Archetype | ˈärk(i)ˌtīp |
• a very typical example of a certain person or thing (Apple Dictionary)
• a statement, pattern of behavior, or prototype which other statements,
patterns of behavior, and objects copy or emulate (Wikipedia)
Archetype | ˈärk(i)ˌtīp |
• a very typical example of a certain person or thing (Apple Dictionary)
• a statement, pattern of behavior, or prototype which other statements,
patterns of behavior, and objects copy or emulate (Wikipedia)
Composing Project
Archetypes with SBT
AutoPlugins
Mark Schaake
allenai.org
“contribute to humanity through high-impact AI research and engineering”
Composing Project
Archetypes with SBT
AutoPlugins
Mark Schaake
allenai.org
“contribute to humanity through high-impact AI research and engineering”
Combatting Multiple Build
Maintenance Hell with
Archetype AutoPlugins
Mark Schaake
allenai.org
“contribute to humanity through high-impact AI research and engineering”
“When you have very limited visibility and
control over many project builds to the point
where you feel paralyzed to maintaining cross-
project consistency.”
(Multiple Build Maintenance Hell)
MBMH
• visibility: what libraries, plugins, versions?
• control: how to enforce team standards, upgrades?
• consistency: minimize context switching
SOA, Inc.
• SOA architecture
• Scala, Akka, Spray
Svc A
Plugins Projects Dependencies
Svc A
Plugins Projects Dependencies
packager 0.6.0
scalariform 1.3
// native packager for generating deployable artifacts
addSbtPlugin(
"com.typesafe.sbt" % "sbt-native-packager" % "0.6.0")
 
// format our code in SBT instead of our editors
addSbtPlugin(
"com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
project/plugins.sbt
Svc A
Plugins Projects Dependencies
packager 0.6.0
scalariform 1.3
// native packager for generating deployable artifacts
addSbtPlugin(
"com.typesafe.sbt" % "sbt-native-packager" % "0.6.0")
 
// format our code in SBT instead of our editors
addSbtPlugin(
"com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
project/plugins.sbt
akka 2.3.2
spray 1.3.0
dispatch 0.11.1
scala 2.10.2
organization := "com.soa"
 
name := "service-a"
 
scalaVersion := "2.10.2"
 
libraryDependencies ++= Seq(
"io.spray" % "spray-can" % "1.3.0",
"io.spray" % "spray-routing" % "1.3.0",
"com.typesafe.akka" %% "akka-actor" % "2.3.2",
"com.typesafe.akka" %% "akka-slf4j" % "2.3.2",
"net.databinder" %% "dispatch-core" % "0.11.1",
"ch.qos.logback" % "logback-classic" % "1.1.2"
...
)
build.sbt
// native packager for generating deployable artifacts
addSbtPlugin(
"com.typesafe.sbt" % "sbt-native-packager" % "0.6.0")
 
// format our code in SBT instead of our editors
addSbtPlugin(
"com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
// native packager for generating deployable artifacts
addSbtPlugin(
"com.typesafe.sbt" % "sbt-native-packager" % "0.6.0")
 
// format our code in SBT instead of our editors
addSbtPlugin(
"com.typesafe.sbt" % "sbt-scalariform" % “1.3.0")
addSbtPlugin(
“org.scalastyle" %% "scalastyle" % “0.5.0")
Svc A
Plugins Projects Dependencies
akka 2.3.2
spray 1.3.0
dispatch 0.11.1Svc B
akka 2.3.4
spray 1.3.1
scala 2.10.2
scala 2.11.1
packager 0.6.0
scalastyle
scalariform 1.3
organization := "com.soa"
 
name := "service-a"
 
scalaVersion := "2.10.2"
 
libraryDependencies ++= Seq(
"io.spray" % "spray-can" % "1.3.0",
"io.spray" % "spray-routing" % "1.3.0",
"com.typesafe.akka" %% "akka-actor" % "2.3.2",
"com.typesafe.akka" %% "akka-slf4j" % "2.3.2",
"net.databinder" %% "dispatch-core" % "0.11.1",
"ch.qos.logback" % "logback-classic" % "1.1.2"
...
)
build.sbt
organization := "com.soa"
 
name := "service-b"
 
scalaVersion := "2.11.1"
 
libraryDependencies ++= Seq(
"io.spray" % "spray-can" % "1.3.1",
"io.spray" % "spray-routing" % "1.3.1",
"com.typesafe.akka" %% "akka-actor" % "2.3.4",
"com.typesafe.akka" %% "akka-slf4j" % "2.3.4",
"net.databinder" %% "dispatch-core" % "0.11.1",
"ch.qos.logback" % "logback-classic" % "1.1.2"
...
)
project/plugins.sbt
Svc A
Plugins Projects Dependencies
akka 2.3.2
spray 1.3.0
dispatch 0.11.1Svc B
akka 2.3.4
spray-client 1.3.2
spray 1.3.1
Svc C
scala 2.10.2
scala 2.11.1
akka 2.3.6
spray 1.3.2
packager 0.6.0
scalastyle
packager 0.7.2
scalariform 1.3
scalariform 1.5
Svc A
Plugins Projects Dependencies
akka 2.3.2
spray 1.3.0
dispatch 0.11.1Svc B
akka 2.3.4
spray-client 1.3.2
spray 1.3.1
Svc C
scala 2.10.2
scala 2.11.1
akka 2.3.6
spray 1.3.2
Svc D
packager 0.6.0
scalastyle
packager 0.7.2
scalariform 1.3
scalariform 1.5
Svc A
Plugins Projects Dependencies
akka 2.3.2
spray 1.3.0
dispatch 0.11.1Svc B
akka 2.3.4
spray-client 1.3.2
spray 1.3.1
Svc C
scala 2.10.2
scala 2.11.1
akka 2.3.6
spray 1.3.2
Svc D
packager 0.6.0
scalastyle
packager 0.7.2
scalariform 1.3
scalariform 1.5
…
Lib X
Lib Y
CLI Z scopt
…
sbt-release
assembly
project/plugins.sbt 6
build.sbt 50
Project build LOC 56
x 26 projects
= 1,456 LOC!
…
…
Avg Project Build LOC
and mostly boilerplate
project/plugins.sbt 6
build.sbt 50
Project build LOC 56
x 26 projects
= 1,456 LOC!
…
…
Avg Project Build LOC
and mostly boilerplate
MBMH!
and MBMH
BuildLOC
500
1,000
1,500
2,000
2,500
Projects
15
30
45
60
Jan March May July Sept Nov
Projects Build LOC
and MBMH
BuildLOC
500
1,000
1,500
2,000
2,500
Projects
15
30
45
60
Jan March May July Sept Nov
Projects Build LOC
M
BuildLOC
500
1,000
1,500
2,000
2,500
Projects
15
30
45
60
Jan March May July Sept Nov
Projects Build LOC
MBMH
and MBMH
Yay!
Solving MBMH
Solving
• Maximize consistency across projects
MBMH
Solving
• Maximize consistency across projects
• Minimize build complexity (LOC)
MBMH
Solving
• Maximize consistency across projects
• Minimize build complexity (LOC)
• Maximize agility to evolve standards
MBMH
Solving
• Maximize consistency across projects
• Minimize build complexity (LOC)
• Maximize agility to evolve standards
• Allow for stragglers (don’t force upgrades)
MBMH
Solving
• Maximize consistency across projects
• Minimize build complexity (LOC)
• Maximize agility to evolve standards
• Allow for stragglers (don’t force upgrades)
• Easy build upgrade path
MBMH
Other Considerations
Other Considerations
• Archetype settings shared by similar projects
Other Considerations
• Archetype settings shared by similar projects
• Core settings common to all projects
Other Considerations
• Archetype settings shared by similar projects
• Core settings common to all projects
• Formatting and Style
Other Considerations
• Archetype settings shared by similar projects
• Core settings common to all projects
• Formatting and Style
• Generate Git version resource
Solution:
Archetype SBT Plugins
Solution:
Archetype SBT Plugins
• Projects enable a single (versioned) archetype plugin
Solution:
Archetype SBT Plugins
• Projects enable a single (versioned) archetype plugin
• Archetype plugin provides:
• core build settings (style, scala version, etc.)
Solution:
Archetype SBT Plugins
• Projects enable a single (versioned) archetype plugin
• Archetype plugin provides:
• core build settings (style, scala version, etc.)
• archetype build settings (deploy, publish, etc.)
Solution:
Archetype SBT Plugins
• Projects enable a single (versioned) archetype plugin
• Archetype plugin provides:
• core build settings (style, scala version, etc.)
• archetype build settings (deploy, publish, etc.)
• archetype dependencies (e.g. spray, akka, scopt)
Solution:
Archetype SBT Plugins
• Projects enable a single (versioned) archetype plugin
• Archetype plugin provides:
• core build settings (style, scala version, etc.)
• archetype build settings (deploy, publish, etc.)
• archetype dependencies (e.g. spray, akka, scopt)
• Project upgraded upgraded by upgrading plugin version
Svc A
Plugins Projects Dependencies
akka 2.3.2
spray 1.3.0
dispatch 0.11.1Svc B
akka 2.3.4
spray-client 1.3.2
spray 1.3.1
Svc C
scala 2.10.2
scala 2.11.1
akka 2.3.6
spray 1.3.2
Svc D
packager 0.6.0
scalastyle
packager 0.7.2
scalariform 1.3
scalariform 1.5
Web Services
web-service 1.0
Svc A
akka 2.3.2
spray 1.3.0
dispatch 0.11.1
Svc B
Svc C
scala 2.10.2
Svc D
packager 0.6.0
scalariform 1.3
web-service 2.0
akka 2.3.4
spray 1.3.1
dispatch 0.11.1
scala 2.11.1packager 0.6.0
scalariform 1.3
scalastyle
web-service 2.1
akka 2.3.6
spray 1.3.2
spray-client 1.3.2
scala 2.11.1packager 0.7.2
scalariform 1.5
scalastyle
<app-specific
dependencies>
Plugins Projects Dependencies
Web Services
sbt-revolver
sbt-revolver
sbt-revolver
web-service 1.0 Svc A
Archetype Plugins Projects
Svc B
Svc C
Svc D
web-service 2.0
web-service 2.1
library 1.0
library 1.1
cli 1.0
Lib X
Lib Y
CLI Z
…
…
…
web-app 1.0 App W
…
web-service 1.0 Svc A
Archetype Plugins Projects
Svc B
Svc C
Svc D
web-service 2.0
web-service 2.1
library 1.0
library 1.1
cli 1.0
Lib X
Lib Y
CLI Z
…
…
…
web-app 1.0 App W
…
Before Archetypes
import com.typesafe.sbt.SbtNativePackager._
import org.scalastyle.sbt.ScalastylePlugin
scalaVersion := "2.10.2"
name := "Proj B"
Revolver.settings
scalariformSettings
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(DoubleIndentClassDeclaration, true)
.setPreference(MultilineScaladocCommentsStartOnFirstLine, true)
.setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true)
ScalastylePlugin.Settings
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.1",
"io.spray" % "spray-can" % "1.3.2",
"io.spray" % "spray-routing" % "1.3.2",
"io.spray" % "spray-cace" % "1.3.2",
"io.spray" % "spray-json" % "1.2.6",
"net.databinder.dispatch" %% "dispatch-core" % "0.11.0"
)
…
addSbtPlugin("com.github.gzeitz" % "sbt-release" % "0.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.4")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.6.2")
addSbtPlugin("org.allenai.plugins" % "version-injector" % "0.2.2")
addSbtPlugin("org.allenai.plugins" % "publisher" % "0.2.2")
Before Archetypes
import com.typesafe.sbt.SbtNativePackager._
import org.scalastyle.sbt.ScalastylePlugin
scalaVersion := "2.10.2"
name := "Proj B"
Revolver.settings
scalariformSettings
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(DoubleIndentClassDeclaration, true)
.setPreference(MultilineScaladocCommentsStartOnFirstLine, true)
.setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true)
ScalastylePlugin.Settings
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.1",
"io.spray" % "spray-can" % "1.3.2",
"io.spray" % "spray-routing" % "1.3.2",
"io.spray" % "spray-cace" % "1.3.2",
"io.spray" % "spray-json" % "1.2.6",
"net.databinder.dispatch" %% "dispatch-core" % "0.11.0"
)
…
addSbtPlugin("com.github.gzeitz" % "sbt-release" % "0.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.4")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.6.2")
addSbtPlugin("org.allenai.plugins" % "version-injector" % "0.2.2")
addSbtPlugin("org.allenai.plugins" % "publisher" % "0.2.2")
name := "Proj B"
enablePlugins(WebServicePlugin)
addSbtPlugin("org.allenai.plugins" % "plugins" % “1.0”)
After Archetypes
LOC Before 56
LOC After 3
LOC Reduction 95%
Implementing
Archetype Plugins
Implementing
Archetype Plugins
• How to wrap / depend on other plugins?
Implementing
Archetype Plugins
• How to wrap / depend on other plugins?
• How to include core settings in each archetype?
ArchetypePlugins
What AI2 Needed
Library Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Web App
libraryDependencies:
- ai2Webapp
settings:
- npm:*
- reStart dependsOn npm:build
- universal:mappings + npm:target
CLI
libraryDependencies:
- scopt
ArchetypePlugins
What AI2 Needed
Library Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Web App
libraryDependencies:
- ai2Webapp
settings:
- npm:*
- reStart dependsOn npm:build
- universal:mappings + npm:target
CLI
libraryDependencies:
- scopt
AuxiliaryPlugins
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Release
wrapped plugins:
- sbt-release
settings:
- custom versioning
NodeJs
commands:
- npm <args>
- npm:install
- npm:build
- npm:test
- nom:clean
settings:
- npm:nodeProjectDir
- npm:nodeProjectTarget
- npm:buildEnvironment
- nom:environment
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
(Vanilla) SBT Plugins?
• Loosely defined API
• What are the right conventions?
Adding Popular SBT Plugin
Settings
“To add the default plugin settings, add the
following to your build.sbt…”
Adding Popular SBT Plugin
Settings
“To add the default plugin settings, add the
following to your build.sbt…”
import com.typesafe.sbt.SbtNativePackager._
import NativePackagerKeys._
packageArchetype.java_application
sbt-native-packager
org.scalastyle.sbt.ScalastylePlugin.Settings
sbt-scalastyle
scalariformSettings
sbt-scalariform
Revolver.settings
sbt-revolver
SBT AutoPlugins
• The new Plugin standard (since SBT 0.13.5)
SBT AutoPlugins
• The new Plugin standard (since SBT 0.13.5)
• Well-defined plugin API
SBT AutoPlugins
• The new Plugin standard (since SBT 0.13.5)
• Well-defined plugin API
• Less need for conventions
SBT AutoPlugins
• The new Plugin standard (since SBT 0.13.5)
• Well-defined plugin API
• Less need for conventions
• Killer feature: can compose plugins via `requires`
abstract class AutoPlugin {
…
/** When this AutoPlugin is enabled, all required
* plugins will also be enabled automatically prior
* to enabling this AutoPlugin. */
def requires: Plugins = empty
/** The [[Setting]]s to add in the scope of each
* project that activates this AutoPlugin. */
def projectSettings: Seq[Setting[_]] = Nil
…
}
SBT AutoPlugins
https://github.com/sbt/sbt/blob/0.13.7/main/src/main/scala/sbt/Plugins.scala
Core Settings AutoPlugin
object CoreSettingsPlugin extends AutoPlugin {
 
override def requires = StylePlugin && VersionInjectorPlugin
 
override def projectSettings = Seq(
scalaVersion := CoreDependencies.defaultScalaVersion,
scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation"),
javacOptions ++= Seq("-source", "1.7", "-target", “1.7"), …
)
}
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
Core Settings AutoPlugin
When CoreSettingsPlugin is enabled…
object CoreSettingsPlugin extends AutoPlugin {
 
override def requires = StylePlugin && VersionInjectorPlugin
 
override def projectSettings = Seq(
scalaVersion := CoreDependencies.defaultScalaVersion,
scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation"),
javacOptions ++= Seq("-source", "1.7", "-target", “1.7"), …
)
}
Core Settings AutoPlugin
1. adds projectSettings from StylePlugin and VersionInjector
When CoreSettingsPlugin is enabled…
object CoreSettingsPlugin extends AutoPlugin {
 
override def requires = StylePlugin && VersionInjectorPlugin
 
override def projectSettings = Seq(
scalaVersion := CoreDependencies.defaultScalaVersion,
scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation"),
javacOptions ++= Seq("-source", "1.7", "-target", “1.7"), …
)
}
Core Settings AutoPlugin
1. adds projectSettings from StylePlugin and VersionInjector
2. adds projectSettings from CoreSettings
When CoreSettingsPlugin is enabled…
object CoreSettingsPlugin extends AutoPlugin {
 
override def requires = StylePlugin && VersionInjectorPlugin
 
override def projectSettings = Seq(
scalaVersion := CoreDependencies.defaultScalaVersion,
scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation"),
javacOptions ++= Seq("-source", "1.7", "-target", “1.7"), …
)
}
Composing an
Archetype Plugin
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
object WebServicePlugin extends AutoPlugin {
override def requires = CoreSettingsPlugin && DeployPlugin
override def projectSettings = Revolver.settings ++ Seq(
libraryDependencies ++= Seq(
akkaActor,
akkaLogging,
sprayCan,
sprayRouting,
sprayJson,
allenAiCommon,
allenAiTestkit % "test"))
}
Composing an
Archetype Plugin
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
object WebServicePlugin extends AutoPlugin {
override def requires = CoreSettingsPlugin && DeployPlugin
override def projectSettings = Revolver.settings ++ Seq(
libraryDependencies ++= Seq(
akkaActor,
akkaLogging,
sprayCan,
sprayRouting,
sprayJson,
allenAiCommon,
allenAiTestkit % "test"))
}
Composing an
Archetype Plugin
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
object WebServicePlugin extends AutoPlugin {
override def requires = CoreSettingsPlugin && DeployPlugin
override def projectSettings = Revolver.settings ++ Seq(
libraryDependencies ++= Seq(
akkaActor,
akkaLogging,
sprayCan,
sprayRouting,
sprayJson,
allenAiCommon,
allenAiTestkit % "test"))
}
Composing an
Archetype Plugin
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
object WebServicePlugin extends AutoPlugin {
override def requires = CoreSettingsPlugin && DeployPlugin
override def projectSettings = Revolver.settings ++ Seq(
libraryDependencies ++= Seq(
akkaActor,
akkaLogging,
sprayCan,
sprayRouting,
sprayJson,
allenAiCommon,
allenAiTestkit % "test"))
}
When WebServicePlugin is enabled…
Composing an
Archetype Plugin
1. Style and Versioning applied
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
object WebServicePlugin extends AutoPlugin {
override def requires = CoreSettingsPlugin && DeployPlugin
override def projectSettings = Revolver.settings ++ Seq(
libraryDependencies ++= Seq(
akkaActor,
akkaLogging,
sprayCan,
sprayRouting,
sprayJson,
allenAiCommon,
allenAiTestkit % "test"))
}
When WebServicePlugin is enabled…
Composing an
Archetype Plugin
1. Style and Versioning applied
2. CoreSettings and Deploy applied
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
object WebServicePlugin extends AutoPlugin {
override def requires = CoreSettingsPlugin && DeployPlugin
override def projectSettings = Revolver.settings ++ Seq(
libraryDependencies ++= Seq(
akkaActor,
akkaLogging,
sprayCan,
sprayRouting,
sprayJson,
allenAiCommon,
allenAiTestkit % "test"))
}
When WebServicePlugin is enabled…
Composing an
Archetype Plugin
1. Style and Versioning applied
2. CoreSettings and Deploy applied
3. WebService applied
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
object WebServicePlugin extends AutoPlugin {
override def requires = CoreSettingsPlugin && DeployPlugin
override def projectSettings = Revolver.settings ++ Seq(
libraryDependencies ++= Seq(
akkaActor,
akkaLogging,
sprayCan,
sprayRouting,
sprayJson,
allenAiCommon,
allenAiTestkit % "test"))
}
When WebServicePlugin is enabled…
ArchetypePluginsAuxiliaryPlugins Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
ArchetypePluginsAuxiliaryPlugins Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
Release
wrapped plugins:
- sbt-release
settings:
- custom versioning
Library
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
ArchetypePluginsAuxiliaryPlugins Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
CLI
libraryDependencies:
- scopt
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
Release
wrapped plugins:
- sbt-release
settings:
- custom versioning
Library
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
ArchetypePluginsAuxiliaryPlugins Web Service
libraryDependencies:
- akka
- spray
- spray-json
- typesafeConfig
- ai2Common
- ai2Testkit
wrapped plugins:
- sbt-revolver
CLI
libraryDependencies:
- scopt
Core Settings
scalaVersion: 2.10.4
scalacOptions: …
conflictManager: strict
common library ModuleIDs
- ai2Common, ai2Testkit, …
- akka, spray, spray-json
Versioning
tasks:
- injectVersion
- injectArtifact
- injectGit
- gitCommitDate
- gitRemotes
- gitSha1
- gitDescribe
Style
wrapped plugins:
- scalariform
- scalastyle
settings:
- apply scalariform
- apply scalastyle
Release
wrapped plugins:
- sbt-release
settings:
- custom versioning
Library
Deploy
wrapped plugins:
- sbt-native-packager
command:
- deploy
Web App
libraryDependencies:
- ai2Webapp
settings:
- npm:*
- reStart dependsOn npm:build
- universal:mappings + npm:target
NodeJs
commands:
- npm <args>
- npm:install
- npm:build
- npm:test
- nom:clean
settings:
- npm:nodeProjectDir
- npm:nodeProjectTarget
- npm:buildEnvironment
- nom:environment
Archetype Plugins
in Action
Resources
• SBT docs - http://www.scala-sbt.org/0.13/docs/Plugins.html
• Tutorial - http://mukis.de/pages/sbt-autoplugins-tutorial/
• AI2 sbt-plugins: https://github.com/allenai/sbt-plugins
Questions
Mark Schaake
marks@allenai.org
@markschaake
Project Archetype Recipe
• Create a company “sbt-plugins” project
• Wrap third-party plugins (scalariform, scalastyle, etc.)
• Define a core settings AutoPlugin that enforces team
standards
• Define archetype plugins that require core settings
and add in archetype-specific settings
• Publish to Bintray and serve!

More Related Content

What's hot

Continous integration and delivery for single page applications
Continous integration and delivery for single page applicationsContinous integration and delivery for single page applications
Continous integration and delivery for single page applications
Sunil Dalal
 
CI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsCI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page Apps
Mike North
 
BP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
BP-10 Keeping Your Sanity – Rapid Development & Deployment ToolsBP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
BP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
Alfresco Software
 
GitBucket: The perfect Github clone by Scala
GitBucket: The perfect Github clone by ScalaGitBucket: The perfect Github clone by Scala
GitBucket: The perfect Github clone by Scala
takezoe
 
OpenStack Doc Overview for Boot Camp
OpenStack Doc Overview for Boot CampOpenStack Doc Overview for Boot Camp
OpenStack Doc Overview for Boot Camp
Anne Gentle
 
Puppet Release Workflows at Jive Software
Puppet Release Workflows at Jive SoftwarePuppet Release Workflows at Jive Software
Puppet Release Workflows at Jive Software
Puppet
 
Kubernetes and AWS Lambda can play nicely together
Kubernetes and AWS Lambda can play nicely togetherKubernetes and AWS Lambda can play nicely together
Kubernetes and AWS Lambda can play nicely together
Edward Wilde
 
Akkurate Akka
Akkurate AkkaAkkurate Akka
Akkurate Akka
Yurii Ostapchuk
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on RailsAvi Kedar
 
Scala for java developers 6 may 2017 - yeni
Scala for java developers   6 may 2017 - yeniScala for java developers   6 may 2017 - yeni
Scala for java developers 6 may 2017 - yeni
Baris Dere
 
Michelin Starred Cooking with Chef
Michelin Starred Cooking with ChefMichelin Starred Cooking with Chef
Michelin Starred Cooking with Chef
Jon Cowie
 
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
Ryan Cuprak
 
What is this cloud thing?
What is this cloud thing?What is this cloud thing?
What is this cloud thing?
Andrew Eisenberg
 
KubeCon 2019 Recap (Parts 1-3)
KubeCon 2019 Recap (Parts 1-3)KubeCon 2019 Recap (Parts 1-3)
KubeCon 2019 Recap (Parts 1-3)
Ford Prior
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill Sparks
Phill Sparks
 
Immutable infrastructure with Boxfuse
Immutable infrastructure with BoxfuseImmutable infrastructure with Boxfuse
Immutable infrastructure with Boxfuse
Lars Östling
 
Docker in the Cloud
Docker in the CloudDocker in the Cloud
Docker in the Cloud
Sascha Möllering
 
DrupalCon 2011 Highlight
DrupalCon 2011 HighlightDrupalCon 2011 Highlight
DrupalCon 2011 Highlight
Supakit Kiatrungrit
 
Greenfields tech decisions
Greenfields tech decisionsGreenfields tech decisions
Greenfields tech decisions
Trent Hornibrook
 
Coscup
CoscupCoscup
Coscup
Giivee The
 

What's hot (20)

Continous integration and delivery for single page applications
Continous integration and delivery for single page applicationsContinous integration and delivery for single page applications
Continous integration and delivery for single page applications
 
CI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsCI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page Apps
 
BP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
BP-10 Keeping Your Sanity – Rapid Development & Deployment ToolsBP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
BP-10 Keeping Your Sanity – Rapid Development & Deployment Tools
 
GitBucket: The perfect Github clone by Scala
GitBucket: The perfect Github clone by ScalaGitBucket: The perfect Github clone by Scala
GitBucket: The perfect Github clone by Scala
 
OpenStack Doc Overview for Boot Camp
OpenStack Doc Overview for Boot CampOpenStack Doc Overview for Boot Camp
OpenStack Doc Overview for Boot Camp
 
Puppet Release Workflows at Jive Software
Puppet Release Workflows at Jive SoftwarePuppet Release Workflows at Jive Software
Puppet Release Workflows at Jive Software
 
Kubernetes and AWS Lambda can play nicely together
Kubernetes and AWS Lambda can play nicely togetherKubernetes and AWS Lambda can play nicely together
Kubernetes and AWS Lambda can play nicely together
 
Akkurate Akka
Akkurate AkkaAkkurate Akka
Akkurate Akka
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 
Scala for java developers 6 may 2017 - yeni
Scala for java developers   6 may 2017 - yeniScala for java developers   6 may 2017 - yeni
Scala for java developers 6 may 2017 - yeni
 
Michelin Starred Cooking with Chef
Michelin Starred Cooking with ChefMichelin Starred Cooking with Chef
Michelin Starred Cooking with Chef
 
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
 
What is this cloud thing?
What is this cloud thing?What is this cloud thing?
What is this cloud thing?
 
KubeCon 2019 Recap (Parts 1-3)
KubeCon 2019 Recap (Parts 1-3)KubeCon 2019 Recap (Parts 1-3)
KubeCon 2019 Recap (Parts 1-3)
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill Sparks
 
Immutable infrastructure with Boxfuse
Immutable infrastructure with BoxfuseImmutable infrastructure with Boxfuse
Immutable infrastructure with Boxfuse
 
Docker in the Cloud
Docker in the CloudDocker in the Cloud
Docker in the Cloud
 
DrupalCon 2011 Highlight
DrupalCon 2011 HighlightDrupalCon 2011 Highlight
DrupalCon 2011 Highlight
 
Greenfields tech decisions
Greenfields tech decisionsGreenfields tech decisions
Greenfields tech decisions
 
Coscup
CoscupCoscup
Coscup
 

Viewers also liked

The passive voice
The passive voiceThe passive voice
The passive voice
Teresa Polonio Parras
 
Teori pembelajaran
Teori pembelajaranTeori pembelajaran
Teori pembelajaran
munir_ahmad
 
Quis sekda satu
Quis sekda satuQuis sekda satu
Quis sekda satu
munir_ahmad
 
Gartner 2015 10 techtrendsthrough2015
Gartner 2015 10 techtrendsthrough2015Gartner 2015 10 techtrendsthrough2015
Gartner 2015 10 techtrendsthrough2015blt5
 
Composing Project Archetyps with SBT AutoPlugins
Composing Project Archetyps with SBT AutoPluginsComposing Project Archetyps with SBT AutoPlugins
Composing Project Archetyps with SBT AutoPlugins
Mark Schaake
 
U.S. Constitution - Preamble
U.S. Constitution - PreambleU.S. Constitution - Preamble
U.S. Constitution - Preamblestacyscarroll
 
Sejarah perkembangan teori admin
Sejarah perkembangan teori adminSejarah perkembangan teori admin
Sejarah perkembangan teori admin
munir_ahmad
 

Viewers also liked (9)

The passive voice
The passive voiceThe passive voice
The passive voice
 
Teori pembelajaran
Teori pembelajaranTeori pembelajaran
Teori pembelajaran
 
Quis sekda satu
Quis sekda satuQuis sekda satu
Quis sekda satu
 
Gartner 2015 10 techtrendsthrough2015
Gartner 2015 10 techtrendsthrough2015Gartner 2015 10 techtrendsthrough2015
Gartner 2015 10 techtrendsthrough2015
 
Composing Project Archetyps with SBT AutoPlugins
Composing Project Archetyps with SBT AutoPluginsComposing Project Archetyps with SBT AutoPlugins
Composing Project Archetyps with SBT AutoPlugins
 
The passive voice
The passive voiceThe passive voice
The passive voice
 
Constitutional
ConstitutionalConstitutional
Constitutional
 
U.S. Constitution - Preamble
U.S. Constitution - PreambleU.S. Constitution - Preamble
U.S. Constitution - Preamble
 
Sejarah perkembangan teori admin
Sejarah perkembangan teori adminSejarah perkembangan teori admin
Sejarah perkembangan teori admin
 

Similar to Archetype autoplugins

Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
Kevin Webber
 
Continuous Automated Deployment with Apache ACE
Continuous Automated Deployment with Apache ACEContinuous Automated Deployment with Apache ACE
Continuous Automated Deployment with Apache ACE
Jan Willem Janssen
 
Boilerplates: Step up your Web Development Process
Boilerplates: Step up your Web Development ProcessBoilerplates: Step up your Web Development Process
Boilerplates: Step up your Web Development Process
Fibonalabs
 
OpenStack Documentation Projects and Processes
OpenStack Documentation Projects and ProcessesOpenStack Documentation Projects and Processes
OpenStack Documentation Projects and Processes
Anne Gentle
 
Infrastructure as Code on Azure: Show your Bicep!
Infrastructure as Code on Azure: Show your Bicep!Infrastructure as Code on Azure: Show your Bicep!
Infrastructure as Code on Azure: Show your Bicep!
Marco Obinu
 
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Peter Procházka
 
OSGi Community Event 2010 - Dependencies, dependencies, dependencies
OSGi Community Event 2010 - Dependencies, dependencies, dependenciesOSGi Community Event 2010 - Dependencies, dependencies, dependencies
OSGi Community Event 2010 - Dependencies, dependencies, dependencies
mfrancis
 
Open service broker API with Azure Kubernetes Services
Open service broker API with Azure Kubernetes ServicesOpen service broker API with Azure Kubernetes Services
Open service broker API with Azure Kubernetes Services
Jorge Arteiro
 
Measure and Increase Developer Productivity with Help of Serverless at JCON 2...
Measure and Increase Developer Productivity with Help of Serverless at JCON 2...Measure and Increase Developer Productivity with Help of Serverless at JCON 2...
Measure and Increase Developer Productivity with Help of Serverless at JCON 2...
Vadym Kazulkin
 
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Mike Broberg
 
habitat at docker bud
habitat at docker budhabitat at docker bud
habitat at docker bud
Mandi Walls
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Railselliando dias
 
Crowbar2 update
Crowbar2 updateCrowbar2 update
Crowbar2 updateosonoi
 
Kubecon 2019 - Promoting Kubernetes CI/CD to the Next Level
Kubecon 2019 - Promoting Kubernetes CI/CD to the Next LevelKubecon 2019 - Promoting Kubernetes CI/CD to the Next Level
Kubecon 2019 - Promoting Kubernetes CI/CD to the Next Level
Tim Pouyer
 
AKS - Azure Kubernetes Services - kubernetes meetup may 2018
AKS - Azure Kubernetes Services  - kubernetes meetup may 2018AKS - Azure Kubernetes Services  - kubernetes meetup may 2018
AKS - Azure Kubernetes Services - kubernetes meetup may 2018
Jorge Arteiro
 
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
rodburns
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
Rafe Colton
 
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Peter Procházka
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
Docker, Inc.
 
Introduction Apache Kafka
Introduction Apache KafkaIntroduction Apache Kafka
Introduction Apache Kafka
Joe Stein
 

Similar to Archetype autoplugins (20)

Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Continuous Automated Deployment with Apache ACE
Continuous Automated Deployment with Apache ACEContinuous Automated Deployment with Apache ACE
Continuous Automated Deployment with Apache ACE
 
Boilerplates: Step up your Web Development Process
Boilerplates: Step up your Web Development ProcessBoilerplates: Step up your Web Development Process
Boilerplates: Step up your Web Development Process
 
OpenStack Documentation Projects and Processes
OpenStack Documentation Projects and ProcessesOpenStack Documentation Projects and Processes
OpenStack Documentation Projects and Processes
 
Infrastructure as Code on Azure: Show your Bicep!
Infrastructure as Code on Azure: Show your Bicep!Infrastructure as Code on Azure: Show your Bicep!
Infrastructure as Code on Azure: Show your Bicep!
 
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
 
OSGi Community Event 2010 - Dependencies, dependencies, dependencies
OSGi Community Event 2010 - Dependencies, dependencies, dependenciesOSGi Community Event 2010 - Dependencies, dependencies, dependencies
OSGi Community Event 2010 - Dependencies, dependencies, dependencies
 
Open service broker API with Azure Kubernetes Services
Open service broker API with Azure Kubernetes ServicesOpen service broker API with Azure Kubernetes Services
Open service broker API with Azure Kubernetes Services
 
Measure and Increase Developer Productivity with Help of Serverless at JCON 2...
Measure and Increase Developer Productivity with Help of Serverless at JCON 2...Measure and Increase Developer Productivity with Help of Serverless at JCON 2...
Measure and Increase Developer Productivity with Help of Serverless at JCON 2...
 
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
 
habitat at docker bud
habitat at docker budhabitat at docker bud
habitat at docker bud
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Rails
 
Crowbar2 update
Crowbar2 updateCrowbar2 update
Crowbar2 update
 
Kubecon 2019 - Promoting Kubernetes CI/CD to the Next Level
Kubecon 2019 - Promoting Kubernetes CI/CD to the Next LevelKubecon 2019 - Promoting Kubernetes CI/CD to the Next Level
Kubecon 2019 - Promoting Kubernetes CI/CD to the Next Level
 
AKS - Azure Kubernetes Services - kubernetes meetup may 2018
AKS - Azure Kubernetes Services  - kubernetes meetup may 2018AKS - Azure Kubernetes Services  - kubernetes meetup may 2018
AKS - Azure Kubernetes Services - kubernetes meetup may 2018
 
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
SC20 SYCL and C++ Birds of a Feather 19th Nov 2020
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
 
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
Are Frameworks Evil? Should you care about Sitecore SXA and JSS?
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
 
Introduction Apache Kafka
Introduction Apache KafkaIntroduction Apache Kafka
Introduction Apache Kafka
 

Archetype autoplugins

  • 1.
  • 3. How many SBT projects does your team maintain?
  • 4.
  • 5. Archetype | ˈärk(i)ˌtīp | • a very typical example of a certain person or thing (Apple Dictionary) • a statement, pattern of behavior, or prototype which other statements, patterns of behavior, and objects copy or emulate (Wikipedia)
  • 6. Archetype | ˈärk(i)ˌtīp | • a very typical example of a certain person or thing (Apple Dictionary) • a statement, pattern of behavior, or prototype which other statements, patterns of behavior, and objects copy or emulate (Wikipedia)
  • 7. Composing Project Archetypes with SBT AutoPlugins Mark Schaake allenai.org “contribute to humanity through high-impact AI research and engineering”
  • 8. Composing Project Archetypes with SBT AutoPlugins Mark Schaake allenai.org “contribute to humanity through high-impact AI research and engineering”
  • 9. Combatting Multiple Build Maintenance Hell with Archetype AutoPlugins Mark Schaake allenai.org “contribute to humanity through high-impact AI research and engineering”
  • 10. “When you have very limited visibility and control over many project builds to the point where you feel paralyzed to maintaining cross- project consistency.” (Multiple Build Maintenance Hell) MBMH • visibility: what libraries, plugins, versions? • control: how to enforce team standards, upgrades? • consistency: minimize context switching
  • 11. SOA, Inc. • SOA architecture • Scala, Akka, Spray
  • 12. Svc A Plugins Projects Dependencies
  • 13. Svc A Plugins Projects Dependencies packager 0.6.0 scalariform 1.3 // native packager for generating deployable artifacts addSbtPlugin( "com.typesafe.sbt" % "sbt-native-packager" % "0.6.0")   // format our code in SBT instead of our editors addSbtPlugin( "com.typesafe.sbt" % "sbt-scalariform" % "1.3.0") project/plugins.sbt
  • 14. Svc A Plugins Projects Dependencies packager 0.6.0 scalariform 1.3 // native packager for generating deployable artifacts addSbtPlugin( "com.typesafe.sbt" % "sbt-native-packager" % "0.6.0")   // format our code in SBT instead of our editors addSbtPlugin( "com.typesafe.sbt" % "sbt-scalariform" % "1.3.0") project/plugins.sbt akka 2.3.2 spray 1.3.0 dispatch 0.11.1 scala 2.10.2 organization := "com.soa"   name := "service-a"   scalaVersion := "2.10.2"   libraryDependencies ++= Seq( "io.spray" % "spray-can" % "1.3.0", "io.spray" % "spray-routing" % "1.3.0", "com.typesafe.akka" %% "akka-actor" % "2.3.2", "com.typesafe.akka" %% "akka-slf4j" % "2.3.2", "net.databinder" %% "dispatch-core" % "0.11.1", "ch.qos.logback" % "logback-classic" % "1.1.2" ... ) build.sbt
  • 15. // native packager for generating deployable artifacts addSbtPlugin( "com.typesafe.sbt" % "sbt-native-packager" % "0.6.0")   // format our code in SBT instead of our editors addSbtPlugin( "com.typesafe.sbt" % "sbt-scalariform" % "1.3.0") // native packager for generating deployable artifacts addSbtPlugin( "com.typesafe.sbt" % "sbt-native-packager" % "0.6.0")   // format our code in SBT instead of our editors addSbtPlugin( "com.typesafe.sbt" % "sbt-scalariform" % “1.3.0") addSbtPlugin( “org.scalastyle" %% "scalastyle" % “0.5.0") Svc A Plugins Projects Dependencies akka 2.3.2 spray 1.3.0 dispatch 0.11.1Svc B akka 2.3.4 spray 1.3.1 scala 2.10.2 scala 2.11.1 packager 0.6.0 scalastyle scalariform 1.3 organization := "com.soa"   name := "service-a"   scalaVersion := "2.10.2"   libraryDependencies ++= Seq( "io.spray" % "spray-can" % "1.3.0", "io.spray" % "spray-routing" % "1.3.0", "com.typesafe.akka" %% "akka-actor" % "2.3.2", "com.typesafe.akka" %% "akka-slf4j" % "2.3.2", "net.databinder" %% "dispatch-core" % "0.11.1", "ch.qos.logback" % "logback-classic" % "1.1.2" ... ) build.sbt organization := "com.soa"   name := "service-b"   scalaVersion := "2.11.1"   libraryDependencies ++= Seq( "io.spray" % "spray-can" % "1.3.1", "io.spray" % "spray-routing" % "1.3.1", "com.typesafe.akka" %% "akka-actor" % "2.3.4", "com.typesafe.akka" %% "akka-slf4j" % "2.3.4", "net.databinder" %% "dispatch-core" % "0.11.1", "ch.qos.logback" % "logback-classic" % "1.1.2" ... ) project/plugins.sbt
  • 16. Svc A Plugins Projects Dependencies akka 2.3.2 spray 1.3.0 dispatch 0.11.1Svc B akka 2.3.4 spray-client 1.3.2 spray 1.3.1 Svc C scala 2.10.2 scala 2.11.1 akka 2.3.6 spray 1.3.2 packager 0.6.0 scalastyle packager 0.7.2 scalariform 1.3 scalariform 1.5
  • 17. Svc A Plugins Projects Dependencies akka 2.3.2 spray 1.3.0 dispatch 0.11.1Svc B akka 2.3.4 spray-client 1.3.2 spray 1.3.1 Svc C scala 2.10.2 scala 2.11.1 akka 2.3.6 spray 1.3.2 Svc D packager 0.6.0 scalastyle packager 0.7.2 scalariform 1.3 scalariform 1.5
  • 18. Svc A Plugins Projects Dependencies akka 2.3.2 spray 1.3.0 dispatch 0.11.1Svc B akka 2.3.4 spray-client 1.3.2 spray 1.3.1 Svc C scala 2.10.2 scala 2.11.1 akka 2.3.6 spray 1.3.2 Svc D packager 0.6.0 scalastyle packager 0.7.2 scalariform 1.3 scalariform 1.5 … Lib X Lib Y CLI Z scopt … sbt-release assembly
  • 19. project/plugins.sbt 6 build.sbt 50 Project build LOC 56 x 26 projects = 1,456 LOC! … … Avg Project Build LOC and mostly boilerplate
  • 20. project/plugins.sbt 6 build.sbt 50 Project build LOC 56 x 26 projects = 1,456 LOC! … … Avg Project Build LOC and mostly boilerplate MBMH!
  • 23. BuildLOC 500 1,000 1,500 2,000 2,500 Projects 15 30 45 60 Jan March May July Sept Nov Projects Build LOC MBMH and MBMH Yay!
  • 25. Solving • Maximize consistency across projects MBMH
  • 26. Solving • Maximize consistency across projects • Minimize build complexity (LOC) MBMH
  • 27. Solving • Maximize consistency across projects • Minimize build complexity (LOC) • Maximize agility to evolve standards MBMH
  • 28. Solving • Maximize consistency across projects • Minimize build complexity (LOC) • Maximize agility to evolve standards • Allow for stragglers (don’t force upgrades) MBMH
  • 29. Solving • Maximize consistency across projects • Minimize build complexity (LOC) • Maximize agility to evolve standards • Allow for stragglers (don’t force upgrades) • Easy build upgrade path MBMH
  • 31. Other Considerations • Archetype settings shared by similar projects
  • 32. Other Considerations • Archetype settings shared by similar projects • Core settings common to all projects
  • 33. Other Considerations • Archetype settings shared by similar projects • Core settings common to all projects • Formatting and Style
  • 34. Other Considerations • Archetype settings shared by similar projects • Core settings common to all projects • Formatting and Style • Generate Git version resource
  • 36. Solution: Archetype SBT Plugins • Projects enable a single (versioned) archetype plugin
  • 37. Solution: Archetype SBT Plugins • Projects enable a single (versioned) archetype plugin • Archetype plugin provides: • core build settings (style, scala version, etc.)
  • 38. Solution: Archetype SBT Plugins • Projects enable a single (versioned) archetype plugin • Archetype plugin provides: • core build settings (style, scala version, etc.) • archetype build settings (deploy, publish, etc.)
  • 39. Solution: Archetype SBT Plugins • Projects enable a single (versioned) archetype plugin • Archetype plugin provides: • core build settings (style, scala version, etc.) • archetype build settings (deploy, publish, etc.) • archetype dependencies (e.g. spray, akka, scopt)
  • 40. Solution: Archetype SBT Plugins • Projects enable a single (versioned) archetype plugin • Archetype plugin provides: • core build settings (style, scala version, etc.) • archetype build settings (deploy, publish, etc.) • archetype dependencies (e.g. spray, akka, scopt) • Project upgraded upgraded by upgrading plugin version
  • 41. Svc A Plugins Projects Dependencies akka 2.3.2 spray 1.3.0 dispatch 0.11.1Svc B akka 2.3.4 spray-client 1.3.2 spray 1.3.1 Svc C scala 2.10.2 scala 2.11.1 akka 2.3.6 spray 1.3.2 Svc D packager 0.6.0 scalastyle packager 0.7.2 scalariform 1.3 scalariform 1.5 Web Services
  • 42. web-service 1.0 Svc A akka 2.3.2 spray 1.3.0 dispatch 0.11.1 Svc B Svc C scala 2.10.2 Svc D packager 0.6.0 scalariform 1.3 web-service 2.0 akka 2.3.4 spray 1.3.1 dispatch 0.11.1 scala 2.11.1packager 0.6.0 scalariform 1.3 scalastyle web-service 2.1 akka 2.3.6 spray 1.3.2 spray-client 1.3.2 scala 2.11.1packager 0.7.2 scalariform 1.5 scalastyle <app-specific dependencies> Plugins Projects Dependencies Web Services sbt-revolver sbt-revolver sbt-revolver
  • 43. web-service 1.0 Svc A Archetype Plugins Projects Svc B Svc C Svc D web-service 2.0 web-service 2.1 library 1.0 library 1.1 cli 1.0 Lib X Lib Y CLI Z … … … web-app 1.0 App W …
  • 44. web-service 1.0 Svc A Archetype Plugins Projects Svc B Svc C Svc D web-service 2.0 web-service 2.1 library 1.0 library 1.1 cli 1.0 Lib X Lib Y CLI Z … … … web-app 1.0 App W …
  • 45. Before Archetypes import com.typesafe.sbt.SbtNativePackager._ import org.scalastyle.sbt.ScalastylePlugin scalaVersion := "2.10.2" name := "Proj B" Revolver.settings scalariformSettings ScalariformKeys.preferences := ScalariformKeys.preferences.value .setPreference(DoubleIndentClassDeclaration, true) .setPreference(MultilineScaladocCommentsStartOnFirstLine, true) .setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true) ScalastylePlugin.Settings libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.3.1", "io.spray" % "spray-can" % "1.3.2", "io.spray" % "spray-routing" % "1.3.2", "io.spray" % "spray-cace" % "1.3.2", "io.spray" % "spray-json" % "1.2.6", "net.databinder.dispatch" %% "dispatch-core" % "0.11.0" ) … addSbtPlugin("com.github.gzeitz" % "sbt-release" % "0.8") addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1") addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.4") addSbtPlugin("io.spray" % "sbt-revolver" % "0.6.2") addSbtPlugin("org.allenai.plugins" % "version-injector" % "0.2.2") addSbtPlugin("org.allenai.plugins" % "publisher" % "0.2.2")
  • 46. Before Archetypes import com.typesafe.sbt.SbtNativePackager._ import org.scalastyle.sbt.ScalastylePlugin scalaVersion := "2.10.2" name := "Proj B" Revolver.settings scalariformSettings ScalariformKeys.preferences := ScalariformKeys.preferences.value .setPreference(DoubleIndentClassDeclaration, true) .setPreference(MultilineScaladocCommentsStartOnFirstLine, true) .setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true) ScalastylePlugin.Settings libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.3.1", "io.spray" % "spray-can" % "1.3.2", "io.spray" % "spray-routing" % "1.3.2", "io.spray" % "spray-cace" % "1.3.2", "io.spray" % "spray-json" % "1.2.6", "net.databinder.dispatch" %% "dispatch-core" % "0.11.0" ) … addSbtPlugin("com.github.gzeitz" % "sbt-release" % "0.8") addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1") addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.4") addSbtPlugin("io.spray" % "sbt-revolver" % "0.6.2") addSbtPlugin("org.allenai.plugins" % "version-injector" % "0.2.2") addSbtPlugin("org.allenai.plugins" % "publisher" % "0.2.2") name := "Proj B" enablePlugins(WebServicePlugin) addSbtPlugin("org.allenai.plugins" % "plugins" % “1.0”) After Archetypes LOC Before 56 LOC After 3 LOC Reduction 95%
  • 48. Implementing Archetype Plugins • How to wrap / depend on other plugins?
  • 49. Implementing Archetype Plugins • How to wrap / depend on other plugins? • How to include core settings in each archetype?
  • 50. ArchetypePlugins What AI2 Needed Library Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Web App libraryDependencies: - ai2Webapp settings: - npm:* - reStart dependsOn npm:build - universal:mappings + npm:target CLI libraryDependencies: - scopt
  • 51. ArchetypePlugins What AI2 Needed Library Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Web App libraryDependencies: - ai2Webapp settings: - npm:* - reStart dependsOn npm:build - universal:mappings + npm:target CLI libraryDependencies: - scopt AuxiliaryPlugins Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Deploy wrapped plugins: - sbt-native-packager command: - deploy Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Release wrapped plugins: - sbt-release settings: - custom versioning NodeJs commands: - npm <args> - npm:install - npm:build - npm:test - nom:clean settings: - npm:nodeProjectDir - npm:nodeProjectTarget - npm:buildEnvironment - nom:environment Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle
  • 52. (Vanilla) SBT Plugins? • Loosely defined API • What are the right conventions?
  • 53. Adding Popular SBT Plugin Settings “To add the default plugin settings, add the following to your build.sbt…”
  • 54. Adding Popular SBT Plugin Settings “To add the default plugin settings, add the following to your build.sbt…” import com.typesafe.sbt.SbtNativePackager._ import NativePackagerKeys._ packageArchetype.java_application sbt-native-packager org.scalastyle.sbt.ScalastylePlugin.Settings sbt-scalastyle scalariformSettings sbt-scalariform Revolver.settings sbt-revolver
  • 55. SBT AutoPlugins • The new Plugin standard (since SBT 0.13.5)
  • 56. SBT AutoPlugins • The new Plugin standard (since SBT 0.13.5) • Well-defined plugin API
  • 57. SBT AutoPlugins • The new Plugin standard (since SBT 0.13.5) • Well-defined plugin API • Less need for conventions
  • 58. SBT AutoPlugins • The new Plugin standard (since SBT 0.13.5) • Well-defined plugin API • Less need for conventions • Killer feature: can compose plugins via `requires`
  • 59. abstract class AutoPlugin { … /** When this AutoPlugin is enabled, all required * plugins will also be enabled automatically prior * to enabling this AutoPlugin. */ def requires: Plugins = empty /** The [[Setting]]s to add in the scope of each * project that activates this AutoPlugin. */ def projectSettings: Seq[Setting[_]] = Nil … } SBT AutoPlugins https://github.com/sbt/sbt/blob/0.13.7/main/src/main/scala/sbt/Plugins.scala
  • 60. Core Settings AutoPlugin object CoreSettingsPlugin extends AutoPlugin {   override def requires = StylePlugin && VersionInjectorPlugin   override def projectSettings = Seq( scalaVersion := CoreDependencies.defaultScalaVersion, scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation"), javacOptions ++= Seq("-source", "1.7", "-target", “1.7"), … ) } Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle
  • 61. Core Settings AutoPlugin When CoreSettingsPlugin is enabled… object CoreSettingsPlugin extends AutoPlugin {   override def requires = StylePlugin && VersionInjectorPlugin   override def projectSettings = Seq( scalaVersion := CoreDependencies.defaultScalaVersion, scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation"), javacOptions ++= Seq("-source", "1.7", "-target", “1.7"), … ) }
  • 62. Core Settings AutoPlugin 1. adds projectSettings from StylePlugin and VersionInjector When CoreSettingsPlugin is enabled… object CoreSettingsPlugin extends AutoPlugin {   override def requires = StylePlugin && VersionInjectorPlugin   override def projectSettings = Seq( scalaVersion := CoreDependencies.defaultScalaVersion, scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation"), javacOptions ++= Seq("-source", "1.7", "-target", “1.7"), … ) }
  • 63. Core Settings AutoPlugin 1. adds projectSettings from StylePlugin and VersionInjector 2. adds projectSettings from CoreSettings When CoreSettingsPlugin is enabled… object CoreSettingsPlugin extends AutoPlugin {   override def requires = StylePlugin && VersionInjectorPlugin   override def projectSettings = Seq( scalaVersion := CoreDependencies.defaultScalaVersion, scalacOptions ++= Seq("-target:jvm-1.7", "-Xlint", "-deprecation"), javacOptions ++= Seq("-source", "1.7", "-target", “1.7"), … ) }
  • 64. Composing an Archetype Plugin Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Deploy wrapped plugins: - sbt-native-packager command: - deploy Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle object WebServicePlugin extends AutoPlugin { override def requires = CoreSettingsPlugin && DeployPlugin override def projectSettings = Revolver.settings ++ Seq( libraryDependencies ++= Seq( akkaActor, akkaLogging, sprayCan, sprayRouting, sprayJson, allenAiCommon, allenAiTestkit % "test")) }
  • 65. Composing an Archetype Plugin Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Deploy wrapped plugins: - sbt-native-packager command: - deploy Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle object WebServicePlugin extends AutoPlugin { override def requires = CoreSettingsPlugin && DeployPlugin override def projectSettings = Revolver.settings ++ Seq( libraryDependencies ++= Seq( akkaActor, akkaLogging, sprayCan, sprayRouting, sprayJson, allenAiCommon, allenAiTestkit % "test")) }
  • 66. Composing an Archetype Plugin Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Deploy wrapped plugins: - sbt-native-packager command: - deploy Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle object WebServicePlugin extends AutoPlugin { override def requires = CoreSettingsPlugin && DeployPlugin override def projectSettings = Revolver.settings ++ Seq( libraryDependencies ++= Seq( akkaActor, akkaLogging, sprayCan, sprayRouting, sprayJson, allenAiCommon, allenAiTestkit % "test")) }
  • 67. Composing an Archetype Plugin Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Deploy wrapped plugins: - sbt-native-packager command: - deploy Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle object WebServicePlugin extends AutoPlugin { override def requires = CoreSettingsPlugin && DeployPlugin override def projectSettings = Revolver.settings ++ Seq( libraryDependencies ++= Seq( akkaActor, akkaLogging, sprayCan, sprayRouting, sprayJson, allenAiCommon, allenAiTestkit % "test")) } When WebServicePlugin is enabled…
  • 68. Composing an Archetype Plugin 1. Style and Versioning applied Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Deploy wrapped plugins: - sbt-native-packager command: - deploy Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle object WebServicePlugin extends AutoPlugin { override def requires = CoreSettingsPlugin && DeployPlugin override def projectSettings = Revolver.settings ++ Seq( libraryDependencies ++= Seq( akkaActor, akkaLogging, sprayCan, sprayRouting, sprayJson, allenAiCommon, allenAiTestkit % "test")) } When WebServicePlugin is enabled…
  • 69. Composing an Archetype Plugin 1. Style and Versioning applied 2. CoreSettings and Deploy applied Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Deploy wrapped plugins: - sbt-native-packager command: - deploy Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle object WebServicePlugin extends AutoPlugin { override def requires = CoreSettingsPlugin && DeployPlugin override def projectSettings = Revolver.settings ++ Seq( libraryDependencies ++= Seq( akkaActor, akkaLogging, sprayCan, sprayRouting, sprayJson, allenAiCommon, allenAiTestkit % "test")) } When WebServicePlugin is enabled…
  • 70. Composing an Archetype Plugin 1. Style and Versioning applied 2. CoreSettings and Deploy applied 3. WebService applied Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Deploy wrapped plugins: - sbt-native-packager command: - deploy Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle object WebServicePlugin extends AutoPlugin { override def requires = CoreSettingsPlugin && DeployPlugin override def projectSettings = Revolver.settings ++ Seq( libraryDependencies ++= Seq( akkaActor, akkaLogging, sprayCan, sprayRouting, sprayJson, allenAiCommon, allenAiTestkit % "test")) } When WebServicePlugin is enabled…
  • 71. ArchetypePluginsAuxiliaryPlugins Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle Deploy wrapped plugins: - sbt-native-packager command: - deploy
  • 72. ArchetypePluginsAuxiliaryPlugins Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle Release wrapped plugins: - sbt-release settings: - custom versioning Library Deploy wrapped plugins: - sbt-native-packager command: - deploy
  • 73. ArchetypePluginsAuxiliaryPlugins Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver CLI libraryDependencies: - scopt Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle Release wrapped plugins: - sbt-release settings: - custom versioning Library Deploy wrapped plugins: - sbt-native-packager command: - deploy
  • 74. ArchetypePluginsAuxiliaryPlugins Web Service libraryDependencies: - akka - spray - spray-json - typesafeConfig - ai2Common - ai2Testkit wrapped plugins: - sbt-revolver CLI libraryDependencies: - scopt Core Settings scalaVersion: 2.10.4 scalacOptions: … conflictManager: strict common library ModuleIDs - ai2Common, ai2Testkit, … - akka, spray, spray-json Versioning tasks: - injectVersion - injectArtifact - injectGit - gitCommitDate - gitRemotes - gitSha1 - gitDescribe Style wrapped plugins: - scalariform - scalastyle settings: - apply scalariform - apply scalastyle Release wrapped plugins: - sbt-release settings: - custom versioning Library Deploy wrapped plugins: - sbt-native-packager command: - deploy Web App libraryDependencies: - ai2Webapp settings: - npm:* - reStart dependsOn npm:build - universal:mappings + npm:target NodeJs commands: - npm <args> - npm:install - npm:build - npm:test - nom:clean settings: - npm:nodeProjectDir - npm:nodeProjectTarget - npm:buildEnvironment - nom:environment
  • 76. Resources • SBT docs - http://www.scala-sbt.org/0.13/docs/Plugins.html • Tutorial - http://mukis.de/pages/sbt-autoplugins-tutorial/ • AI2 sbt-plugins: https://github.com/allenai/sbt-plugins
  • 78. Project Archetype Recipe • Create a company “sbt-plugins” project • Wrap third-party plugins (scalariform, scalastyle, etc.) • Define a core settings AutoPlugin that enforces team standards • Define archetype plugins that require core settings and add in archetype-specific settings • Publish to Bintray and serve!