-
Notifications
You must be signed in to change notification settings - Fork 24
Dev's Guide: Setting up backend IDE
This sections explains how to set up IDE for local backend development.
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.
-
Inside the backends directory (
judgels-backends
), generate a new IDEA project:./gradlew idea
-
Open IDEA, then open the generated project file
judgels-backends/judgels-backends.ipr
. -
When this Gradle popup appears, click the "Load Gradle Project" button.
-
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: -
Try building the project by clicking Build -> Rebuild Project. If the build succeeded, you're all set!
We can run the app from IDEA using the following steps:
-
Open
judgels-server-app/src/main/java/judgels/JudgelsServerApplication
. Click on the green "play" button: -
Then, click "Modify Run Configuration...":
-
Modify the configurations as follows:
-
Click "OK".
-
We can now run the server by clicking Run -> Run 'JudgelsServerApplication', or alternatively, clicking the "green" play button and selecting the first option:
-
To run the grader app, follow the exact same steps above, replacing
(S|s)erver
with(G|g)rader
.
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:
-
If you add a new dependency (in one of the
build.gradle
s), reload the Gradle dependencies: -
If you write a new class with Immutables/Dagger/Hibernate annotations, hit Build -> Rebuild Project again to generate the corresponding classes.
-
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.
-
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