Skip to content

Dev's Guide: Setting up backend IDE

Ashar Fuadi edited this page May 29, 2023 · 7 revisions

This sections explains how to set up IDE for local backend development.

Prerequisites

We highly recommend using IntelliJ IDEA. This section will only cover setup on IDEA.

The following steps were tested on IntelliJ IDEA 2023.1.2 Community Edition.

Setting up IDEA project

  1. Inside the backends directory (judgels-backends), generate a new IDEA project:

    ./gradlew idea
    
  2. Open IDEA, then open the generated project file judgels-backends/judgels-backends.ipr.

  3. When this Gradle popup appears, click the "Load Gradle Project" button.

  4. Some of our libraries (Immutables, Dagger 2, Hibernate Static Metamodel) will generate classes during compilation (e.g. judgels.jophiel.api.user.ImmutableUser). This needs to be also enabled in IDEA. Open Preferences, go to Build, Execution, Deployment -> Compiler -> Annotation Processors, then set the following options:

  5. Try building the project by clicking Build -> Rebuild Project. If the build succeeded, you're all set!

Running server/grader from IDEA

We can run the app from IDEA using the following steps:

  1. Open judgels-server-app/src/main/java/judgels/JudgelsServerApplication. Click on the green "play" button:

  2. Then, click "Modify Run Configuration...":

  3. Modify the configurations as follows:

  4. Click "OK".

  5. We can now run the server by clicking Run -> Run 'JudgelsServerApplication', or alternatively, clicking the "green" play button and selecting the first option:

  6. To run the grader app, follow the exact same steps above, replacing (S|s)erver with (G|g)rader.

Debugging server/grader from IDEA

We can debug the app from IDEA. "Debugging" is very similar to "running" the app, except that the execution will stop whenever it reaches any breakpoints we set.

The steps are very similar to the above. After modifying the configurations, we can debug the app by selection the second option from the green "play" button:

Miscellaneous

  1. If you add a new dependency (in one of the build.gradles), reload the Gradle dependencies:

  2. If you write a new class with Immutables/Dagger/Hibernate annotations, hit Build -> Rebuild Project again to generate the corresponding classes.

  3. IMPORTANT: If you have compilation errors, in some cases the annotation preprocessing won't have chance to be run. So you might get too many compilation errors related to generated classes being not found. Keep this in mind.

  4. If you have weird errors, you can try to start over the process:

    ./gradlew clean cleanIdea
    find . -name "*.ipr" | xargs rm
    find . -name "*.iml" | xargs rm
    find . -name "*.iws" | xargs rm