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
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
44. (Meta)-Annotations
• How to use @JavaAnnotation on a getter method
when defining fields?
• Scala meta annotations @beanGetter, @beanGetter,
@field, @getter, @setter
44
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
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
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
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
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
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
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