Skip to content

Instantly share code, notes, and snippets.

@canweriotnow
Last active March 12, 2024 21:11
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save canweriotnow/d60f9a784f8cc4f59301 to your computer and use it in GitHub Desktop.
Save canweriotnow/d60f9a784f8cc4f59301 to your computer and use it in GitHub Desktop.

Exercism and IntelliJ IDEA

So, you want to use IntelliJ IDEA for your Exercism.io Java exercises?

Here’s my workflow. Note, using IntelliJ IDEA CE 14.

Gradle setup

  • [ ] cd to $EXERCISM_DIR/java/the-exercise
  • [ ] Run gradle idea to generate the *.iml* and =.idea files/dirs

IntelliJ

Open IntelliJ. If a project is already open, close it.

You should see the opening dialog.

Choose “Open”. Do not choose “Create new project”, “Import Project”, or anything else.

Navigate to the exercise folder, i.e. the folder just under java/ where the exercise lives. Select it, and choose “open.”

IntelliJ will try to open it like an existing IntelliJ project (which, thanks to gradle, it sort of is), rather than initiating the Rube Goldbergian “import” process which is really designed to make Eclipse projects unmanageable by Eclipse.

A wild dialog appears!

This is IntelliJ letting you know, BEHOLD, it perceives a Gradle project and would like to synchronize it for your pleasure. Click the link in that dialog. A second one will open just below that, if you keep your whole exercism directory in Git like I do. Ignore that one.

Gradle options. Wat do?

Okay, working from memory here, there will be a couple of checkboxes, unchecked by default. One is for auto-imports. Select it, this will make FEST and other things get pulled in through the Gradle dependency.

The other has to do with stubbing non-existent or empty folders or such.

You want that too, since the project only comes with test/src/ProjectTest.java and you also want main/src/Project.java - this will help you out there.

The next options get confusing. Where is my GRADLE HOME? Lost to the Cylons?

Doesn’t matter, because gradle made you some local custom wrapper scripts, so choose the radio button that says something about custom wrapper something.

The last choice is a select box for your Java runtime. Choose 1.8 if you can, since the Exercism java help page says use Java 8.

Why do we need Java 8? Well in addition to Java 7’s generics and annotations, you’ll obviously need lambda expressions to complete HelloWorld.java.

just kidding, choosing 1.7 probably won’t break anything but why wouldn’t you choose Java 8 if you can?

Fin

At this point, you should have a working project which will have all kinds of red squigglies in the test file which is referencing at least one class and method you have yet to write. So get writing, and run the damn tests!.

Oh, and have fun.

@dbc2201
Copy link

dbc2201 commented Jul 24, 2019

@canweriotnow Thank you so much, it was such a hassle to move through all of those directories just to execute everything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment