SlideShare a Scribd company logo
GitBucket
Open source self-hosting Git server built by Scala
Naoki Takezoe
@takezoen
Who am I?
Naoki Takezoe
● Software Engineer at Treasure Data
○ Presto (Trino) and Spark
● 10 years experience with Scala
○ GitBucket, Scalatra, Apache PredictionIO, etc
○ Japanese edition of Scala Puzzlers
GitBucket is...
GitBucket is...
● Open source self-hosting Git server
● Initial commit was April 2013
● Built by Scala and Java technologies
Current status (Feb 6, 2021)
● 8266 stars
● 158 contributors
● 719 gitter users
● 98 releases
Start GitBucket right now!
● Download gitbucket.war from
○ https://github.com/gitbucket/gitbucket
● Run
● Official Docker image is available
$ java -jar gitbucket.war
$ docker run -d -p 8080:8080 gitbucket/gitbucket
Motivation
Motivation
● In-house Git repository
○ Due to company's security policy?
○ Due to contract with customers?
● Solutions
○ GitHub Enterprise was expensive
○ GitLab installation was awkward
I must make it myself! by
Why ?
From First Principles: Why Scala? by Li Haoyi
https://www.lihaoyi.com/post/FromFirstPrinciplesWhyScala.html
● "A Compiled Language that feels Dynamic"
○ Compiled language + Scripting launguage
○ Easy to write with safety
● "A Broad and Deep Ecosystem"
○ Existing Java resources can be leveraged
○ JGit: Pure Java Git implementation
○ Zero dependencies (except JVM) inspired by Jenkins
Personal reasons:
● Wanted to write a real-world applications in Scala
● Just for fun :-)
Tour of GitBucket
Repository viewer
Issues
Pull requests
Major Features
● Public and private repository hosting
● Dashboard includes activity timeline
● Repository viewer which supports online file editing
● Markdown available Wiki
● Issues and pull requests
● Comment on source code
● Notification via E-mail
● User and group management
● LDAP integration
● Gravator integration
● GitHub compatible Web API
● Plugin system
● External database support (MySQL and PostgreSQL)
Kanban and Gantt chart
Continuous Integration
Major plugins
Name Description
Gist plugin Add code snippet Gist-like functionality to GitBucket
Asciidoc plugin Add AsciiDoc support to GitBucket
Bugspots plugin Apply Google Bugspots to code in GitBucket repositories
Pages plugin Publish repository contents as web sites
Network plugin Add the commit graph view to GitBucket
Emoji plugin Emoji support in Wiki or Issues
RST plugin Add ReStructuredText support to GitBucket
Explorer plugin Add the tree view for repositories on GitBucket
PlantUML plugin Render PlantUML files on GitBucket
Jupyter plugin Render Jupyter or IPython files on GitBucket
Fess Plugin Add full text search capability to GitBucket
Maven repository plugin Host in-house maven repositories on GitBucket
Visit https://gitbucket-plugins.github.io/ to find other plugins!!
Technology
Technology stack
Git Repository
RDBMS
(H2 / MySQL / PostgreSQL)
JGit Slick
Apache MINA SSHD
Jetty
GitServlet (JGit) Scalatra + Twirl
Git Client Web Browser
SSH HTTP
Core technologies are Java components
● Jetty
● H2
● JGit
● Apache MINA SSHD
Technology stack (Java parts)
Git Repository
RDBMS
(H2 / MySQL / PostgreSQL)
JGit Slick
Apache MINA SSHD
Jetty
GitServlet (JGit) Scalatra + Twirl
Git Client Web Browser
SSH HTTP
Key to minimize development cost
Minimizing dev cost is very important for sustainability of
personal OSS projects
● Java interoperability
○ Scala has good Java interoperability
○ Benefit from existing Java software resources
● Plugin architecture
○ Keep core features minimum for maintainability
○ Leverage community resources
Because GitBucket users are not necessarily mature Scala users, we
avoid too much FP flavor in GitBucket in order to open the door to
contribution and plugin development to them.
Challenges in
long-life application with Scala
Upgrading Scala and libraries
Scala's source code level backward compatibility is great, but…
● Need to rebuild libraries for new Scala major version
● Abandoned or not-well maintained libraries can be blockers
● Some libraries changed its public interface significantly
(e.g. Slick2 -> Slick3)
Experienced Scala major upgrade 3 times
● 2.10 -> 2.11
● 2.11 -> 2.12
● 2.12 -> 2.13
The most painful upgrade!
Why upgrading to Scala 2.12 was so painful?
Git Repository
RDBMS
(H2 / MySQL / PostgreSQL)
JGit Slick
Apache MINA SSHD
Jetty
GitServlet (JGit) Scalatra + Twirl
Git Client Web Browser
SSH HTTP
Scalatra development was going down
Destructive change in Slick3
Scalatra
● Simple we framework for Scala inspired by Ruby's Sinatra
○ Traditional Java servlet based framework
○ Declarative input validation and mapping framework like Play2
○ json4s based JSON support
Scalatra development is going down
● Rise of reactive and functional programming in Scala
○ Emerge of new frameworks such as finagle, http4s and akka-http
○ Main Scalatra developers shifted to http4s
● Became a Scalatra committer
○ Boosted migration to Scala 2.12, and eventually Scala 2.13
● Reduced maintenance cost to make it sustainable
○ Dropped minor features and library dependencies
○ Forked abandoned libraries, took some into Scalatra source tree if
small enough
Slick
● Advanced Type-safe SQL builder (former Scala-Query)
○ Very powerful and flexible type-safe API
○ Sometimes generated SQL can cause performance issues,
especially on MySQL, though...
● Super painful upgrade in Slick2 -> Slick3
○ Monadic DBIO introduced in Slick3 affected all existing code
Slick2 -> Slick3 migration
● Amount of code that needs to be migrated
○ Affected all existing Slick2 based code including community
developed plugins
● Difficulty of DBIO for GitBucket users
○ GitBucket users are not mature Scala programmers
○ We wanted to keep the bar low
● Scala 2.12 version of Slick2 was not available back then
○ Eventually Scala 2.12 version of Slick2 was released, though
○ Scala 2.13 version has not been released
How we migrated to Slick3?
● Created blocking-slick library
○ Slick2 compatible blocking API on the top of Slick3
https://github.com/takezoe/blocking-slick
● We could migrate to Slick3 with minimum effort
https://github.com/gitbucket/gitbucket/pull/1381/files
○ Also, minimized the negative impact on plugin developers
Created Java libraries, not Scala libraries
● Markedj (GitHub flavored markdown parser, Java-port of marked.js)
● Solidbase (Multi-tenant and multi-database supported migration tool
based on Liquibase)
● If the library interface is simple enough, no benefit to write in Scala
for library users.
● We don't need to rebuild a library for each major Scala version.
Effective strategy for long-term maintenance
● Minimize library dependencies
● Use Java libraries if possible
● Fork or take over library maintenance if needed
These strategies would be effective even for migration to Scala3!
Try GitBucket!
● GitHub: https://github.com/gitbucket/gitbucket
● Demo site: https://gitbucket.herokuapp.com/
● Gitter: https://gitter.im/gitbucket/gitbucket
● Blog: https://gitbucket.github.io/gitbucket-news/
● Community Plugins: https://gitbucket-plugins.github.io/
Appendix:
How to create GitBucket plugin
Create project
● build.sbt
● project/plugins.sbt
This sbt plugin adds necessary library dependencies to the project
and provide configuration and sbt task useful for GitBucket plugin
development.
Define plugin manifest
● Plugin.scala (plugin manifest)
Register new controller via
extension point
Implement plugin
● HelloWorldController.scala (Typical Scalatra controller)
Bunch of extension points are available, such as:
● Add menus and tabs
● Inject JavaScript
● Register event hooks
● etc
Build and Test
● Create a package
● Install to local GitBucket
● Template project
○ https://github.com/gitbucket/gitbucket-plugin-template
● Tutorial
○ https://gitbucket.github.io/gitbucket-news/gitbucket/2015/06/29/ho
w-to-create-plugin.html
$ sbt assembly
$ sbt install

More Related Content

What's hot (20)

PDF
Streaming Analytics & CEP - Two sides of the same coin?
Till Rohrmann
 
PDF
Hazelcast Distributed Lock
Jadson Santos
 
PDF
Why Splunk Chose Pulsar_Karthik Ramasamy
StreamNative
 
PDF
IBM DataPower Gateway appliances feature & virtual edition comparison
IBM DataPower Gateway
 
PDF
Introduction to Kong API Gateway
Yohann Ciurlik
 
PDF
Percona server for MySQL 제품 소개
NeoClova
 
PPTX
Gcp dataflow
Igor Roiter
 
PPTX
Kinesis Firehoseを使ってみた
dcubeio
 
PPTX
リクルートライフスタイルの考える ストリームデータの活かし方(Hadoop Spark Conference2016)
Atsushi Kurumada
 
PDF
Elastic Observability keynote
Elasticsearch
 
PPTX
Performance Testing
vodQA
 
PDF
Aws kms in 10 minutes
Rajendran Senapathi
 
PDF
How to Build an Apache Kafka® Connector
confluent
 
PDF
APIsecure 2023 - Learning from a decade of API breaches and why application-c...
apidays
 
PDF
What's new in API Connect and DataPower - 2019
IBM DataPower Gateway
 
PDF
Google Cloud のネットワークとロードバランサ
Google Cloud Platform - Japan
 
PPTX
Amazon Virtual Private Cloud VPC Architecture AWS Web Services
Robert Wilson
 
PDF
.NET Core時代のCI/CD
Yuta Matsumura
 
PDF
Introduction to Open Telemetry as Observability Library
Tonny Adhi Sabastian
 
Streaming Analytics & CEP - Two sides of the same coin?
Till Rohrmann
 
Hazelcast Distributed Lock
Jadson Santos
 
Why Splunk Chose Pulsar_Karthik Ramasamy
StreamNative
 
IBM DataPower Gateway appliances feature & virtual edition comparison
IBM DataPower Gateway
 
Introduction to Kong API Gateway
Yohann Ciurlik
 
Percona server for MySQL 제품 소개
NeoClova
 
Gcp dataflow
Igor Roiter
 
Kinesis Firehoseを使ってみた
dcubeio
 
リクルートライフスタイルの考える ストリームデータの活かし方(Hadoop Spark Conference2016)
Atsushi Kurumada
 
Elastic Observability keynote
Elasticsearch
 
Performance Testing
vodQA
 
Aws kms in 10 minutes
Rajendran Senapathi
 
How to Build an Apache Kafka® Connector
confluent
 
APIsecure 2023 - Learning from a decade of API breaches and why application-c...
apidays
 
What's new in API Connect and DataPower - 2019
IBM DataPower Gateway
 
Google Cloud のネットワークとロードバランサ
Google Cloud Platform - Japan
 
Amazon Virtual Private Cloud VPC Architecture AWS Web Services
Robert Wilson
 
.NET Core時代のCI/CD
Yuta Matsumura
 
Introduction to Open Telemetry as Observability Library
Tonny Adhi Sabastian
 

Similar to GitBucket: Open source self-hosting Git server built by Scala (20)

PDF
GitBucket: Git Centric Software Development Platform by Scala
takezoe
 
PDF
GitBucket: The perfect Github clone by Scala
takezoe
 
PDF
How to keep maintainability of long life Scala applications
takezoe
 
KEY
Java to Scala: Why & How
Graham Tackley
 
KEY
The Why and How of Scala at Twitter
Alex Payne
 
PDF
Tips For Maintaining OSS Projects
Taro L. Saito
 
PDF
Bitbucket Pipelines
Knoldus Inc.
 
PPT
Evolving IGN’s New APIs with Scala
Manish Pandit
 
PPTX
Difference between Github vs Gitlab vs Bitbucket
jeetendra mandal
 
PDF
My "Perfect" Toolchain Setup for Grails Projects
GR8Conf
 
PPTX
Scala adoption by enterprises
Mike Slinn
 
PDF
Difference between gitlab vs github vs bitbucket
Acodez IT Solutions
 
KEY
S2GX 2012 - Spring Projects Infrastructure
Gunnar Hillert
 
PDF
Spring Projects Infrastructure
Roy Clarkson
 
PDF
Martin Odersky: What's next for Scala
Marakana Inc.
 
ODP
Roundup presentation
mattgrommes
 
PDF
Repository Management with JFrog Artifactory
Stephen Chin
 
PDF
Scalatra 2.2
Ivan Porto Carrero
 
KEY
Scala
sryx
 
ZIP
Why Scala Presentation
guestc185e0e
 
GitBucket: Git Centric Software Development Platform by Scala
takezoe
 
GitBucket: The perfect Github clone by Scala
takezoe
 
How to keep maintainability of long life Scala applications
takezoe
 
Java to Scala: Why & How
Graham Tackley
 
The Why and How of Scala at Twitter
Alex Payne
 
Tips For Maintaining OSS Projects
Taro L. Saito
 
Bitbucket Pipelines
Knoldus Inc.
 
Evolving IGN’s New APIs with Scala
Manish Pandit
 
Difference between Github vs Gitlab vs Bitbucket
jeetendra mandal
 
My "Perfect" Toolchain Setup for Grails Projects
GR8Conf
 
Scala adoption by enterprises
Mike Slinn
 
Difference between gitlab vs github vs bitbucket
Acodez IT Solutions
 
S2GX 2012 - Spring Projects Infrastructure
Gunnar Hillert
 
Spring Projects Infrastructure
Roy Clarkson
 
Martin Odersky: What's next for Scala
Marakana Inc.
 
Roundup presentation
mattgrommes
 
Repository Management with JFrog Artifactory
Stephen Chin
 
Scalatra 2.2
Ivan Porto Carrero
 
Scala
sryx
 
Why Scala Presentation
guestc185e0e
 
Ad

More from takezoe (20)

PDF
Journey of Migrating Millions of Queries on The Cloud
takezoe
 
PDF
Testing Distributed Query Engine as a Service
takezoe
 
PDF
Revisit Dependency Injection in scala
takezoe
 
PDF
頑張りすぎないScala
takezoe
 
PDF
Non-Functional Programming in Scala
takezoe
 
PDF
Scala警察のすすめ
takezoe
 
PDF
Scala製機械学習サーバ「Apache PredictionIO」
takezoe
 
PDF
The best of AltJava is Xtend
takezoe
 
PDF
Scala Warrior and type-safe front-end development with Scala.js
takezoe
 
PDF
Tracing Microservices with Zipkin
takezoe
 
PDF
Type-safe front-end development with Scala
takezoe
 
PDF
Scala Frameworks for Web Application 2016
takezoe
 
PDF
Macro in Scala
takezoe
 
PDF
Java9 and Project Jigsaw
takezoe
 
PDF
Reactive database access with Slick3
takezoe
 
PDF
markedj: The best of markdown processor on JVM
takezoe
 
PDF
ネタじゃないScala.js
takezoe
 
PDF
Excel方眼紙を支えるJava技術 2015
takezoe
 
PDF
ビズリーチの新サービスをScalaで作ってみた 〜マイクロサービスの裏側 #jissenscala
takezoe
 
PDF
Play2実践tips集
takezoe
 
Journey of Migrating Millions of Queries on The Cloud
takezoe
 
Testing Distributed Query Engine as a Service
takezoe
 
Revisit Dependency Injection in scala
takezoe
 
頑張りすぎないScala
takezoe
 
Non-Functional Programming in Scala
takezoe
 
Scala警察のすすめ
takezoe
 
Scala製機械学習サーバ「Apache PredictionIO」
takezoe
 
The best of AltJava is Xtend
takezoe
 
Scala Warrior and type-safe front-end development with Scala.js
takezoe
 
Tracing Microservices with Zipkin
takezoe
 
Type-safe front-end development with Scala
takezoe
 
Scala Frameworks for Web Application 2016
takezoe
 
Macro in Scala
takezoe
 
Java9 and Project Jigsaw
takezoe
 
Reactive database access with Slick3
takezoe
 
markedj: The best of markdown processor on JVM
takezoe
 
ネタじゃないScala.js
takezoe
 
Excel方眼紙を支えるJava技術 2015
takezoe
 
ビズリーチの新サービスをScalaで作ってみた 〜マイクロサービスの裏側 #jissenscala
takezoe
 
Play2実践tips集
takezoe
 
Ad

Recently uploaded (20)

PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PPTX
From spreadsheets and delays to real-time control
SatishKumar2651
 
PPTX
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
PPTX
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Simplify React app login with asgardeo-sdk
vaibhav289687
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
From spreadsheets and delays to real-time control
SatishKumar2651
 
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Simplify React app login with asgardeo-sdk
vaibhav289687
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 

GitBucket: Open source self-hosting Git server built by Scala

  • 1. GitBucket Open source self-hosting Git server built by Scala Naoki Takezoe @takezoen
  • 2. Who am I? Naoki Takezoe ● Software Engineer at Treasure Data ○ Presto (Trino) and Spark ● 10 years experience with Scala ○ GitBucket, Scalatra, Apache PredictionIO, etc ○ Japanese edition of Scala Puzzlers
  • 4. GitBucket is... ● Open source self-hosting Git server ● Initial commit was April 2013 ● Built by Scala and Java technologies
  • 5. Current status (Feb 6, 2021) ● 8266 stars ● 158 contributors ● 719 gitter users ● 98 releases
  • 6. Start GitBucket right now! ● Download gitbucket.war from ○ https://github.com/gitbucket/gitbucket ● Run ● Official Docker image is available $ java -jar gitbucket.war $ docker run -d -p 8080:8080 gitbucket/gitbucket
  • 8. Motivation ● In-house Git repository ○ Due to company's security policy? ○ Due to contract with customers? ● Solutions ○ GitHub Enterprise was expensive ○ GitLab installation was awkward I must make it myself! by
  • 9. Why ? From First Principles: Why Scala? by Li Haoyi https://www.lihaoyi.com/post/FromFirstPrinciplesWhyScala.html ● "A Compiled Language that feels Dynamic" ○ Compiled language + Scripting launguage ○ Easy to write with safety ● "A Broad and Deep Ecosystem" ○ Existing Java resources can be leveraged ○ JGit: Pure Java Git implementation ○ Zero dependencies (except JVM) inspired by Jenkins Personal reasons: ● Wanted to write a real-world applications in Scala ● Just for fun :-)
  • 14. Major Features ● Public and private repository hosting ● Dashboard includes activity timeline ● Repository viewer which supports online file editing ● Markdown available Wiki ● Issues and pull requests ● Comment on source code ● Notification via E-mail ● User and group management ● LDAP integration ● Gravator integration ● GitHub compatible Web API ● Plugin system ● External database support (MySQL and PostgreSQL)
  • 17. Major plugins Name Description Gist plugin Add code snippet Gist-like functionality to GitBucket Asciidoc plugin Add AsciiDoc support to GitBucket Bugspots plugin Apply Google Bugspots to code in GitBucket repositories Pages plugin Publish repository contents as web sites Network plugin Add the commit graph view to GitBucket Emoji plugin Emoji support in Wiki or Issues RST plugin Add ReStructuredText support to GitBucket Explorer plugin Add the tree view for repositories on GitBucket PlantUML plugin Render PlantUML files on GitBucket Jupyter plugin Render Jupyter or IPython files on GitBucket Fess Plugin Add full text search capability to GitBucket Maven repository plugin Host in-house maven repositories on GitBucket Visit https://gitbucket-plugins.github.io/ to find other plugins!!
  • 19. Technology stack Git Repository RDBMS (H2 / MySQL / PostgreSQL) JGit Slick Apache MINA SSHD Jetty GitServlet (JGit) Scalatra + Twirl Git Client Web Browser SSH HTTP
  • 20. Core technologies are Java components ● Jetty ● H2 ● JGit ● Apache MINA SSHD
  • 21. Technology stack (Java parts) Git Repository RDBMS (H2 / MySQL / PostgreSQL) JGit Slick Apache MINA SSHD Jetty GitServlet (JGit) Scalatra + Twirl Git Client Web Browser SSH HTTP
  • 22. Key to minimize development cost Minimizing dev cost is very important for sustainability of personal OSS projects ● Java interoperability ○ Scala has good Java interoperability ○ Benefit from existing Java software resources ● Plugin architecture ○ Keep core features minimum for maintainability ○ Leverage community resources Because GitBucket users are not necessarily mature Scala users, we avoid too much FP flavor in GitBucket in order to open the door to contribution and plugin development to them.
  • 24. Upgrading Scala and libraries Scala's source code level backward compatibility is great, but… ● Need to rebuild libraries for new Scala major version ● Abandoned or not-well maintained libraries can be blockers ● Some libraries changed its public interface significantly (e.g. Slick2 -> Slick3)
  • 25. Experienced Scala major upgrade 3 times ● 2.10 -> 2.11 ● 2.11 -> 2.12 ● 2.12 -> 2.13 The most painful upgrade!
  • 26. Why upgrading to Scala 2.12 was so painful? Git Repository RDBMS (H2 / MySQL / PostgreSQL) JGit Slick Apache MINA SSHD Jetty GitServlet (JGit) Scalatra + Twirl Git Client Web Browser SSH HTTP Scalatra development was going down Destructive change in Slick3
  • 27. Scalatra ● Simple we framework for Scala inspired by Ruby's Sinatra ○ Traditional Java servlet based framework ○ Declarative input validation and mapping framework like Play2 ○ json4s based JSON support
  • 28. Scalatra development is going down ● Rise of reactive and functional programming in Scala ○ Emerge of new frameworks such as finagle, http4s and akka-http ○ Main Scalatra developers shifted to http4s ● Became a Scalatra committer ○ Boosted migration to Scala 2.12, and eventually Scala 2.13 ● Reduced maintenance cost to make it sustainable ○ Dropped minor features and library dependencies ○ Forked abandoned libraries, took some into Scalatra source tree if small enough
  • 29. Slick ● Advanced Type-safe SQL builder (former Scala-Query) ○ Very powerful and flexible type-safe API ○ Sometimes generated SQL can cause performance issues, especially on MySQL, though... ● Super painful upgrade in Slick2 -> Slick3 ○ Monadic DBIO introduced in Slick3 affected all existing code
  • 30. Slick2 -> Slick3 migration ● Amount of code that needs to be migrated ○ Affected all existing Slick2 based code including community developed plugins ● Difficulty of DBIO for GitBucket users ○ GitBucket users are not mature Scala programmers ○ We wanted to keep the bar low ● Scala 2.12 version of Slick2 was not available back then ○ Eventually Scala 2.12 version of Slick2 was released, though ○ Scala 2.13 version has not been released
  • 31. How we migrated to Slick3? ● Created blocking-slick library ○ Slick2 compatible blocking API on the top of Slick3 https://github.com/takezoe/blocking-slick ● We could migrate to Slick3 with minimum effort https://github.com/gitbucket/gitbucket/pull/1381/files ○ Also, minimized the negative impact on plugin developers
  • 32. Created Java libraries, not Scala libraries ● Markedj (GitHub flavored markdown parser, Java-port of marked.js) ● Solidbase (Multi-tenant and multi-database supported migration tool based on Liquibase) ● If the library interface is simple enough, no benefit to write in Scala for library users. ● We don't need to rebuild a library for each major Scala version.
  • 33. Effective strategy for long-term maintenance ● Minimize library dependencies ● Use Java libraries if possible ● Fork or take over library maintenance if needed These strategies would be effective even for migration to Scala3!
  • 34. Try GitBucket! ● GitHub: https://github.com/gitbucket/gitbucket ● Demo site: https://gitbucket.herokuapp.com/ ● Gitter: https://gitter.im/gitbucket/gitbucket ● Blog: https://gitbucket.github.io/gitbucket-news/ ● Community Plugins: https://gitbucket-plugins.github.io/
  • 35. Appendix: How to create GitBucket plugin
  • 36. Create project ● build.sbt ● project/plugins.sbt This sbt plugin adds necessary library dependencies to the project and provide configuration and sbt task useful for GitBucket plugin development.
  • 37. Define plugin manifest ● Plugin.scala (plugin manifest) Register new controller via extension point
  • 38. Implement plugin ● HelloWorldController.scala (Typical Scalatra controller) Bunch of extension points are available, such as: ● Add menus and tabs ● Inject JavaScript ● Register event hooks ● etc
  • 39. Build and Test ● Create a package ● Install to local GitBucket ● Template project ○ https://github.com/gitbucket/gitbucket-plugin-template ● Tutorial ○ https://gitbucket.github.io/gitbucket-news/gitbucket/2015/06/29/ho w-to-create-plugin.html $ sbt assembly $ sbt install