SlideShare une entreprise Scribd logo
1  sur  72
Télécharger pour lire hors ligne
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!

Contenu connexe

Tendances

Docker Bday #5, SF Edition: Introduction to Docker
Docker Bday #5, SF Edition: Introduction to DockerDocker Bday #5, SF Edition: Introduction to Docker
Docker Bday #5, SF Edition: Introduction to DockerDocker, Inc.
 
Intro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratchIntro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratchJohn Culviner
 
Building kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech TalkBuilding kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech TalkRed Hat Developers
 
Automate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOpsAutomate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOpsDaniel Oh
 
Container orchestration from theory to practice
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practiceDocker, Inc.
 
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and JenkinsContinuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and JenkinsMarcel Birkner
 
4K–Kubernetes with Knative, Kafka and Kamel
4K–Kubernetes with Knative, Kafka and Kamel 4K–Kubernetes with Knative, Kafka and Kamel
4K–Kubernetes with Knative, Kafka and Kamel Red Hat Developers
 
2016 - Continuously Delivering Microservices in Kubernetes using Jenkins
2016 - Continuously Delivering Microservices in Kubernetes using Jenkins2016 - Continuously Delivering Microservices in Kubernetes using Jenkins
2016 - Continuously Delivering Microservices in Kubernetes using Jenkinsdevopsdaysaustin
 
Spinnaker Summit 2019: Where are we heading? The Future of Continuous Delivery
Spinnaker Summit 2019: Where are we heading? The Future of Continuous DeliverySpinnaker Summit 2019: Where are we heading? The Future of Continuous Delivery
Spinnaker Summit 2019: Where are we heading? The Future of Continuous DeliveryAndrew Phillips
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDocker, Inc.
 
Docker 101 @KACST Saudi HPC 2016
Docker 101  @KACST Saudi HPC 2016Docker 101  @KACST Saudi HPC 2016
Docker 101 @KACST Saudi HPC 2016Walid Shaari
 
2016 Docker Palo Alto - CD with ECS and Jenkins
2016 Docker Palo Alto -  CD with ECS and Jenkins2016 Docker Palo Alto -  CD with ECS and Jenkins
2016 Docker Palo Alto - CD with ECS and JenkinsTracy Kennedy
 
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with SpinnakerSpinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with SpinnakerAndrew Phillips
 
An Introduction to Rancher
An Introduction to RancherAn Introduction to Rancher
An Introduction to RancherConner Swann
 

Tendances (20)

Docker Bday #5, SF Edition: Introduction to Docker
Docker Bday #5, SF Edition: Introduction to DockerDocker Bday #5, SF Edition: Introduction to Docker
Docker Bday #5, SF Edition: Introduction to Docker
 
Gradle
GradleGradle
Gradle
 
Intro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratchIntro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratch
 
Building kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech TalkBuilding kubectl plugins with Quarkus | DevNation Tech Talk
Building kubectl plugins with Quarkus | DevNation Tech Talk
 
Automate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOpsAutomate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOps
 
Container orchestration from theory to practice
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practice
 
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and JenkinsContinuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
 
4K–Kubernetes with Knative, Kafka and Kamel
4K–Kubernetes with Knative, Kafka and Kamel 4K–Kubernetes with Knative, Kafka and Kamel
4K–Kubernetes with Knative, Kafka and Kamel
 
JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Doc...
JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Doc...JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Doc...
JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Doc...
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
2016 - Continuously Delivering Microservices in Kubernetes using Jenkins
2016 - Continuously Delivering Microservices in Kubernetes using Jenkins2016 - Continuously Delivering Microservices in Kubernetes using Jenkins
2016 - Continuously Delivering Microservices in Kubernetes using Jenkins
 
Spinnaker Summit 2019: Where are we heading? The Future of Continuous Delivery
Spinnaker Summit 2019: Where are we heading? The Future of Continuous DeliverySpinnaker Summit 2019: Where are we heading? The Future of Continuous Delivery
Spinnaker Summit 2019: Where are we heading? The Future of Continuous Delivery
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
Docker 101 @KACST Saudi HPC 2016
Docker 101  @KACST Saudi HPC 2016Docker 101  @KACST Saudi HPC 2016
Docker 101 @KACST Saudi HPC 2016
 
Building with Gradle
Building with GradleBuilding with Gradle
Building with Gradle
 
Introduction to gradle
Introduction to gradleIntroduction to gradle
Introduction to gradle
 
2016 Docker Palo Alto - CD with ECS and Jenkins
2016 Docker Palo Alto -  CD with ECS and Jenkins2016 Docker Palo Alto -  CD with ECS and Jenkins
2016 Docker Palo Alto - CD with ECS and Jenkins
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
 
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with SpinnakerSpinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
Spinnaker Summit 2018: CI/CD Patterns for Kubernetes with Spinnaker
 
An Introduction to Rancher
An Introduction to RancherAn Introduction to Rancher
An Introduction to Rancher
 

En vedette

A Scala Corrections Library
A Scala Corrections LibraryA Scala Corrections Library
A Scala Corrections LibraryPaul Phillips
 
Lightning Talk: Running MongoDB on Docker for High Performance Deployments
Lightning Talk: Running MongoDB on Docker for High Performance DeploymentsLightning Talk: Running MongoDB on Docker for High Performance Deployments
Lightning Talk: Running MongoDB on Docker for High Performance DeploymentsMongoDB
 
Future of ai on the jvm
Future of ai on the jvmFuture of ai on the jvm
Future of ai on the jvmAdam Gibson
 
Effective Actors
Effective ActorsEffective Actors
Effective Actorsshinolajla
 
Scala Json Features and Performance
Scala Json Features and PerformanceScala Json Features and Performance
Scala Json Features and PerformanceJohn Nestor
 
Stateful Distributed Stream Processing
Stateful Distributed Stream ProcessingStateful Distributed Stream Processing
Stateful Distributed Stream ProcessingGyula Fóra
 
What We (Don't) Know About the Beginning of the Universe
What We (Don't) Know About the Beginning of the UniverseWhat We (Don't) Know About the Beginning of the Universe
What We (Don't) Know About the Beginning of the UniverseSean Carroll
 
Gifford Lecture One: Cosmos, Time, Memory
Gifford Lecture One: Cosmos, Time, MemoryGifford Lecture One: Cosmos, Time, Memory
Gifford Lecture One: Cosmos, Time, MemorySean Carroll
 

En vedette (8)

A Scala Corrections Library
A Scala Corrections LibraryA Scala Corrections Library
A Scala Corrections Library
 
Lightning Talk: Running MongoDB on Docker for High Performance Deployments
Lightning Talk: Running MongoDB on Docker for High Performance DeploymentsLightning Talk: Running MongoDB on Docker for High Performance Deployments
Lightning Talk: Running MongoDB on Docker for High Performance Deployments
 
Future of ai on the jvm
Future of ai on the jvmFuture of ai on the jvm
Future of ai on the jvm
 
Effective Actors
Effective ActorsEffective Actors
Effective Actors
 
Scala Json Features and Performance
Scala Json Features and PerformanceScala Json Features and Performance
Scala Json Features and Performance
 
Stateful Distributed Stream Processing
Stateful Distributed Stream ProcessingStateful Distributed Stream Processing
Stateful Distributed Stream Processing
 
What We (Don't) Know About the Beginning of the Universe
What We (Don't) Know About the Beginning of the UniverseWhat We (Don't) Know About the Beginning of the Universe
What We (Don't) Know About the Beginning of the Universe
 
Gifford Lecture One: Cosmos, Time, Memory
Gifford Lecture One: Cosmos, Time, MemoryGifford Lecture One: Cosmos, Time, Memory
Gifford Lecture One: Cosmos, Time, Memory
 

Similaire à Combatting Multiple Build Maintenance Hell with Archetype AutoPlugins

Archetype autoplugins
Archetype autopluginsArchetype autoplugins
Archetype autopluginsMark Schaake
 
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 ServicesJorge Arteiro
 
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 2018Jorge Arteiro
 
Managing Your Application Lifecycle on AWS: Continuous Integration and Deploy...
Managing Your Application Lifecycle on AWS: Continuous Integration and Deploy...Managing Your Application Lifecycle on AWS: Continuous Integration and Deploy...
Managing Your Application Lifecycle on AWS: Continuous Integration and Deploy...Amazon Web Services
 
Building a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger HuntBuilding a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger HuntAshley Roach
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
Introduction Apache Kafka
Introduction Apache KafkaIntroduction Apache Kafka
Introduction Apache KafkaJoe Stein
 
Continuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSContinuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSAmazon Web Services
 
GitHub's Latest: Automation and More
GitHub's Latest: Automation and MoreGitHub's Latest: Automation and More
GitHub's Latest: Automation and MoreAmazon Web Services
 
(SACON) Satish Sreenivasaiah - DevSecOps Tools and Beyond
(SACON) Satish Sreenivasaiah - DevSecOps Tools and Beyond(SACON) Satish Sreenivasaiah - DevSecOps Tools and Beyond
(SACON) Satish Sreenivasaiah - DevSecOps Tools and BeyondPriyanka Aash
 
Using and extending Alfresco Content Application
Using and extending Alfresco Content ApplicationUsing and extending Alfresco Content Application
Using and extending Alfresco Content ApplicationDenys Vuika
 
Continuous Automated Deployment with Apache ACE
Continuous Automated Deployment with Apache ACEContinuous Automated Deployment with Apache ACE
Continuous Automated Deployment with Apache ACEJan Willem Janssen
 
Dependencies, dependencies, dependencies
Dependencies, dependencies, dependenciesDependencies, dependencies, dependencies
Dependencies, dependencies, dependenciesMarcel Offermans
 
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, dependenciesmfrancis
 
OpenStack Documentation Projects and Processes
OpenStack Documentation Projects and ProcessesOpenStack Documentation Projects and Processes
OpenStack Documentation Projects and ProcessesAnne Gentle
 
Boost your productivity with Scala tooling!
Boost your productivity  with Scala tooling!Boost your productivity  with Scala tooling!
Boost your productivity with Scala tooling!MeriamLachkar1
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on RailsAvi Kedar
 

Similaire à Combatting Multiple Build Maintenance Hell with Archetype AutoPlugins (20)

Archetype autoplugins
Archetype autopluginsArchetype autoplugins
Archetype autoplugins
 
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
 
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
 
Versioning for Developers
Versioning for DevelopersVersioning for Developers
Versioning for Developers
 
Managing Your Application Lifecycle on AWS: Continuous Integration and Deploy...
Managing Your Application Lifecycle on AWS: Continuous Integration and Deploy...Managing Your Application Lifecycle on AWS: Continuous Integration and Deploy...
Managing Your Application Lifecycle on AWS: Continuous Integration and Deploy...
 
Building a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger HuntBuilding a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger Hunt
 
Sas 2015 event_driven
Sas 2015 event_drivenSas 2015 event_driven
Sas 2015 event_driven
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Introduction Apache Kafka
Introduction Apache KafkaIntroduction Apache Kafka
Introduction Apache Kafka
 
Continuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWSContinuous Integration and Deployment Best Practices on AWS
Continuous Integration and Deployment Best Practices on AWS
 
GitHub's Latest: Automation and More
GitHub's Latest: Automation and MoreGitHub's Latest: Automation and More
GitHub's Latest: Automation and More
 
(SACON) Satish Sreenivasaiah - DevSecOps Tools and Beyond
(SACON) Satish Sreenivasaiah - DevSecOps Tools and Beyond(SACON) Satish Sreenivasaiah - DevSecOps Tools and Beyond
(SACON) Satish Sreenivasaiah - DevSecOps Tools and Beyond
 
Using and extending Alfresco Content Application
Using and extending Alfresco Content ApplicationUsing and extending Alfresco Content Application
Using and extending Alfresco Content Application
 
Continuous Automated Deployment with Apache ACE
Continuous Automated Deployment with Apache ACEContinuous Automated Deployment with Apache ACE
Continuous Automated Deployment with Apache ACE
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
 
Dependencies, dependencies, dependencies
Dependencies, dependencies, dependenciesDependencies, dependencies, dependencies
Dependencies, dependencies, dependencies
 
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
 
OpenStack Documentation Projects and Processes
OpenStack Documentation Projects and ProcessesOpenStack Documentation Projects and Processes
OpenStack Documentation Projects and Processes
 
Boost your productivity with Scala tooling!
Boost your productivity  with Scala tooling!Boost your productivity  with Scala tooling!
Boost your productivity with Scala tooling!
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 

Dernier

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 

Dernier (20)

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 

Combatting Multiple Build Maintenance Hell with Archetype AutoPlugins

  • 1. Composing Project Archetypes with SBT AutoPlugins Mark Schaake allenai.org “contribute to humanity through high-impact AI research and engineering”
  • 2. Composing Project Archetypes with SBT AutoPlugins Mark Schaake allenai.org “contribute to humanity through high-impact AI research and engineering”
  • 3. Combatting Multiple Build Maintenance Hell with Archetype AutoPlugins Mark Schaake allenai.org “contribute to humanity through high-impact AI research and engineering”
  • 4. “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
  • 5. SOA, Inc. • SOA architecture • Scala, Akka, Spray
  • 6. Svc A Plugins Projects Dependencies
  • 7. 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
  • 8. 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
  • 9. // 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
  • 10. 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
  • 11. 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
  • 12. 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
  • 13. project/plugins.sbt 6 build.sbt 50 Project build LOC 56 x 26 projects = 1,456 LOC! … … Avg Project Build LOC and mostly boilerplate
  • 14. 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!
  • 17. 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!
  • 19. Solving • Maximize consistency across projects MBMH
  • 20. Solving • Maximize consistency across projects • Minimize build complexity (LOC) MBMH
  • 21. Solving • Maximize consistency across projects • Minimize build complexity (LOC) • Maximize agility to evolve standards MBMH
  • 22. Solving • Maximize consistency across projects • Minimize build complexity (LOC) • Maximize agility to evolve standards • Allow for stragglers (don’t force upgrades) MBMH
  • 23. 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
  • 25. Other Considerations • Archetype settings shared by similar projects
  • 26. Other Considerations • Archetype settings shared by similar projects • Core settings common to all projects
  • 27. Other Considerations • Archetype settings shared by similar projects • Core settings common to all projects • Formatting and Style
  • 28. Other Considerations • Archetype settings shared by similar projects • Core settings common to all projects • Formatting and Style • Generate Git version resource
  • 30. Solution: Archetype SBT Plugins • Projects enable a single (versioned) archetype plugin
  • 31. Solution: Archetype SBT Plugins • Projects enable a single (versioned) archetype plugin • Archetype plugin provides: • core build settings (style, scala version, etc.)
  • 32. 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.)
  • 33. 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)
  • 34. 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
  • 35. 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
  • 36. 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
  • 37. 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 …
  • 38. 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 …
  • 39. 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")
  • 40. 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%
  • 42. Implementing Archetype Plugins • How to wrap / depend on other plugins?
  • 43. Implementing Archetype Plugins • How to wrap / depend on other plugins? • How to include core settings in each archetype?
  • 44. 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
  • 45. 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
  • 46. (Vanilla) SBT Plugins? • Loosely defined API • What are the right conventions?
  • 47. Adding Popular SBT Plugin Settings “To add the default plugin settings, add the following to your build.sbt…”
  • 48. 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
  • 49. SBT AutoPlugins • The new Plugin standard (since SBT 0.13.5)
  • 50. SBT AutoPlugins • The new Plugin standard (since SBT 0.13.5) • Well-defined plugin API
  • 51. SBT AutoPlugins • The new Plugin standard (since SBT 0.13.5) • Well-defined plugin API • Less need for conventions
  • 52. 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`
  • 53. 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
  • 54. 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
  • 55. 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"), … ) }
  • 56. 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"), … ) }
  • 57. 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"), … ) }
  • 58. 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")) }
  • 59. 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")) }
  • 60. 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")) }
  • 61. 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…
  • 62. 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…
  • 63. 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…
  • 64. 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…
  • 65. 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
  • 66. 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
  • 67. 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
  • 68. 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
  • 70. 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
  • 72. 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!