Skip to content

Instantly share code, notes, and snippets.

View jeffreyolchovy's full-sized avatar

Jeffrey Olchovy jeffreyolchovy

View GitHub Profile
import Publishing._
lazy val root = (project in file("."))
.settings(ReleaseSettings: _*)
.aggregate(plugin, library)
.enablePlugins(CrossPerProjectPlugin)
lazy val plugin = (project in file("plugin"))
.settings(PublishSettings: _*)
.settings(scriptedSettings: _*)
import sbt._
import sbt.Keys._
import sbtrelease.ReleasePlugin.autoImport._
import sbtrelease.ReleaseStateTransformations._
object Publishing {
/* `publish` performs a no-op */
val NoopPublishSettings = Seq(
packagedArtifacts in RootProject(file(".")) := Map.empty,
import sbtrelease.ReleaseStateTransformations._
name := "tweeter-positive"
organization := "com.example"
// current timestamp has been added as version metadata to prevent the suppression of duplicate tweets
version := s"1.2.3+${System.currentTimeMillis}"
// for 'real' projects, we'll want to use most of the default `releaseProcess`
override def projectSettings = Seq(
// Required settings that must be defined by the project utilizing the plugin
tweeterConsumerKey := {
tweeterConsumerKey.??(undefinedKeyError(tweeterConsumerKey.key)).value
},
tweeterConsumerSecret := {
tweeterConsumerSecret.??(undefinedKeyError(tweeterConsumerSecret.key)).value
},
tweeterAccessToken := {
tweeterAccessToken.??(undefinedKeyError(tweeterAccessToken.key)).value
// The one input task that will be available to our plugin users, by default
tweeterTweet := {
val log = streams.value.log
val tweet = spaceDelimited("<text of tweet>").parsed.mkString(" ")
val consumerKey = tweeterConsumerKey.value
val consumerSecret = tweeterConsumerSecret.value
val accessToken = tweeterAccessToken.value
val accessTokenSecret = tweeterAccessTokenSecret.value
val client = TweeterService(consumerKey, consumerSecret, accessToken, accessTokenSecret)
client.post(tweet) match {
package sbttweeter
import scala.util.{Success, Failure}
import sbt._
import sbt.Keys._
import sbt.complete.DefaultParsers.spaceDelimited
import com.example.sbt.TweeterService
object TweeterKeys {
val tweeterConsumerKey = settingKey[String]("The Twitter application consumer key")
name := "tweeter-negative"
tweeterConsumerKey := "foo"
tweeterConsumerSecret := "bar"
tweeterAccessToken := "baz"
tweeterAccessTokenSecret := "qux"
package sbttweeter
import sbt._
import sbt.Keys._
object TweeterKeys {
val tweeterConsumerKey = settingKey[String]("The Twitter application consumer key")
val tweeterConsumerSecret = settingKey[String]("The Twitter application consumer secret")
val tweeterAccessToken = settingKey[String]("The Twitter user access token")
val tweeterAccessTokenSecret = settingKey[String]("The Twitter user access token secret")
lazy val root = (project in file("."))
.aggregate(plugin, library)
.enablePlugins(CrossPerProjectPlugin)
lazy val plugin = (project in file("plugin"))
.settings(scriptedSettings: _*)
.settings(
name := "sbt-tweeter",
sbtPlugin := true,
scalaVersion := "2.10.6",
package sbttweeter
import sbt._
import sbt.Keys._
object TweeterKeys {
val tweeterConsumerKey = settingKey[String]("The Twitter application consumer key")
val tweeterConsumerSecret = settingKey[String]("The Twitter application consumer secret")
val tweeterAccessToken = settingKey[String]("The Twitter user access token")
val tweeterAccessTokenSecret = settingKey[String]("The Twitter user access token secret")