Using an IDE (Intellij)
Last updated
Last updated
A rough guide on how to develop molgenis in IntelliJ IDEA is described below. This was created using IntelliJ IDEA 2016.1 Ultimate, courteously provided to us by JetBrains on an open source license. Most of the time we use the latest IntelliJ version.
Open Preferences, Build Execution Deployment, Maven
Set the home dir to where your >= 3.1.0 maven installation lives.
File, New, Project from version control, Git (or Github)
Pick https://github.com/molgenis/molgenis.git
for the repository URL.
In the Event log: Non-managed pom.xml file found. Choose "Add as Maven Project". (You'll also see 'JPA framework is detected'. Ignore that.)
You now should have a Project called molgenis with a module for each maven module.
Open File, Project Structure. For the entire project:
(Add and) select Java 8 JDK.
Set language level to Java 8.
For normal operation, IntelliJ can compile the sources for you. But some classes get generated so you'll need to run the maven build at least once.
Run, Edit Configurations...
Press +
, add new maven run config, call it molgenis [clean install]
Set the project location as run directory
Command line is clean install
In the tool bar, select the molgenis[clean install]
configuration and press the play button.
Molgenis now should compile and test. In particular the molgenis-core-ui module may take a while the first time it is run.
Build, Make project should work fine now and spew out no errors, only warnings.
We format our code according to the Google Java Format. You can run the formatter in maven using target fmt:format
. Maven will invoke fmt:check
at build time and fail if the code isn't formatted properly.
If you miss the reformat checkbox, you can configure a git commit hook in the folder where you checked out the molgenis repository. Add a file called .git/hooks/pre-commit
with the following contents:
Make sure that your .idea project folder lives inside your molgenis git project root! Only then will we be able to auto-share templates.
Goto 'New / Edit file templates' and switch from 'Default' to 'Project'-scope.
Restart IntelliJ after setting the .idea directory and changing the settings
Adds two file templates for creating Package and EntityType classes. The templates can be accessed from the 'New' menu, when right-clicking a java package:
When choosing EntityType and filling out the form...
... a file is created with the necessary boilerplate:
Sadly, it's not possible to generate multiple files from one template, so the Metadata and Factory classes have to be manually moved to separate files. (Tip: Set your cursor to the class name and use Refactor > Move... or press F6)
Run, Edit configurations..., +
, Tomcat, Local.
Call it molgenis-app [exploded]
(Add and) select your Tomcat installation
VM options: -Dmolgenis.home=<path to dir containing molgenis-server.properties> -Xmx4g -Des.discovery.zen.ping.multicast.enabled=false -Des.network.host=localhost
Deployment: Select +
-> artifact
-> molgenis-app:war exploded
Application context: Select /
Go back to the first tab, you should now have more options in the update and frame deactivation pulldowns.
Select On Update: Redeploy, don't ask (This is the action that will triggered when you press the blue reload button in the run view)
Select On frame deactivation: Update resources (This is the action that will be triggered whenever you tab out of IntelliJ)
(If you get update classes and resources to work, let us know!!)
Select your favorite browser in the pulldown.
Save the configuration
In the tool bar, select the molgenis-app [exploded]
configuration and press the play button.
This'll build and deploy molgenis to tomcat and open it in the browser. Whenever you tab from molgenis to the browser, all modified resources will be copied to the deployed exploded war. A browser reload should display the changes.
Note: In some cases InteliJ might not pick up all changes in the file system made during the build process. This may result in an error referencing a missing jar file. This can be fixed by selecting the 'Synchronize molgenis' option from the project action menu.
Open molgenis-core-ui/target/classes/js.
Right-click the dist folder, Mark directory as..., cancel exclusion.
Open molgenis-core-ui/package.json
Select the scripts / watch key in the json configuration
Right-click it and select the NPM create watch
option from the menu.
SaveIn the tool bar, select the npm watch
configuration and press the play button to start webpack watch.
Now, whenever you make changes to one or more JavaScript files, the corresponding js bundle file will get rebuilt by the npm watch task. Once it's built, tab out of IntelliJ to trigger a refresh of the exploded war. As soon as IntelliJ loses focus, you'll see a task progress bar in the bottom right corner of IntelliJ. Wait for that task to finish and then refresh the browser. The changes will be loaded.
Building the project can be sped up by not building the javascript. To skip building the javascript, use:
-Dskip.js=true
to the maven build command.
Note:
If javascript was not already built, javascript will be missing and the application will not function properly.
If changes were made to the javascript these changes will not be built into the application (as building will be skipped).
Install and enable the .
Download and import the to fix the import order.
Uncheck the reformat checkbox in the git commit dialog, .
See also the