Building SBT Plugins Mads Hartmann Jensen @mads_hartmann http://mads379.github.com/ Code shown in presentation: https://github.com/mads379/sbt-plugin-examples Friday, January 27, 12

Agenda

The Simple Steps • Setting up your build definition • Implementing your plugin • Running it

Friday, January 27, 12

Setting up your build definition

In Your build.sbt file sbtPlugin := true name := "example-plugin" organization := "org.example"

Friday, January 27, 12

Implementing your plugin

Two ways to do it • “A plugin extends the build definition, most commonly by adding new settings”

• Will show • A plugin that provides a command • A plugin that provides some settings • A plugin with tab-completion Friday, January 27, 12

Implementing your plugin

Command Plugin

• For when you don’t need customization

Friday, January 27, 12

Implementing your plugin

Command Plugin import sbt._ import Keys._ object CommandPlugin extends Plugin { override lazy val settings = Seq(commands += myCommand) lazy val myCommand = Command.command("hello") { (state: State) => println("Hi there!") state } }

Friday, January 27, 12

Implementing your plugin

Command Plugin • In

~/.sbt/plugins/build.sbt

or

/project/build.sbt

addSbtPlugin("com.sidewayscoding" % "settings-plugin" % "0.1")

Friday, January 27, 12

Implementing your plugin

Command Plugin • For local development (trail/error) create a project with the build definition: /project/project/build.scala import sbt._ import Keys._ object Playground extends Build { val commandPlugin = RootProject(file("../../command-plugin")) lazy val root = Project(id = "playground", base = file(".")) .dependsOn(commandPlugin) }

Friday, January 27, 12

Implementing your plugin

Command Plugin

Demo Friday, January 27, 12

Implementing your plugin

Settings Plugin

• Useful when your plugin is customizable

Friday, January 27, 12

Implementing your plugin

Settings Plugin

import sbt._ object SettingsPlugin extends Plugin { val newTask = TaskKey[Unit]("new-task") val newSetting = SettingKey[String]("new-setting") val newSettings = Seq( newSetting := "test", newTask <<= newSetting map { str => println(str) } ) }

Friday, January 27, 12

Running it

Settings: Using it • In

~/.sbt/plugins/build.sbt

or

/project/build.sbt

addSbtPlugin("com.sidewayscoding" % "settings-plugin" % "0.1")

• In

/build.sbt

seq( SettingsPlugin.newSettings : _*) newSetting := "light"

Friday, January 27, 12

Running it

Settings: Using it

Demo Friday, January 27, 12

Implementing your plugin

Tab-completion

• Parsing input and providing tab-completions through Parser Combinators

Friday, January 27, 12

Implementing your plugin

import import import import import

Tab-completion

sbt._ Keys._ Defaults._ complete.DefaultParsers._ complete.{ Parser }

object ParserPlugin extends Plugin { override lazy val settings = Seq(commands += cmd) lazy val cmd = Command("parserCmd")(_ => parser)(action _) type parseResult = ... lazy val parser: Parser[parseResult] = ... def action(st: State, parsed: parseResult): State = ... }

Friday, January 27, 12

Implementing your plugin

Tab-completion

Demo Friday, January 27, 12

Building SBT Plugins - scala-phase.org

Page 5. Command Plugin. • For when you don't need customization. Implementing your plugin. Friday, January 27, 12. Page 6. Command Plugin import sbt._.

102KB Sizes 0 Downloads 210 Views

Recommend Documents

Hudson plugins -
Schedule : Whenever developer commit changes info source repo. ... Run static analysis tools again when finishing development and ..... Android Issues. 4.

SBT Peon GK.pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying.

SBT This Year.pdf
Page 1 of 1. Jan Mar May Jul Sep Nov Jan. 10 15 20 25. Scripps Pier SBT (°C) In 2018. Date. Temperature (°C). Record High. All Time Average. Record Low. 2018 (Preliminary). Manual Shore Station Program. California State Parks Division of Boating an

Hudson plugins -
Put your own JDK label(e.g : jdk 1.6.0_25) in the “name” field. 3. Put JDK path in JAVA_HOME(e.g ..... 2. 02(Severe). 40. Android Issues. 4. Denial of Service. 3.

SBI-SBT Merger.pdf
STATE BANK BHAVAN,MADAME CAMA ROAD,MUMBAI-4000021,. REPRESENTED ... R7,R8 BY ADV. SRI.V.G. ... Main menu. Displaying SBI-SBT Merger.pdf.

SBT RTGS-NEFT Application Form.pdf
www.myschoolchildren.com. Muat turun (percuma) kertas soalan lain di : Page 1 of 1. SBT RTGS-NEFT Application Form.pdf. SBT RTGS-NEFT Application ...

SBT RTGS-NEFT Application Form.pdf
SBT RTGS-NEFT Application Form.pdf. SBT RTGS-NEFT Application Form.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying SBT RTGS-NEFT ...

Plugins for fl
Pdf greek book.Viper gtsenglish.With similar. sentiments, Momaday observes that, ... Deftones 2012 flac. Labyrinth dovetutto è possibile.Nas newalbum2015.

plugins chrome pdf viewer
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. plugins chrome ...

Wordpress SEO Plugins Best.pdf
https://www.diigo.com/user/seoultimateplus. Page 3 of 6. Wordpress SEO Plugins Best.pdf. Wordpress SEO Plugins Best.pdf. Open. Extract. Open with. Sign In.

Lis-moi (Plugins Akallan).pdf
personnes curieuses ou qui veulent se créer un dossier Plugins de base solide. N'oubliez pas que le dossier n'a pas été conçu pour vous mais pour moi selon.

History of SBT Today.pdf
Page 1 of 1. 12 14 16 18 20. The History of Scripps Pier SBT (..C) on 2018−03−19. Temperature (..C). ○. ○. ○. 12 14 16 18 20. ○○. ○. ○. ○. ○. Today's SBT is the 84th warmest Mar 19th on record @ 12.4. 2014 was the warmest @ 18.6

SBT Pay In Slip.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. SBT Pay In Slip.

SBT-Sport-Personnel-Advt.pdf
SBT-Sport-Personnel-Advt.pdf. SBT-Sport-Personnel-Advt.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying SBT-Sport-Personnel-Advt.pdf.

Lis-moi (Plugins Akallan).pdf
Windows 7: Bibliothèques\Documents). 2. Copiez le dossier SimCity 4, collez le dossier sur un disque dur externe (clé. USB par exemple, ou a quelque part sur ...

Getting Started with SBT for Scala - Saxena Shiti.pdf
Getting Started with SBT for Scala - Saxena Shiti.pdf. Getting Started with SBT for Scala - Saxena Shiti.pdf. Open. Extract. Open with. Sign In. Main menu.

[PDF BOOK] WordPress: 665 Free WordPress Plugins ...
... 665 Free WordPress Plugins for Creating Amazing and Profitable Websites (SEO ..... design and development freelance and job sites- Discover the best FREE ...

Download HOFA-Plugins HOFA IQ-Reverb v1.0.11-R2R [deepstatus ...
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Main menu.

Top-15-WordPress-Social-Media-Sharing-Plugins-by-Techtic ...
Top-15-WordPress-Social-Media-Sharing-Plugins-by-Techtic Solutions.pdf. Top-15-WordPress-Social-Media-Sharing-Plugins-by-Techtic Solutions.pdf. Open.

NuGen Audio Plugins Bundle January 2014 - CHAOS [deepstatus] .pdf
Stereoizer offers you. the full range of stereo image enhancement, from gentle width adjustments to huge dynamic. ambiences that transform the soundstage.

techrepublic.com-How to check and configure your browser plugins ...
... sure all your updates have been done, and that you are secure. Chrome. Page 3 of 5. techrepublic.com-How to check and configure your browser plugins.pdf.

content-buzz-a-wordpress-plugins-details-for-affiliate-plugin-to-obtain ...
Try one of the apps below to open or edit this item. content-buzz-a-wordpress-plugins-details-for-affiliate-plugin-to-obtain-content-from-1499494503885.pdf.