This section needs to be updated for the latest version of ONOS, which is built using buck rather than mavenpage is kept here if you need to work on an older version of ONOS that used Maven.
Starting from ONOS 1.14 we use Bazel to build and to import the project in the IntelliJ IDE
The project does not enforce the use of a specific IDE, but rather, a set of guidelines that can be configured in an IDE. The examples and documentation focus on IntelliJ IDEA, and include some help for Eclipse. For other IDEs, developers should consult the documentation for the IDE of choice for specific configuration steps.
If you have no idea where to start, here are some instructions on how to install IntelliJ. The ONOS Screencasts page provides helpful videos on importing, debugging, and developing ONOS with IntelliJ.
A helpful screencast illustrating the entire import process can be found here (the link to the video is at the top of the page). Assuming you have obtained the source code already, the following steps can be followed to import ONOS into IntelliJ:
- To import the ONOS project, simply open IntelliJ IDEA and select: File… New… Project from Existing Sources
- If you are starting IDEA for the very first time and don’t have any existing projects, you can alternatively select: Import Project… from the initial options.
- When presented with a file selection dialog, you should navigate to the top of the ONOS source tree and select the root pom.xml file. This will initiate the project import wizard.
- On the first screen we only need to check Sources and Documentation and then press Next.
- Select Next to bypass the Maven profiles.
- Make sure that the org.onosproject:onos Maven project is selected and press Next.
- After this select the JDK 8. If selecting JDK for the very first time, you may need to press the + sign to locate the JDK home directory. Press Next and then Finish.
- At this point IntelliJ will complete the import process by building the project and indexing the source files.
Importing the settings
While the project is being processed, we can go ahead and import the recommended IDEA settings. We do this by selecting File… Import Settings… and then navigating to the ONOStools/dev directory and selecting the idea-settings.jar file. We can complete the process by pressing the OK button.
If IntelliJ is throwing errors like "The package 'org.onosproject.cluster' is not exported by the bundle dependencies," go to IntelliJ IDEA->Preferences. On the sidebar, under the Editor dropdown section, select Inspections. From there, search OSGi and under the OSGi dropdown, uncheck Package accessibility inspections and press OK.
Importing the Copyright header
Since ONOS is licensed under Apache 2 license, we need to make sure that all source files are properly decorated with the Apache 2 license header file.
Then we will make sure that the newly created ONOS copyright profile is the default and we are done.
As ONOS is a multi-module project, it may appear as a collection of many (about 50 at the time of this writing) projects beginning with "onos-". This is normal for some IDEs such as Eclipse.