SlideShare a Scribd company logo
1 of 36
Download to read offline
Custom Deployments
with SBT-Native-Packager
Gary Coady

gcoady@gilt.com
Twitter: @fiadliel
Why Native Packager?
• Java = “run anywhere”
• Native Packager = “run Java anywhere”
• Classpath, JVM parameters, command-line
arguments, environment variables, behaviour on
quit, …
$	
  bin/my-­‐first-­‐app	
  -­‐h	
  
Usage:	
  	
  [options]	
  
	
  	
  -­‐h	
  |	
  -­‐help	
  	
  	
  	
  	
  	
  	
  	
  	
  print	
  this	
  message	
  
	
  	
  -­‐v	
  |	
  -­‐verbose	
  	
  	
  	
  	
  	
  this	
  runner	
  is	
  chattier	
  
	
  	
  -­‐d	
  |	
  -­‐debug	
  	
  	
  	
  	
  	
  	
  	
  set	
  sbt	
  log	
  level	
  to	
  debug	
  
	
  	
  -­‐no-­‐version-­‐check	
  	
  Don't	
  run	
  the	
  java	
  version	
  check.	
  
	
  	
  -­‐main	
  <classname>	
  	
  Define	
  a	
  custom	
  main	
  class	
  
	
  	
  -­‐jvm-­‐debug	
  <port>	
  	
  Turn	
  on	
  JVM	
  debugging,	
  open	
  at	
  the	
  given	
  port.	
  
	
  	
  #	
  java	
  version	
  (default:	
  java	
  from	
  PATH,	
  currently	
  java	
  version	
  "1.8.0_45")	
  
	
  	
  -­‐java-­‐home	
  <path>	
  	
  	
  	
  	
  	
  	
  	
  	
  alternate	
  JAVA_HOME	
  
	
  	
  #	
  jvm	
  options	
  and	
  output	
  control	
  
	
  	
  JAVA_OPTS	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  environment	
  variable,	
  if	
  unset	
  uses	
  ""	
  
	
  	
  -­‐Dkey=val	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  pass	
  -­‐Dkey=val	
  directly	
  to	
  the	
  java	
  runtime	
  
	
  	
  -­‐J-­‐X	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  pass	
  option	
  -­‐X	
  directly	
  to	
  the	
  java	
  runtime	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  (-­‐J	
  is	
  stripped)	
  
	
  	
  #	
  special	
  option	
  
	
  	
  -­‐-­‐	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  To	
  stop	
  parsing	
  built-­‐in	
  commands	
  from	
  the	
  rest	
  of	
  the	
  command-­‐line.	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  e.g.)	
  enabling	
  debug	
  and	
  sending	
  -­‐d	
  as	
  app	
  argument	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  $	
  ./start-­‐script	
  -­‐d	
  -­‐-­‐	
  -­‐d	
  
In	
  the	
  case	
  of	
  duplicated	
  or	
  conflicting	
  options,	
  basically	
  the	
  order	
  above	
  
shows	
  precedence:	
  JAVA_OPTS	
  lowest,	
  command	
  line	
  options	
  highest	
  except	
  "-­‐-­‐".
What is an SBT API?
Setting[T]
Computation run once, returning T
>	
  set	
  name	
  :=	
  {	
  println("hello	
  world!”);	
  "name"	
  }	
  
[info]	
  Defining	
  *:name	
  
[info]	
  Reapplying	
  settings...	
  
hello	
  world!	
  
[info]	
  Set	
  current	
  project	
  to	
  name	
  (in	
  build	
  file:/Users/gcoady/my-­‐project/)	
  
>	
  name	
  
[info]	
  name
Task[T]
Computation run every time value is needed, returning T
>	
  set	
  run	
  :=	
  {	
  println("hello	
  world");	
  ()	
  }	
  
[info]	
  Defining	
  *:run	
  
[info]	
  The	
  new	
  value	
  will	
  be	
  used	
  by	
  no	
  settings	
  or	
  tasks.	
  
[info]	
  Reapplying	
  settings...	
  
blah	
  
[info]	
  Set	
  current	
  project	
  to	
  name	
  (in	
  build	
  file:/Users/gcoady/my-­‐project/)	
  
>	
  run	
  
hello	
  world	
  
[success]	
  Total	
  time:	
  0	
  s,	
  completed	
  11-­‐Feb-­‐2016	
  14:59:18	
  
>	
  run	
  
hello	
  world	
  
[success]	
  Total	
  time:	
  0	
  s,	
  completed	
  11-­‐Feb-­‐2016	
  14:59:19
Dependencies
• Tasks can depend on other tasks and settings
• Settings can depend on other settings
Keys
Typed identifier & documentation for settings/tasks
>	
  inspect	
  name	
  
[info]	
  Setting:	
  java.lang.String	
  =	
  name	
  
[info]	
  Description:	
  
[info]	
  	
   Project	
  name.	
  
[info]	
  Provided	
  by:	
  
[info]	
  	
   {file:/Users/gcoady/my-­‐project/}my-­‐project/*:name
Native Packager API
AutoPlugin Ecosystem
SbtNativePackager
UniversalPlugin
DockerPlugin
LinuxPlugin
WindowsPluginDebianPlugin RpmPlugin
JavaAppPackaging
Universal Configuration
• Provided by Universal Plugin
• Platform-independent layout
• Staging
• Package zip & tgz files
• Depended on by other deployment formats
Universal Configuration
val	
  mappings	
  =	
  TaskKey[Seq[(File,	
  String)]](	
  
	
  	
  "mappings",	
  
	
  	
  "Defines	
  the	
  mappings	
  from	
  a	
  file	
  to	
  a	
  
path,	
  used	
  by	
  packaging,	
  for	
  example."

)
Starting your plugin
sbtPlugin := true



// The Typesafe repository

resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"



addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3" % "provided")

Starting your plugin
object MyPlugin extends AutoPlugin {



val MyPluginConfig = config("myplugin") extend Universal



object autoImport {

val myPluginSetting = settingKey[Seq[String]](“A custom setting")

val myPluginTask = taskKey[File](“A custom task")

}



import autoImport._



override val requires = JavaAppPackaging



override val projectSettings = inConfig(MyPluginConfig)(Seq(
// Configure settings for project here

))

}
Case Study
• YourKit Profiler:

An awesome CPU and memory Java Profiler
• Lots of annoying steps to install
Plugin Requirements
• Add platform-specific shared library
• Add flags to use library as Java agent
• Allow changes to configuration at deployment time
Adding resources
$	
  find	
  src/main/resources	
  -­‐type	
  f	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/aix-­‐ppc-­‐32/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/aix-­‐ppc-­‐64/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/freebsd-­‐x86-­‐32/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/freebsd-­‐x86-­‐64/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/hpux-­‐ia64-­‐32/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/hpux-­‐ia64-­‐64/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐aarch64/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐armv5-­‐sf/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐armv7-­‐hf/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐ppc-­‐32/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐ppc-­‐64/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐ppc64le/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐x86-­‐32/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐x86-­‐64/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/mac/libyjpagent.jnilib	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/solaris-­‐sparc-­‐32/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/solaris-­‐sparc-­‐64/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/solaris-­‐x86-­‐32/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/solaris-­‐x86-­‐64/libyjpagent.so	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/win32/yjpagent.dll	
  
src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/win64/yjpagent.dll
Adding resources
val	
  stream	
  =	
  Option(getClass.getResourceAsStream(path))

stream	
  match	
  {

	
  	
  case	
  Some(s)	
  =>

	
  	
  	
  	
  val	
  tempFile	
  =	
  targetDir	
  /	
  "yourkit"	
  /	
  p	
  /	
  s"yourkit.$ext"

	
  	
  	
  	
  tempFile.getParentFile.mkdirs()

	
  	
  	
  	
  IO.transferAndClose(s,	
  new	
  java.io.FileOutputStream(tempFile))
Adding resources
mappings in Universal ++=
yourKitAgents.value.map(agent =>
agent.sourceFile -> agent.targetPath
)
Java entry point generation
• Provided by JavaAppPackaging
• Creates start script for Java applications
• Arbitrary bash code can be injected
• Adding Java agents to Java binaries
• Environment discovery & injection
Injecting arbitrary code
val	
  bashScriptExtraDefines	
  =	
  TaskKey[Seq[String]](	
  
	
  	
  “bashScriptExtraDefines",	
  
	
  	
  "A	
  list	
  of	
  extra	
  definitions	
  that	
  should	
  be	
  written	
  to	
  the	
  
bash	
  file	
  template.")
Bash script helpers
• ${app_path}/…/ — root directory of distribution
• addJava — adds a Java argument
• addApp — adds an argument to your application
• addResidual — adds an argument to your
application, goes after non-residuals
Injecting bash code
def	
  startYourKitScript(defaultStartupOptions:	
  String):	
  String	
  =	
  """

if	
  [[	
  -­‐z	
  "$YOURKIT_AGENT_DISABLED"	
  ]];	
  then

	
  	
  if	
  [[	
  -­‐z	
  "$YOURKIT_AGENT_STARTUP_OPTIONS"	
  ]];	
  then

	
  	
  	
  	
  YOURKIT_AGENT_STARTUP_OPTIONS=""""	
  +	
  defaultStartupOptions	
  +	
  """"

	
  	
  	
  	
  export	
  YOURKIT_AGENT_STARTUP_OPTIONS

	
  	
  fi

"""	
  
bashScriptExtraDefines	
  +=	
  
	
  	
  """addJava	
  "-­‐agentpath:${app_home}/../"""	
  +	
  
	
  	
  	
  	
  mapping	
  +	
  
	
  	
  	
  	
  """=${YOURKIT_AGENT_STARTUP_OPTIONS}""""
Trying it out
addSbtPlugin("com.gilt.sbt" % "sbt-yourkit" % "0.0.2")
enablePlugins(PlayScala,	
  YourKit)
Debugging
• Universal configuration IS universal
• universal:stage presents application layout
Online Examples
• https://github.com/gilt/sbt-yourkit
• https://github.com/gilt/sbt-newrelic

Downloads New Relic agent with Ivy

Generates NR configuration from SBT settings

Adds agent, configuration, and appropriate startup
arguments
• https://github.com/gilt/sbt-aspectjweaver

Downloads AspectJWeaver agent with Ivy

Adds agent and appropriate startup arguments
Native Packager Supported
Formats
• Zip/TGZ Archives
• Windows MSI
• OSX DMG
• Debian DEB
• Red Hat / Fedora RPM
• Docker
Why not one more?
Case Study: ACI Images
• Used by RKT (Docker alternative)
• TAR format
• Optional compression, GPG signatures
• /manifest: Image metadata
• /rootfs/: Image contents
Defining required keys
object autoImport {
val aciDependencies = settingKey[Seq[String]](“ACI Dependencies")

val aciManifest = taskKey[File]("ACI Manifest")

}
Reusing existing keys
val Aci = config("aci") extend Universal
Create file/path mappings
mappings	
  :=	
  (	
  
	
  	
  renameDests((mappings	
  in	
  Universal).value,	
  "rootfs")	
  ++	
  
	
  	
  	
  	
  Seq(aciManifest.value	
  -­‐>	
  “manifest")	
  
)

def	
  renameDest(originalPath:	
  String,	
  dest:	
  String)	
  =

	
  	
  "%s/%s"	
  format	
  (dest,	
  originalPath)



def	
  renameDests(from:	
  Seq[(File,	
  String)],	
  dest:	
  String)	
  =

	
  	
  for	
  {

	
  	
  	
  	
  (f,	
  path)	
  <-­‐	
  from

	
  	
  }	
  yield	
  (f,	
  renameDest(path,	
  dest))
Create target file
packageBin :=

Archives.makeTarball(Archives.gzip, “.aci")(
target.value, normalizedName.value, mappings.value, None)
Online Code
• https://github.com/fiadliel/sbt-aci
Summary
• Extending SBT Native Packager is easy
• Alter program environment
• Create alternative formats for distribution
Questions?

More Related Content

What's hot

DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)Soshi Nemoto
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configurationlutter
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about GradleEvgeny Goldin
 
React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15Rob Gietema
 
"Migrate large gwt applications - Lessons Learned" By Harald Pehl
"Migrate large gwt applications - Lessons Learned" By Harald Pehl"Migrate large gwt applications - Lessons Learned" By Harald Pehl
"Migrate large gwt applications - Lessons Learned" By Harald PehlGWTcon
 
Spring & Hibernate
Spring & HibernateSpring & Hibernate
Spring & HibernateJiayun Zhou
 
Cassandra and materialized views
Cassandra and materialized viewsCassandra and materialized views
Cassandra and materialized viewsGrzegorz Duda
 
Ice mini guide
Ice mini guideIce mini guide
Ice mini guideAdy Liu
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2Graham Dumpleton
 
Jafka guide
Jafka guideJafka guide
Jafka guideAdy Liu
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneAndres Almiray
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansiblejtyr
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to NodejsGabriele Lana
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansiblebcoca
 

What's hot (20)

DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
Intro to-ant
Intro to-antIntro to-ant
Intro to-ant
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about Gradle
 
Ant
AntAnt
Ant
 
React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15
 
"Migrate large gwt applications - Lessons Learned" By Harald Pehl
"Migrate large gwt applications - Lessons Learned" By Harald Pehl"Migrate large gwt applications - Lessons Learned" By Harald Pehl
"Migrate large gwt applications - Lessons Learned" By Harald Pehl
 
Spring & Hibernate
Spring & HibernateSpring & Hibernate
Spring & Hibernate
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
 
Cassandra and materialized views
Cassandra and materialized viewsCassandra and materialized views
Cassandra and materialized views
 
Ice mini guide
Ice mini guideIce mini guide
Ice mini guide
 
GradleFX
GradleFXGradleFX
GradleFX
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2
 
groovy & grails - lecture 11
groovy & grails - lecture 11groovy & grails - lecture 11
groovy & grails - lecture 11
 
Jafka guide
Jafka guideJafka guide
Jafka guide
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
Scala active record
Scala active recordScala active record
Scala active record
 

Viewers also liked

Unsucking Error Handling with Futures
Unsucking Error Handling with FuturesUnsucking Error Handling with Futures
Unsucking Error Handling with FuturesGaryCoady
 
Continous delivery - lad koden flyde 2014
Continous delivery - lad koden flyde 2014Continous delivery - lad koden flyde 2014
Continous delivery - lad koden flyde 2014BestBrains
 
Continous delivery with sbt
Continous delivery with sbtContinous delivery with sbt
Continous delivery with sbtWojciech Pituła
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And MavenPerconaPerformance
 
Scala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouScala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouJ On The Beach
 
Akka Http , Routes, Streams with Scala
Akka Http , Routes, Streams with ScalaAkka Http , Routes, Streams with Scala
Akka Http , Routes, Streams with ScalaJerry Kuru
 
Using Jenkins and Jmeter to build a scalable Load Testing solution
Using Jenkins and Jmeter to build a scalable Load Testing solutionUsing Jenkins and Jmeter to build a scalable Load Testing solution
Using Jenkins and Jmeter to build a scalable Load Testing solutionRuslan Strazhnyk
 
Performance Testing With Jmeter
Performance Testing With JmeterPerformance Testing With Jmeter
Performance Testing With JmeterAdam Goucher
 
An Introduction to Akka http
An Introduction to Akka httpAn Introduction to Akka http
An Introduction to Akka httpKnoldus Inc.
 
Practical Akka HTTP - introduction
Practical Akka HTTP - introductionPractical Akka HTTP - introduction
Practical Akka HTTP - introductionŁukasz Sowa
 
Securing Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTPSecuring Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTPRafal Gancarz
 
Building scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTPBuilding scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTPdatamantra
 
Building a Reactive RESTful API with Akka Http & Slick
Building a Reactive RESTful API with Akka Http & SlickBuilding a Reactive RESTful API with Akka Http & Slick
Building a Reactive RESTful API with Akka Http & SlickZalando Technology
 
Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster OpenCredo
 
Jmeter Performance Testing
Jmeter Performance TestingJmeter Performance Testing
Jmeter Performance TestingAtul Pant
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scaladatamantra
 

Viewers also liked (19)

Unsucking Error Handling with Futures
Unsucking Error Handling with FuturesUnsucking Error Handling with Futures
Unsucking Error Handling with Futures
 
Continous delivery - lad koden flyde 2014
Continous delivery - lad koden flyde 2014Continous delivery - lad koden flyde 2014
Continous delivery - lad koden flyde 2014
 
Continous delivery with sbt
Continous delivery with sbtContinous delivery with sbt
Continous delivery with sbt
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
 
Scala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouScala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camou
 
Akka Http , Routes, Streams with Scala
Akka Http , Routes, Streams with ScalaAkka Http , Routes, Streams with Scala
Akka Http , Routes, Streams with Scala
 
Using Jenkins and Jmeter to build a scalable Load Testing solution
Using Jenkins and Jmeter to build a scalable Load Testing solutionUsing Jenkins and Jmeter to build a scalable Load Testing solution
Using Jenkins and Jmeter to build a scalable Load Testing solution
 
Performance Testing With Jmeter
Performance Testing With JmeterPerformance Testing With Jmeter
Performance Testing With Jmeter
 
Akka http 2
Akka http 2Akka http 2
Akka http 2
 
An Introduction to Akka http
An Introduction to Akka httpAn Introduction to Akka http
An Introduction to Akka http
 
Practical Akka HTTP - introduction
Practical Akka HTTP - introductionPractical Akka HTTP - introduction
Practical Akka HTTP - introduction
 
Securing Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTPSecuring Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTP
 
Building scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTPBuilding scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTP
 
Building a Reactive RESTful API with Akka Http & Slick
Building a Reactive RESTful API with Akka Http & SlickBuilding a Reactive RESTful API with Akka Http & Slick
Building a Reactive RESTful API with Akka Http & Slick
 
Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster Spring Boot Microservices vs Akka Actor Cluster
Spring Boot Microservices vs Akka Actor Cluster
 
Jmeter Performance Testing
Jmeter Performance TestingJmeter Performance Testing
Jmeter Performance Testing
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
Jenkins Workflow
Jenkins WorkflowJenkins Workflow
Jenkins Workflow
 

Similar to Custom deployments with sbt-native-packager

Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Deepak Garg
 
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfRahulRoy130127
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbtFabio Fumarola
 
Ant_quick_guide
Ant_quick_guideAnt_quick_guide
Ant_quick_guideducquoc_vn
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Puppet
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012Carlos Sanchez
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabricandymccurdy
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby TeamArto Artnik
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in pythonAndrés J. Díaz
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabricandymccurdy
 
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docxOrdering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docxhopeaustin33688
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyNikhil Mungel
 
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Matt Fuller
 
PM : code faster
PM : code fasterPM : code faster
PM : code fasterPHPPRO
 
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2Yros
 

Similar to Custom deployments with sbt-native-packager (20)

Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
 
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Ant_quick_guide
Ant_quick_guideAnt_quick_guide
Ant_quick_guide
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Dev ops meetup
Dev ops meetupDev ops meetup
Dev ops meetup
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabric
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Generators
GeneratorsGenerators
Generators
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in python
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
 
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docxOrdering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
 
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
 
PM : code faster
PM : code fasterPM : code faster
PM : code faster
 
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2Dev ninja  -> vagrant + virtualbox + chef-solo + git + ec2
Dev ninja -> vagrant + virtualbox + chef-solo + git + ec2
 

Recently uploaded

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
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
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
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
 

Recently uploaded (20)

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
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
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
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
 

Custom deployments with sbt-native-packager

  • 1. Custom Deployments with SBT-Native-Packager Gary Coady
 gcoady@gilt.com Twitter: @fiadliel
  • 2. Why Native Packager? • Java = “run anywhere” • Native Packager = “run Java anywhere” • Classpath, JVM parameters, command-line arguments, environment variables, behaviour on quit, …
  • 3. $  bin/my-­‐first-­‐app  -­‐h   Usage:    [options]      -­‐h  |  -­‐help                  print  this  message      -­‐v  |  -­‐verbose            this  runner  is  chattier      -­‐d  |  -­‐debug                set  sbt  log  level  to  debug      -­‐no-­‐version-­‐check    Don't  run  the  java  version  check.      -­‐main  <classname>    Define  a  custom  main  class      -­‐jvm-­‐debug  <port>    Turn  on  JVM  debugging,  open  at  the  given  port.      #  java  version  (default:  java  from  PATH,  currently  java  version  "1.8.0_45")      -­‐java-­‐home  <path>                  alternate  JAVA_HOME      #  jvm  options  and  output  control      JAVA_OPTS                    environment  variable,  if  unset  uses  ""      -­‐Dkey=val                    pass  -­‐Dkey=val  directly  to  the  java  runtime      -­‐J-­‐X                              pass  option  -­‐X  directly  to  the  java  runtime                                            (-­‐J  is  stripped)      #  special  option      -­‐-­‐                                  To  stop  parsing  built-­‐in  commands  from  the  rest  of  the  command-­‐line.                                            e.g.)  enabling  debug  and  sending  -­‐d  as  app  argument                                            $  ./start-­‐script  -­‐d  -­‐-­‐  -­‐d   In  the  case  of  duplicated  or  conflicting  options,  basically  the  order  above   shows  precedence:  JAVA_OPTS  lowest,  command  line  options  highest  except  "-­‐-­‐".
  • 4. What is an SBT API?
  • 5. Setting[T] Computation run once, returning T >  set  name  :=  {  println("hello  world!”);  "name"  }   [info]  Defining  *:name   [info]  Reapplying  settings...   hello  world!   [info]  Set  current  project  to  name  (in  build  file:/Users/gcoady/my-­‐project/)   >  name   [info]  name
  • 6. Task[T] Computation run every time value is needed, returning T >  set  run  :=  {  println("hello  world");  ()  }   [info]  Defining  *:run   [info]  The  new  value  will  be  used  by  no  settings  or  tasks.   [info]  Reapplying  settings...   blah   [info]  Set  current  project  to  name  (in  build  file:/Users/gcoady/my-­‐project/)   >  run   hello  world   [success]  Total  time:  0  s,  completed  11-­‐Feb-­‐2016  14:59:18   >  run   hello  world   [success]  Total  time:  0  s,  completed  11-­‐Feb-­‐2016  14:59:19
  • 7. Dependencies • Tasks can depend on other tasks and settings • Settings can depend on other settings
  • 8. Keys Typed identifier & documentation for settings/tasks >  inspect  name   [info]  Setting:  java.lang.String  =  name   [info]  Description:   [info]     Project  name.   [info]  Provided  by:   [info]     {file:/Users/gcoady/my-­‐project/}my-­‐project/*:name
  • 11. Universal Configuration • Provided by Universal Plugin • Platform-independent layout • Staging • Package zip & tgz files • Depended on by other deployment formats
  • 12. Universal Configuration val  mappings  =  TaskKey[Seq[(File,  String)]](      "mappings",      "Defines  the  mappings  from  a  file  to  a   path,  used  by  packaging,  for  example."
 )
  • 13. Starting your plugin sbtPlugin := true
 
 // The Typesafe repository
 resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
 
 addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3" % "provided")

  • 14. Starting your plugin object MyPlugin extends AutoPlugin {
 
 val MyPluginConfig = config("myplugin") extend Universal
 
 object autoImport {
 val myPluginSetting = settingKey[Seq[String]](“A custom setting")
 val myPluginTask = taskKey[File](“A custom task")
 }
 
 import autoImport._
 
 override val requires = JavaAppPackaging
 
 override val projectSettings = inConfig(MyPluginConfig)(Seq( // Configure settings for project here
 ))
 }
  • 15. Case Study • YourKit Profiler:
 An awesome CPU and memory Java Profiler • Lots of annoying steps to install
  • 16. Plugin Requirements • Add platform-specific shared library • Add flags to use library as Java agent • Allow changes to configuration at deployment time
  • 17. Adding resources $  find  src/main/resources  -­‐type  f   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/aix-­‐ppc-­‐32/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/aix-­‐ppc-­‐64/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/freebsd-­‐x86-­‐32/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/freebsd-­‐x86-­‐64/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/hpux-­‐ia64-­‐32/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/hpux-­‐ia64-­‐64/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐aarch64/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐armv5-­‐sf/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐armv7-­‐hf/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐ppc-­‐32/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐ppc-­‐64/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐ppc64le/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐x86-­‐32/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/linux-­‐x86-­‐64/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/mac/libyjpagent.jnilib   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/solaris-­‐sparc-­‐32/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/solaris-­‐sparc-­‐64/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/solaris-­‐x86-­‐32/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/solaris-­‐x86-­‐64/libyjpagent.so   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/win32/yjpagent.dll   src/main/resources/yjp-­‐2015-­‐build-­‐15068/bin/win64/yjpagent.dll
  • 18. Adding resources val  stream  =  Option(getClass.getResourceAsStream(path))
 stream  match  {
    case  Some(s)  =>
        val  tempFile  =  targetDir  /  "yourkit"  /  p  /  s"yourkit.$ext"
        tempFile.getParentFile.mkdirs()
        IO.transferAndClose(s,  new  java.io.FileOutputStream(tempFile))
  • 19. Adding resources mappings in Universal ++= yourKitAgents.value.map(agent => agent.sourceFile -> agent.targetPath )
  • 20. Java entry point generation • Provided by JavaAppPackaging • Creates start script for Java applications • Arbitrary bash code can be injected • Adding Java agents to Java binaries • Environment discovery & injection
  • 21. Injecting arbitrary code val  bashScriptExtraDefines  =  TaskKey[Seq[String]](      “bashScriptExtraDefines",      "A  list  of  extra  definitions  that  should  be  written  to  the   bash  file  template.")
  • 22. Bash script helpers • ${app_path}/…/ — root directory of distribution • addJava — adds a Java argument • addApp — adds an argument to your application • addResidual — adds an argument to your application, goes after non-residuals
  • 23. Injecting bash code def  startYourKitScript(defaultStartupOptions:  String):  String  =  """
 if  [[  -­‐z  "$YOURKIT_AGENT_DISABLED"  ]];  then
    if  [[  -­‐z  "$YOURKIT_AGENT_STARTUP_OPTIONS"  ]];  then
        YOURKIT_AGENT_STARTUP_OPTIONS=""""  +  defaultStartupOptions  +  """"
        export  YOURKIT_AGENT_STARTUP_OPTIONS
    fi
 """   bashScriptExtraDefines  +=      """addJava  "-­‐agentpath:${app_home}/../"""  +          mapping  +          """=${YOURKIT_AGENT_STARTUP_OPTIONS}""""
  • 24. Trying it out addSbtPlugin("com.gilt.sbt" % "sbt-yourkit" % "0.0.2") enablePlugins(PlayScala,  YourKit)
  • 25. Debugging • Universal configuration IS universal • universal:stage presents application layout
  • 26. Online Examples • https://github.com/gilt/sbt-yourkit • https://github.com/gilt/sbt-newrelic
 Downloads New Relic agent with Ivy
 Generates NR configuration from SBT settings
 Adds agent, configuration, and appropriate startup arguments • https://github.com/gilt/sbt-aspectjweaver
 Downloads AspectJWeaver agent with Ivy
 Adds agent and appropriate startup arguments
  • 27. Native Packager Supported Formats • Zip/TGZ Archives • Windows MSI • OSX DMG • Debian DEB • Red Hat / Fedora RPM • Docker
  • 28. Why not one more?
  • 29. Case Study: ACI Images • Used by RKT (Docker alternative) • TAR format • Optional compression, GPG signatures • /manifest: Image metadata • /rootfs/: Image contents
  • 30. Defining required keys object autoImport { val aciDependencies = settingKey[Seq[String]](“ACI Dependencies")
 val aciManifest = taskKey[File]("ACI Manifest")
 }
  • 31. Reusing existing keys val Aci = config("aci") extend Universal
  • 32. Create file/path mappings mappings  :=  (      renameDests((mappings  in  Universal).value,  "rootfs")  ++          Seq(aciManifest.value  -­‐>  “manifest")   )
 def  renameDest(originalPath:  String,  dest:  String)  =
    "%s/%s"  format  (dest,  originalPath)
 
 def  renameDests(from:  Seq[(File,  String)],  dest:  String)  =
    for  {
        (f,  path)  <-­‐  from
    }  yield  (f,  renameDest(path,  dest))
  • 33. Create target file packageBin :=
 Archives.makeTarball(Archives.gzip, “.aci")( target.value, normalizedName.value, mappings.value, None)
  • 35. Summary • Extending SBT Native Packager is easy • Alter program environment • Create alternative formats for distribution