Adempiere in IntelliJ IDEA
Part I: Creating Adempiere project in IntelliJ IDEA
I am an IntelliJ IDEA fanatic since its version 5. It eases all my development efforts especially its shortcut keys in its Editor and the Code refactorings as well as Inspection tool which generally guides me to avoid things that I overlooked. This is the part 1 and click here for the part 2: running adempiere in idea.
You need to have the following running on your system no matter what OS you use:
- JDK 1.6 – You can download this from the Sun website. http://java.sun.com
- IntelliJ IDEA 9 Ultimate – You can download trial version of this from http://www.jetbrains.com
- Subversion Client – http://subversion.tigris.org
You need to do the following:
- Install IntelliJ IDEA 9, JDK 1.6 and the Subversion Client.
- Set JAVA_HOME environment variable to point to your JDK 1.6 installation directory.
- For Windows:
- i. JAVA_HOME = C:\Program Files\Java\jdk1.6.0_16
- Set the PATH environment variable to have JAVA_HOME and Subversion installation directory exist
- For Windows:
- i. PATH = %PATH%;%JAVA_HOME%\bin; C:\Program Files\Subversion\bin;
Getting the Adempiere Source from the Online repository (sourceforge.net)
Repository location: https://adempiere.svn.sourceforge.net/svnroot/adempiere/trunk
- Open the IntelliJ IDEA
- Once open, Click the Version Control menu and navigate to checkout from version control.
- Click the Subversion
- Click the “+” symbol and add the repository above. It will show you figure 1 below.
- Once the repository has been loaded, right click it and click on Checkout
- Now, select the directory upon which you want to store the Adempiere trunk source.
- i. In my case it’s in C:\workspace\adempiere\trunk
Making an IntelliJ IDEA Project
Adempiere by default does not have an IntelliJ IDEA project setting. It does have however, a .classpath and .project which makes it an Eclipse project and nbproject which makes it a Netbeans project.
- In the main display of IntelliJ IDEA, Click on Create New Project
- Once the New project dialog appears, click the Import project from external model (because we will base it on the already defined eclipse project) as shown below Figure 2.
- Click Next and Select “Eclipse”
- Now, select the trunk directory and check the “Link created IntelliJ IDEA modules to Eclipse project files”. Do not change the default which is “Create module files near .classpath files” and “.idea (directory based)” project file format. Image shown below Figure 3.
- Click Next
- Check the adempiereTrunk and Click the Finish button.
- If the Subversion asks you about adding the newly created files to the repository, click No.
Now as an end result, there will be one project module present “adempiereTrunk”. When you view its module settings, all sources locate each directory. We will call it the parent project. We will proceed with the creation of the child projects.
Making the Child projects
Make the child modules in the adempiereTrunk parent folder by doing the following steps:
- Right click the adempiereTrunk in the Project tool window
- Click the New à Module
- In the New Module dialog box, select the Import module from external model
- Click Next and Select Eclipse as external model
- Click Next
- Find the module you want to import
- Check the Link created IntelliJ IDEA modules to Eclipse project files
- Check also the Create module files near .classpath files
- Click Next
- Select the Eclipse project you want to import as module
- Click Finish.
In the end, your Project tool window might look like the above image in Figure 4.
Import the modules in this order to minimize errors of dependency. Although this should not be a problem since IntelliJ will still treat correct dependency even if you imported the dependent module ahead of the depended module:
Once you’ve successfully imported all projects as a module in IntelliJ IDEA, you can now click the Rebuild Project under the Build menu. If there are errors in JasperReportsWebApp, follow instructions below.
Resolving error in JasperReportsWebApp
- Right click the JasperReportsWebApp
- Click on the Module Settings
- Click the Dependencies tab
- Click Add à Module Dependencies
- Find and add the “base”, then click OK
- Click Add à Single Entry Module Library
- You will be asked for the Path of the jars, enter the tools\lib folder i.e. C:\workspace\adempiere\trunk\tools\lib\
- Select all the jars under the folder as shown below then click OK
- Once done, you will end up like this as shown below. Click OK button when finished.
Compiling Adempiere in IntelliJ IDEA
All else successful in the above configuration, we can now compile Adempiere project.
- Click the Build menu
- Click Rebuild Project
This will show a successful compilation as shown below. No errors would be found, only warnings.
If you wanted to go back to Eclipse as an IDE; it should have no problems since the classpath is already linked with both IDE’s. In Eclipse, select all and then press F5 to refresh. Click Clean and rebuild. It should have nil errors.