ONAP Developer Set-Up
...
The public ssh key can then be uploaded to Gerrit (user setting, ssh keys, add new key) or elsewhere as needed for authorization.
...
MAC/OSX (to be reviewed/updated by a MAC user )
Expand |
---|
get your MBP 2016 ready for development Install homebrew package manager -
python should already be installed. - do a --version check install openstack tools install docker (dmg) - https://docs.docker.com/docker-for-mac/install/#download-docker-for-mac |
Redhat/CentOS (redundant?! to be reviewed/updated by a Redhat/CentOS user)
Expand | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Ubuntu (to be reviewed/updated by an Ubuntu user )
Expand | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Connecting to ONAP Gerrit
SSH Connection (Recommended)
...
Expand |
---|
For developers working with a proxy, you might have proxy issues connecting to Linux Foundation website. To avoid the connection issue, you must define the proxy setting for both IntelliJ and Git. To configure the proxy settings in IntelliJ; click File -> Settings -> Appearance & Behavior -> System Settings -> HTTP Proxy enter the correct proxy settings and click Apply. In case of Manual proxy configuration, while entering the Host name, there is no need to write http:// in front of the URL. For example, if the proxy value is http://one.proxy.com, you would put one.proxy.com as the Host name To configure the proxy settings for Git, play the following command: git config --global https.proxy https://<proxy username>:<proxy password>@<proxy url> git config --global http.proxy http://<proxy username>:<proxy password>@<proxy url> Note: while entering the proxy username, sometimes it may require to add the domain name in front. |
IDEs
Eclipse
Install Eclipse
Download and run the installer from: Install Eclipse. Select "Eclipse IDE for Java Developers" to install.
ONAP Eclipse Java Formatter
Download onap-java-formatter.xml and import into Eclipse.
...
Expand | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
Using the Eclipse Formatter file above and maven plugin configuration in pom.xml as per pom.xml (https://code.revelc.net/formatter-maven-plugin/ for Eclipse formatter and https://github.com/diffplug/spotless/tree/master/plugin-maven for import order)
The combination can be used in a maven command to rewrite code and imports, then checkstyle audit like so
|
Install useful plugins for Eclipse
Install EclEmma for code coverage and SonarLint for static code analysis.
Set up Sonar towards ONAP for Eclipse
To bind your projects to the ONAP Sonar server, follow the instructions below.
...
Expand | ||
---|---|---|
| ||
|
To see messages from Sonar introduced by edits made in the projects, select "Window -> Show View -> Other...". Expand "SonarLint" and select "SonarLint -> On-The-Fly".
Setting up the ONAP Checkstyle
...
for Eclipse
Set "ONAP" configuration in Eclipse
To set the newly built checkstyle files in Eclipse:
- Preferences->Checkstyle
- Click "New"
- Select "External Configuration File"
- Give it a name eg ONAP
- Point at the file <your_git_folder>/oparent/checkstyle/src/main/resources/onap-checkstyle/onap-java-style.xml
(assuming you have downloaded the oparent repo) - Click OK
- Select "ONAP" configuration and click "Set as Default"
- Select "Apply and Close"
Apply "ONAP" configuration to a project in Eclipse
Now we need to activate the checkstyle on one project and set it as the blueprint for all of them:
- Select a project in eclipse and right click-
...
- >Properties→Checkstyle
- check "Checkstyle active for this project"
- Select the "ONAP" checkstyle profile
- Click "Apply and Close"
Spread blueprint to other projects
...
for Eclipse
Now spread the profile to all other projects:
- Select all the projects you want to apply the profile to in the Eclipse project explorer (not the one that you set up above)
- Right click->Checkstyle->Configure projects from blueprint
- Select the project you set up above
- Now all the projects have the correct checkstyle setup.
Hack oparent to fix "curly bracket" issue
Expand |
---|
The first issue is that the current ONAP master tagged version of the checkstyle does not work with Eclipse Oxygen/Photon (and maybe other versions) because of the "curly bracket" issue. There is a fix on the way but it's not here yet. The current tagged version of oparent we are using in Policy is 1.2.1. To get around this issue, check out oparent, checked out the 1.2.1 tag, fixed the "curly bracket" bug and built it on my local machine.
|
Configure ONAP copyright for Eclipse
...
- Window > Preferences
- Java > Code Style > Code Templates
- Click Code and select New Java files
- Click Edit
- Paste the license below
- Click Insert Variable and add the date
- Add the organization name
- Click Apply
...
Configure ONAP copyright for Eclipse
Expand | ||
---|---|---|
|
IntelliJ
Download & Install
see https://www.jetbrains.com/idea/download/#section=windows
Configure ONAP code CheckStyle for IntelliJ
- Select, File, Settings, Tools, Checkstyle
- Click on + beside the 'Configuration File' box to add a configuration
- Set description to something like 'ONAP Rules'
- Click on Browse to select the file <your_git_folder>/oparent/checkstyle/src/main/resources/onap-checkstyle/onap-java-style.xml
(assuming you have downloaded the oparent repo) - Complete the Wizard (you can set exclusion properties if needed)
- Select the Configuration File you just added by selecting the relevant checkbox
- Click [OK] to close the settings popup
Configure ONAP copyright for IntelliJ
Expand | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
IntelliJ
Download
https://www.jetbrains.com/idea/download/#section=windows
Configure ONAP code CheckStyle for IntelliJ
- Select, File, Settings, Tools, Checkstyle
- Click on + beside the 'Configuration File' box to add a configuration
- Set description to something like 'ONAP Rules'
- Click on Browse to select the file <your_git_folder>/oparent/checkstyle/src/main/resources/onap-checkstyle/onap-java-style.xml
(assuming you have downloaded the oparent repo) - Complete the Wizard (you can set exclusion properties if needed)
- Select the Configuration File you just added by selecting the relevant checkbox
- Click [OK] to close the settings popup
Configure ONAP copyright for IntelliJ
...
- File > Settings > Editor > Copyright > Copyright Profiles
- Click the + icon and add the copyright text below
- Change the organization name
- Go to the Copyright
- Select the new copyright profile from the drop down for Default project copyright
- Click Apply
...
============LICENSE_START=======================================================
Copyright (C) $today.year <organization name>
================================================================================
Licensed under the Apache License, Version
2.0
(the
"License"
);
you may not use
this
file except in compliance with the License.
You may obtain a copy of the License at
http:
//www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an
"AS IS"
BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License
for
the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-
2.0
============LICENSE_END=========================================================
Set up SonarLint towards ONAP for IntelliJ
Prerequisites
- You need to be part of the onap organization in GitHub (see GitHub, click on your icon and select 'My Organizations')
If you are not a member of this organization email support.linuxfoundation.org and ask to be added to the onap organization in GitHub
Note. It is possible to enter a different organization if you at least member of 1 organization (you can create your own in GitHub).
The plugin wizard crashes if you are member of no organization at all, see this Bug: https://jira.sonarsource.com/browse/SLI-426
To use SonarLint with Onap projects you need to setup a connection with SonarCloud
- Select, File, Settings, Tools, SonarLint.
- Click on + beside the 'SonarCube / SonarClod connections' box to add a new connection
- Set Configuration Name to something like 'ONAP'
- Ensure sonarcloud is selected and click [Next]
- Click [Create Token]
- Select GitHub, logon and follow the GitHub wizard to create a Token
- Copy Token into IntelliJ wizard
- Click [Next] (might have to wait a little while your data is being downloaded)
- Select 'Open Network Automation Platform (ONAP)' from 'Your Organizations' and click [Next]
- Click [Finish] to close the wizard
- Click [OK] to leave settings
Then you need to bind each project to the corresponding project in GitHub/SonarCloud:
- Select, File, Settings, Tools, SonarLint, Project Settings
- Enable (check) 'Binfd project to SonarQube / SonarCloud'
- Select the connection created above using the [Configure the connection] button
- Enter the project name (e.g. 'onap_ccsdk-sli-plugins') or select it using [Search in list..]
- Start typing the name of your project, and it should appear in a list box where it should be selected.
- Click [OK] to finish
Optional
Python
Info |
---|
Check which version of python your project is using before installing. |
Download Python from https://www.python.org/downloads/
Add python binary to Path.
Install "pip3", if you plan to use git-review.
git-review
In a shell, type the following command (assumes you installed python above) :
Code Block |
---|
pip3 install git-review |
To use git review
, you have to be in a Git clone directory that already contains a (possibly hidden) .gitreview
configuration file (see Gerrit/Advanced usage#Setting up a repository for git-remote)
Info |
---|
The Git and git-review installation steps above are derived from the description at: https://www.mediawiki.org/wiki/Gerrit/git-review#Windows |
Configure Git to remember your Linux Foundation user name and email address (the user name and email address associated with your Linux Foundation login):
Code Block |
---|
git config --global user.email <your_LF_account_email>
git config --global --add gitreview.username <your_LF_user_name> |
Configure git review
Code Block | ||
---|---|---|
| ||
git config --global gitreview.remote origin |
If you are using VPN, you might encounter a proxy problem while connecting to the Linux Foundation website. To avoid the problem, you should add the proxy setting in git config, using the following command:
Code Block |
---|
git config --global https.proxy https://<proxy username>:<proxy password>@<proxy url>
git config --global http.proxy http://<proxy username>:<proxy password>@<proxy url> |
NOTE: When entering the proxy username, you might be required to add the domain name in front of the username.
Node-JS
The dcae build will install npm in most cases.
However you can install it yourself from https://nodejs.org/en/download/
Verify your installation by
Code Block |
---|
npm -v |
Local SonarQube Setup
It can be useful to have SonarQube running locally rather than pushing through CI for feedback.
This can be done using docker:
Images of the Community, Developer, and Enterprise Editions are available on Docker Hub.
Start the server by running:
Code Block | ||
---|---|---|
| ||
$ docker run -d --name sonarqube -p 9000:9000 sonarqube:latest |
...
Windows Limitations
Some repos might not clone in Windows until some file paths are reduced below 255 chars.
Enable long paths in windows as
Code Block |
---|
git config --system core.longpaths true |
Other Tools
The component you are working on may require additional tool installations, see the relevant section under Development Guides.
...
Set up SonarLint towards ONAP for IntelliJ
Prerequisites
- You need to be part of the onap organization in GitHub (see GitHub, click on your icon and select 'My Organizations')
If you are not a member of this organization email support.linuxfoundation.org and ask to be added to the onap organization in GitHub
Note. It is possible to enter a different organization if you at least member of 1 organization (you can create your own in GitHub).
The plugin wizard crashes if you are member of no organization at all, see this Bug: https://jira.sonarsource.com/browse/SLI-426
To use SonarLint with Onap projects you need to setup a connection with SonarCloud
- Select, File, Settings, Tools, SonarLint.
- Click on + beside the 'SonarCube / SonarClod connections' box to add a new connection
- Set Configuration Name to something like 'ONAP'
- Ensure sonarcloud is selected and click [Next]
- Click [Create Token]
- Select GitHub, logon and follow the GitHub wizard to create a Token
- Copy Token into IntelliJ wizard
- Click [Next] (might have to wait a little while your data is being downloaded)
- Select 'Open Network Automation Platform (ONAP)' from 'Your Organizations' and click [Next]
- Click [Finish] to close the wizard
- Click [OK] to leave settings
Then you need to bind each project to the corresponding project in GitHub/SonarCloud:
- Select, File, Settings, Tools, SonarLint, Project Settings
- Enable (check) 'Binfd project to SonarQube / SonarCloud'
- Select the connection created above using the [Configure the connection] button
- Enter the project name (e.g. 'onap_ccsdk-sli-plugins') or select it using [Search in list..]
- Start typing the name of your project, and it should appear in a list box where it should be selected.
- Click [OK] to finish
Optional Tools & Utilities
Python
Info |
---|
Check which version of python your project is using before installing. |
Download Python from https://www.python.org/downloads/
Add python binary to Path.
Install "pip3", if you plan to use git-review.
git-review
In a shell, type the following command (assumes you installed python above) :
Code Block |
---|
pip3 install git-review |
To use git review
, you have to be in a Git clone directory that already contains a (possibly hidden) .gitreview
configuration file (see Gerrit/Advanced usage#Setting up a repository for git-remote)
Info |
---|
The Git and git-review installation steps above are derived from the description at: https://www.mediawiki.org/wiki/Gerrit/git-review#Windows |
Configure Git to remember your Linux Foundation user name and email address (the user name and email address associated with your Linux Foundation login):
Code Block |
---|
git config --global user.email <your_LF_account_email>
git config --global --add gitreview.username <your_LF_user_name> |
Configure git review
Code Block | ||
---|---|---|
| ||
git config --global gitreview.remote origin |
If you are using VPN, you might encounter a proxy problem while connecting to the Linux Foundation website. To avoid the problem, you should add the proxy setting in git config, using the following command:
Code Block |
---|
git config --global https.proxy https://<proxy username>:<proxy password>@<proxy url>
git config --global http.proxy http://<proxy username>:<proxy password>@<proxy url> |
NOTE: When entering the proxy username, you might be required to add the domain name in front of the username.
Node-JS
The dcae build will install npm in most cases.
However you can install it yourself from https://nodejs.org/en/download/
Verify your installation by
Code Block |
---|
npm -v |
Local SonarQube Setup
It can be useful to have SonarQube running locally rather than pushing through CI for feedback.
This can be done using docker:
Images of the Community, Developer, and Enterprise Editions are available on Docker Hub.
Start the server by running:
Code Block language bash $ docker run -d --name sonarqube -p 9000:9000 sonarqube:latest
- Log in to http://localhost:9000 with System Administrator credentials (login=admin, password=admin).
- Click the Create new project button to analyze your first project.
Other Optional Tools
The component you are working on may require additional tool installations, see the relevant section under Development Guides.
Troubleshooting & Know Issues
Windows Limitations
Some repos might not clone in Windows until some file paths are reduced below 255 chars.
Enable long paths in windows as
Code Block |
---|
git config --system core.longpaths true |
Hack oparent to fix "curly bracket" issue
Expand |
---|
The first issue is that the current ONAP master tagged version of the checkstyle does not work with Eclipse Oxygen/Photon (and maybe other versions) because of the "curly bracket" issue. There is a fix on the way but it's not here yet. The current tagged version of oparent we are using in Policy is 1.2.1. To get around this issue, check out oparent, checked out the 1.2.1 tag, fixed the "curly bracket" bug and built it on my local machine.
|