Lichess Development Onboarding (IntelliJ on Linux) - lichess-org/lila GitHub Wiki

This page shows you how to set up lila on an Ubuntu Linux machine with IntelliJ IDEA.

With this setup as a newcomer to Scala and SBT, you will greatly benefit from powerful features like autocompletion, library dependency management, code formatting, debugging functionalities and many more things.

Prerequisites

Optionally (for an easy redis and mongodb setup): docker-compose

Instructions

Scala plugin

Install the official Scala plugin

Scala plugin

Clone the repositories

git clone --recursive https://github.com/lichess-org/lila.git
git clone https://github.com/lichess-org/lila-ws.git

Import the project

Import project

Thanks to the build.sbt file in the root folder, IntelliJ is smart enough to automatically detect the project as an SBT Scala project. The import should set up your project correctly:

sbt import

Dependencies should be installed automatically:

Dependencies

Folder and project structure should be detected automatically:

Folder structure

You will be asked to use the default code formatter. Please choose scalafmt:

code formatter

Repeat for the lila-ws project.

Using SBT

Working with the IDE and all its SBT features directly instead of the pure command line requires us to skip the ./lila SBT wrapper functionalities. We have to manually create our configurations once:

cp .sbtopts.default .sbtopts
cp conf/application.conf.default conf/application.conf

There are two integrated SBT tools you would want to use:

  1. SBT Tool window
  2. SBT Shell

sbt tool

sbt shell

Infrastructure

Instead of directly installing redis and MongoDB as services on your machine, you could spin up a dockerized version instead:

Write a docker-compose.yml file with those basic contents:

version: "3.3"
services:
  redis:
    image: "redis:alpine"
    ports:
      - 6379:6379
  mongo:
    image: mongo
    restart: always
    ports:
      - 27017:27017

Spin up the containers with:

docker-compose up

And after use shut them down with:

docker-compose down

Starting lila

  1. docker-compose up to start the infrastructure
  2. ./ui/build to build CSS and JS
  3. Open up the lila and lila-ws projects in IntelliJ.
  4. Go to the sbt shells in your IntelliJ projects and type run
  5. Visit http://localhost:9663/

Lichess.dev

Debugging lila

In the IntelliJ settings find the sbt build tools options and check Enable debugging:

sbt debugging

After reloading your project you should see a new button in your sbt shell:

sbt debug button

Click it and a debugger will be attached to your SBT shell. You can now set breakpoints and debug through your code!

debugger