SlideShare a Scribd company logo
1
Polyglot Plugin Development
How to write plugins in a language other than Java




Stefan Saasen
Confluence Team Lead, Atlassian

                                                     2
Audience
• Written an Atlassian plugin in Java
• Interested in other programming languages
• Eager to see what is possible with Atlassian plugins




                                                         3
Show of hands
• Who has actually written a Atlassian plugin?
• In any other language than Java?




                                                 4
5
Rhino
        6
7
https://bitbucket.org/ssaasen/atlassian-jruby-example-plugin

https://bitbucket.org/ssaasen/atlassian-scala-example-plugin




                                                               8
Polyglot Plugins
• Why?
• How?
 • Example 1: Scala
 • Example 2: JRuby

• Go and do it!


                      9
Why not?
           10
Why ?
        11
What to tell the boss?
• Leverage existing knowledge in the team
• Libraries/applications already written in language X
• Time to market/devspeed
• Explore technologies in a sandboxed environment
• Grass looks always greener on the other side


                                                         12
What to tell the boss?
• Leverage existing knowledge in the team
• Libraries/applications already written in language X
• Time to market/devspeed
• Explore technologies in a sandboxed environment
• Grass looks always greener on the other side


                                                         13
14
“No time to write in Java”

                  “Less bugs”
“Succinctness”
                                15
16
Polyglot Plugins
• Why?
• How?
 • Example 1: Scala
 • Example 2: JRuby

• Go and do it!


                      17
• Hybrid language: Object oriented & functional
• Concise, statically typed (with type inference)
• Higher order/first class functions, pattern matching
• Powerful type system
• Rich standard library


                                                        18
19
20
21
22
How?


       23
Overview

                                          Scala




                                                  scalac
                Scala Runtime Library

Java Bytecode
   *.class                                Java

                 Java Standard Library




                                                  javac
                                    JVM


                                                           24
25
26
Build process
• Start with Maven to get
  the AMPS goodness
• Use the maven-scala-
  plugin
• Add SBT if necessary



                            27
Build process f.
 • Compile time is a concern!
 • FSC
 • Useful Maven goals:
    mvn scala:cc
    mvn scala:console


                                28
Bundle runtime
                 29
Size might be a
  problem :(
                  30
Deployment options
     Option          Scope       Package        Size

                                mvn package
     Bundle          compile     -Pbundle
                                               8.5 MB    Simple

Bundle & Shrink                 mvn package              Deploy
                     compile                   680 KB
 w/ProGuard                     -Pproduction            externally

                                                         Deploy
Install separately   provided   mvn package    50 KB
                                                        internally
                                                                     31
Simply install using the
   plugin manager!

                           32
Development checklist
• Dependencies: Scala libraries are jar files and often
  available from Maven repositories
• Compile time: mvn scala:cc for continuous compilation
• Workflow: scala:cc & atlas-cli pi or
  mvn package && atlas-install-plugin
• Profit: mvn scala:console to get the Scala REPL

                                                          33
Scala: Working
with Java APIs
                 34
Scala gotchas (the 80%)
• Collections
• Method naming conventions
• Annotations
• Null vs. Option




                              35
Collections
 • Immutable vs Mutable, serial vs. parallel
 • Rich API: Prefer Scala collections
 • Convert between Java and Scala collections when
   calling Java methods
 • Solution: JavaConverters (explicit, preferred) vs.
   JavaConversions (implicit)
 • Watch out for serialization: Bandana/XStream
                                                        36
37
38
39
Method naming conventions
• Libraries rely on bean style naming conventions
  e.g. XWork, Velocity
• Scala: uniform access principle
• Solution: Use @BeanProperty and
  @BooleanBeanProperty



                                                    40
41
42
43
(Meta)-Annotations
• How to use @JavaAnnotation on a getter method
  when defining fields?
• Scala meta annotations @beanGetter, @beanGetter,
  @field, @getter, @setter




                                                     44
45
46
47
Option vs. null
 • In Scala Option represents an optional value.
 • Don’t let the billion-dollar mistake leak into your
   Scala code!
 • Solution: wrap nullable method calls in an Option




                                                         48
49
50
51
52
Show me the
   code!
              53
Polyglot Plugin Programming
Polyglot Plugin Programming
Polyglot Plugin Programming
57
58
59
60
Example Scala plugin
• Servlet & XWork action
• Confluence macro
• REST via Jersey/Jackson
• Build setup
• Use as a starting point
                    https://bitbucket.org/ssaasen/atlassian-scala-example-plugin

                                                                                   61
Let’s recap
 • Replace Java entirely with Scala or mix and match
 • Runtime library: 3 deployment options
 • Fits into the AMPS development workflow
 • Scala Gotchas: watch out for common problems
 • “Scala is a great fit to write Atlassian plugins in”


                                                         62
Agenda
• Why?
• How?
 • Example 1: Scala
 • Example 2: JRuby

• Go and do it!


                      63
(J)Ruby
• Dynamic, object-oriented language
• Everything is an object (no “primitives”)
• Meta-programming and open, executable classes
  allow for easy creation of DSLs
• JRuby: Ruby runtime written in Java



                                                  64
65
How?


       66
Overview
                    Ruby
Ruby files *.rb                                  Your Ruby
                  Standard          RubyGems




                                                              jrubyc
                                                   Code
                   Library

                                  Ruby Runtime

Java Bytecode
   *.class                                             Java

                     Java Standard Library




                                                              javac
                                        JVM




                                                                       67
68
69
70
Plugins can’t be
written in Ruby

                   71
But we can still use
 Ruby in a plugin!

                       72
Recipe for using JRuby
• Embed the Ruby Runtime
• Use Java to execute Ruby scripts and classes
• Make components of the host application available
• Use the script execution result in Java




                                                      73
Embedding Strategies
• javax.scripting - JSR 223
• Apache Bean Scripting Framework (BSF)
• JRuby Embed - lower level JRuby API




                                          74
Embedding Strategies
• javax.scripting - JSR 223
  Only configurable via system properties :(
• Apache Bean scripting framework (BSF)
  No point in adding a separate API
• JRuby Embed - lower level JRuby API



                                              75
76
Building the plugin
• Package Ruby files
• Download and package Ruby gems
• Make Ruby gems available on the Ruby LOAD_PATH
• Bundle everything into a plugin jar file
• A lot of Maven XML :)
• Caveat: JRuby runtime is even larger!
                                                   77
Show me the
   code!
              78
79
80
1 minute


           81
82
83
84
85
86
87
88
89
Example JRuby plugin
• How to use Rubygem based
  libraries in a plugin
• How to access host
  components in Ruby
• How to use the execution result
• Sinatra in Confluence ;-)
                     https://bitbucket.org/ssaasen/atlassian-jruby-example-plugin
                                                                                    90
Let’s recap
• The plugin can’t be written in Ruby!
• Use the Ruby runtime
• Development workflow bonus: dynamic reloading!
• The overhead of adding the runtime and providing
  Java glue code makes this only feasible for high
  value use cases :(

                                                     91
Conclusion
• Scala is a great alternative when
  developing an Atlassian plugin
• JRuby is powerful, makes
  developing in a dynamic language
  possible but requires more work and
  custom Java adapter code
• Java interoperability needs to be well
  understood in both cases
                                           92
TAKE-AWAYS




“   The power of the Atlassian plugin framework allows
    you to build your plugins the way you want and

                                     ”
    Java doesn’t have to be the limit.




     #atlascamp


                                                         93
Thank you!




             94
• “Happy Foods” by swanksalot
  http://www.flickr.com/photos/swanksalot/5021262869/
• “Construction” by Daniel Morris
  http://www.flickr.com/photos/danielmorris/275438405/
• “70 80 90” by roujo
  http://www.flickr.com/photos/tekmagika/437989361



                                                        95

More Related Content

What's hot (20)

PDF
Testing Ember Apps
jo_liss
 
PDF
An introduction and future of Ruby coverage library
mametter
 
PDF
A Taste of Pharo 7.0
ESUG
 
PDF
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
Bilgin Ibryam
 
PPTX
Capybara and cucumber with DSL using ruby
Deepak Chandella
 
PDF
Bitter Java, Sweeten with JRuby
Brian Sam-Bodden
 
PDF
GraalVM - MadridJUG 2019-10-22
Jorge Hidalgo
 
PDF
Cloud Native Camel Design Patterns
Bilgin Ibryam
 
KEY
Euruko 2012 - JRuby
Charles Nutter
 
PDF
JVM Memory Management Details
Azul Systems Inc.
 
PDF
Event Driven Architecture with Apache Camel
prajods
 
PPTX
Java performance tuning
Jerry Kurian
 
PPTX
Performance of Microservice Frameworks on different JVMs
Maarten Smeets
 
PDF
GraalVM - OpenSlava 2019-10-18
Jorge Hidalgo
 
KEY
High performance network programming on the jvm oscon 2012
Erik Onnen
 
PDF
Maven: from Scratch to Production (.pdf)
Johan Mynhardt
 
PDF
ToulouseJUG-Maven 3.x, will it lives up to its promises
Arnaud Héritier
 
PDF
BordeauxJUG-Maven 3.x, will it lives up to its promises
Arnaud Héritier
 
PPT
MAVEN
shayan n
 
PDF
From java-to-ruby-book-summary
120bi
 
Testing Ember Apps
jo_liss
 
An introduction and future of Ruby coverage library
mametter
 
A Taste of Pharo 7.0
ESUG
 
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
Bilgin Ibryam
 
Capybara and cucumber with DSL using ruby
Deepak Chandella
 
Bitter Java, Sweeten with JRuby
Brian Sam-Bodden
 
GraalVM - MadridJUG 2019-10-22
Jorge Hidalgo
 
Cloud Native Camel Design Patterns
Bilgin Ibryam
 
Euruko 2012 - JRuby
Charles Nutter
 
JVM Memory Management Details
Azul Systems Inc.
 
Event Driven Architecture with Apache Camel
prajods
 
Java performance tuning
Jerry Kurian
 
Performance of Microservice Frameworks on different JVMs
Maarten Smeets
 
GraalVM - OpenSlava 2019-10-18
Jorge Hidalgo
 
High performance network programming on the jvm oscon 2012
Erik Onnen
 
Maven: from Scratch to Production (.pdf)
Johan Mynhardt
 
ToulouseJUG-Maven 3.x, will it lives up to its promises
Arnaud Héritier
 
BordeauxJUG-Maven 3.x, will it lives up to its promises
Arnaud Héritier
 
MAVEN
shayan n
 
From java-to-ruby-book-summary
120bi
 

Viewers also liked (6)

PDF
Atlassian unite pix
Atlassian
 
PDF
Unite keynote all - mike's edit (don't edit!)
Atlassian
 
PPTX
Ravendb@swedenprogressive
Mikael Östberg
 
KEY
How HipChat Powers the HipChat Team - Atlassian Summit 2012
Atlassian
 
PDF
Atlassian Overview
Atlassian
 
PDF
Guerilla marketing your service desk
Atlassian
 
Atlassian unite pix
Atlassian
 
Unite keynote all - mike's edit (don't edit!)
Atlassian
 
Ravendb@swedenprogressive
Mikael Östberg
 
How HipChat Powers the HipChat Team - Atlassian Summit 2012
Atlassian
 
Atlassian Overview
Atlassian
 
Guerilla marketing your service desk
Atlassian
 
Ad

Similar to Polyglot Plugin Programming (20)

PDF
Enterprise OSGi at eBay
Tony Ng
 
PDF
Venkat Subramaniam Blending Java With Dynamic Languages
deimos
 
KEY
Polyglot Grails
Marcin Gryszko
 
ODP
How to start using Scala
Ngoc Dao
 
PDF
Absorbing Scala Into Java Ecosystem
Eishay Smith
 
PDF
What is new and cool j2se & java
Eugene Bogaart
 
PDF
Real World Technologies
José Maria Silveira Neto
 
PDF
Java Future S Ritter
catherinewall
 
PDF
Calling All Modularity Solutions: A Comparative Study from eBay
Tony Ng
 
PDF
Ola Bini Evolving The Java Platform
deimos
 
PDF
Powering the Next Generation Services with Java Platform - Spark IT 2010
Arun Gupta
 
PDF
Calling all modularity solutions
Sangjin Lee
 
PDF
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
 
PDF
Jax london 2011
njbartlett
 
KEY
Scala Introduction
Adrian Spender
 
PPTX
Scala adoption by enterprises
Mike Slinn
 
KEY
Java to Scala: Why & How
Graham Tackley
 
PPTX
Lessons Learned: Scala and its Ecosystem
Petr Hošek
 
PDF
JRuby - Enterprise 2.0
Jan Sifra
 
PDF
Java ScriptingJava Scripting: One VM, Many Languages
elliando dias
 
Enterprise OSGi at eBay
Tony Ng
 
Venkat Subramaniam Blending Java With Dynamic Languages
deimos
 
Polyglot Grails
Marcin Gryszko
 
How to start using Scala
Ngoc Dao
 
Absorbing Scala Into Java Ecosystem
Eishay Smith
 
What is new and cool j2se & java
Eugene Bogaart
 
Real World Technologies
José Maria Silveira Neto
 
Java Future S Ritter
catherinewall
 
Calling All Modularity Solutions: A Comparative Study from eBay
Tony Ng
 
Ola Bini Evolving The Java Platform
deimos
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Arun Gupta
 
Calling all modularity solutions
Sangjin Lee
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
 
Jax london 2011
njbartlett
 
Scala Introduction
Adrian Spender
 
Scala adoption by enterprises
Mike Slinn
 
Java to Scala: Why & How
Graham Tackley
 
Lessons Learned: Scala and its Ecosystem
Petr Hošek
 
JRuby - Enterprise 2.0
Jan Sifra
 
Java ScriptingJava Scripting: One VM, Many Languages
elliando dias
 
Ad

More from Atlassian (20)

PPTX
International Women's Day 2020
Atlassian
 
PDF
10 emerging trends that will unbreak your workplace in 2020
Atlassian
 
PDF
Forge App Showcase
Atlassian
 
PDF
Let's Build an Editor Macro with Forge UI
Atlassian
 
PDF
Meet the Forge Runtime
Atlassian
 
PDF
Forge UI: A New Way to Customize the Atlassian User Experience
Atlassian
 
PDF
Take Action with Forge Triggers
Atlassian
 
PDF
Observability and Troubleshooting in Forge
Atlassian
 
PDF
Trusted by Default: The Forge Security & Privacy Model
Atlassian
 
PDF
Designing Forge UI: A Story of Designing an App UI System
Atlassian
 
PDF
Forge: Under the Hood
Atlassian
 
PDF
Access to User Activities - Activity Platform APIs
Atlassian
 
PDF
Design Your Next App with the Atlassian Vendor Sketch Plugin
Atlassian
 
PDF
Tear Up Your Roadmap and Get Out of the Building
Atlassian
 
PDF
Nailing Measurement: a Framework for Measuring Metrics that Matter
Atlassian
 
PDF
Building Apps With Color Blind Users in Mind
Atlassian
 
PDF
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Atlassian
 
PDF
Beyond Diversity: A Guide to Building Balanced Teams
Atlassian
 
PDF
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
Atlassian
 
PDF
Building Apps With Enterprise in Mind
Atlassian
 
International Women's Day 2020
Atlassian
 
10 emerging trends that will unbreak your workplace in 2020
Atlassian
 
Forge App Showcase
Atlassian
 
Let's Build an Editor Macro with Forge UI
Atlassian
 
Meet the Forge Runtime
Atlassian
 
Forge UI: A New Way to Customize the Atlassian User Experience
Atlassian
 
Take Action with Forge Triggers
Atlassian
 
Observability and Troubleshooting in Forge
Atlassian
 
Trusted by Default: The Forge Security & Privacy Model
Atlassian
 
Designing Forge UI: A Story of Designing an App UI System
Atlassian
 
Forge: Under the Hood
Atlassian
 
Access to User Activities - Activity Platform APIs
Atlassian
 
Design Your Next App with the Atlassian Vendor Sketch Plugin
Atlassian
 
Tear Up Your Roadmap and Get Out of the Building
Atlassian
 
Nailing Measurement: a Framework for Measuring Metrics that Matter
Atlassian
 
Building Apps With Color Blind Users in Mind
Atlassian
 
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Atlassian
 
Beyond Diversity: A Guide to Building Balanced Teams
Atlassian
 
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
Atlassian
 
Building Apps With Enterprise in Mind
Atlassian
 

Recently uploaded (20)

PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Biography of Daniel Podor.pdf
Daniel Podor
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 

Polyglot Plugin Programming

  • 1. 1
  • 2. Polyglot Plugin Development How to write plugins in a language other than Java Stefan Saasen Confluence Team Lead, Atlassian 2
  • 3. Audience • Written an Atlassian plugin in Java • Interested in other programming languages • Eager to see what is possible with Atlassian plugins 3
  • 4. Show of hands • Who has actually written a Atlassian plugin? • In any other language than Java? 4
  • 5. 5
  • 6. Rhino 6
  • 7. 7
  • 9. Polyglot Plugins • Why? • How? • Example 1: Scala • Example 2: JRuby • Go and do it! 9
  • 10. Why not? 10
  • 11. Why ? 11
  • 12. What to tell the boss? • Leverage existing knowledge in the team • Libraries/applications already written in language X • Time to market/devspeed • Explore technologies in a sandboxed environment • Grass looks always greener on the other side 12
  • 13. What to tell the boss? • Leverage existing knowledge in the team • Libraries/applications already written in language X • Time to market/devspeed • Explore technologies in a sandboxed environment • Grass looks always greener on the other side 13
  • 14. 14
  • 15. “No time to write in Java” “Less bugs” “Succinctness” 15
  • 16. 16
  • 17. Polyglot Plugins • Why? • How? • Example 1: Scala • Example 2: JRuby • Go and do it! 17
  • 18. • Hybrid language: Object oriented & functional • Concise, statically typed (with type inference) • Higher order/first class functions, pattern matching • Powerful type system • Rich standard library 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. 22
  • 23. How? 23
  • 24. Overview Scala scalac Scala Runtime Library Java Bytecode *.class Java Java Standard Library javac JVM 24
  • 25. 25
  • 26. 26
  • 27. Build process • Start with Maven to get the AMPS goodness • Use the maven-scala- plugin • Add SBT if necessary 27
  • 28. Build process f. • Compile time is a concern! • FSC • Useful Maven goals: mvn scala:cc mvn scala:console 28
  • 30. Size might be a problem :( 30
  • 31. Deployment options Option Scope Package Size mvn package Bundle compile -Pbundle 8.5 MB Simple Bundle & Shrink mvn package Deploy compile 680 KB w/ProGuard -Pproduction externally Deploy Install separately provided mvn package 50 KB internally 31
  • 32. Simply install using the plugin manager! 32
  • 33. Development checklist • Dependencies: Scala libraries are jar files and often available from Maven repositories • Compile time: mvn scala:cc for continuous compilation • Workflow: scala:cc & atlas-cli pi or mvn package && atlas-install-plugin • Profit: mvn scala:console to get the Scala REPL 33
  • 35. Scala gotchas (the 80%) • Collections • Method naming conventions • Annotations • Null vs. Option 35
  • 36. Collections • Immutable vs Mutable, serial vs. parallel • Rich API: Prefer Scala collections • Convert between Java and Scala collections when calling Java methods • Solution: JavaConverters (explicit, preferred) vs. JavaConversions (implicit) • Watch out for serialization: Bandana/XStream 36
  • 37. 37
  • 38. 38
  • 39. 39
  • 40. Method naming conventions • Libraries rely on bean style naming conventions e.g. XWork, Velocity • Scala: uniform access principle • Solution: Use @BeanProperty and @BooleanBeanProperty 40
  • 41. 41
  • 42. 42
  • 43. 43
  • 44. (Meta)-Annotations • How to use @JavaAnnotation on a getter method when defining fields? • Scala meta annotations @beanGetter, @beanGetter, @field, @getter, @setter 44
  • 45. 45
  • 46. 46
  • 47. 47
  • 48. Option vs. null • In Scala Option represents an optional value. • Don’t let the billion-dollar mistake leak into your Scala code! • Solution: wrap nullable method calls in an Option 48
  • 49. 49
  • 50. 50
  • 51. 51
  • 52. 52
  • 53. Show me the code! 53
  • 57. 57
  • 58. 58
  • 59. 59
  • 60. 60
  • 61. Example Scala plugin • Servlet & XWork action • Confluence macro • REST via Jersey/Jackson • Build setup • Use as a starting point https://bitbucket.org/ssaasen/atlassian-scala-example-plugin 61
  • 62. Let’s recap • Replace Java entirely with Scala or mix and match • Runtime library: 3 deployment options • Fits into the AMPS development workflow • Scala Gotchas: watch out for common problems • “Scala is a great fit to write Atlassian plugins in” 62
  • 63. Agenda • Why? • How? • Example 1: Scala • Example 2: JRuby • Go and do it! 63
  • 64. (J)Ruby • Dynamic, object-oriented language • Everything is an object (no “primitives”) • Meta-programming and open, executable classes allow for easy creation of DSLs • JRuby: Ruby runtime written in Java 64
  • 65. 65
  • 66. How? 66
  • 67. Overview Ruby Ruby files *.rb Your Ruby Standard RubyGems jrubyc Code Library Ruby Runtime Java Bytecode *.class Java Java Standard Library javac JVM 67
  • 68. 68
  • 69. 69
  • 70. 70
  • 72. But we can still use Ruby in a plugin! 72
  • 73. Recipe for using JRuby • Embed the Ruby Runtime • Use Java to execute Ruby scripts and classes • Make components of the host application available • Use the script execution result in Java 73
  • 74. Embedding Strategies • javax.scripting - JSR 223 • Apache Bean Scripting Framework (BSF) • JRuby Embed - lower level JRuby API 74
  • 75. Embedding Strategies • javax.scripting - JSR 223 Only configurable via system properties :( • Apache Bean scripting framework (BSF) No point in adding a separate API • JRuby Embed - lower level JRuby API 75
  • 76. 76
  • 77. Building the plugin • Package Ruby files • Download and package Ruby gems • Make Ruby gems available on the Ruby LOAD_PATH • Bundle everything into a plugin jar file • A lot of Maven XML :) • Caveat: JRuby runtime is even larger! 77
  • 78. Show me the code! 78
  • 79. 79
  • 80. 80
  • 81. 1 minute 81
  • 82. 82
  • 83. 83
  • 84. 84
  • 85. 85
  • 86. 86
  • 87. 87
  • 88. 88
  • 89. 89
  • 90. Example JRuby plugin • How to use Rubygem based libraries in a plugin • How to access host components in Ruby • How to use the execution result • Sinatra in Confluence ;-) https://bitbucket.org/ssaasen/atlassian-jruby-example-plugin 90
  • 91. Let’s recap • The plugin can’t be written in Ruby! • Use the Ruby runtime • Development workflow bonus: dynamic reloading! • The overhead of adding the runtime and providing Java glue code makes this only feasible for high value use cases :( 91
  • 92. Conclusion • Scala is a great alternative when developing an Atlassian plugin • JRuby is powerful, makes developing in a dynamic language possible but requires more work and custom Java adapter code • Java interoperability needs to be well understood in both cases 92
  • 93. TAKE-AWAYS “ The power of the Atlassian plugin framework allows you to build your plugins the way you want and ” Java doesn’t have to be the limit. #atlascamp 93
  • 95. • “Happy Foods” by swanksalot http://www.flickr.com/photos/swanksalot/5021262869/ • “Construction” by Daniel Morris http://www.flickr.com/photos/danielmorris/275438405/ • “70 80 90” by roujo http://www.flickr.com/photos/tekmagika/437989361 95