ONAP Developer Set-Up
Follow the steps below to set up the development environment on your client machine, and to establish credentials with which you may access the repositories.
Table of Contents |
---|
Create a Linux Foundation Account
Follow the instructions on the identity portal to create a Linux Foundation account and get access to the OpenECOMP ONAP Gerrit instance. Then verify
Verify that you can log in at https://gerrit.openecomponap.org/ and that you can see the OpenECOMP ONAP list of repositories.
Mac/OSX
get your MBP 2016 ready for development
generate keys - either ssh-add the key or rename it as id_rsa and put it into your ~/.ssh dir
Basic Setup
Git
Install git for your OS in accordance with httpsInstall the JDK (as dmg) - http://www.oracleatlassian.com/technetworkgit/java/javase/downloads/jdk8-downloads-2133151.html
Install homebrew package manager -
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
python should already be installed. - do a --version check
install pip - sudo easy_install pip
install openstack tools
install docker (dmg) - https://docs.docker.com/docker-for-mac/install/#download-docker-for-mac
install maven - apache-maven-3.5.0-bin.tar, create and ~./m2 and place settings.xml there
git comes with Xcode or Homebrew - do a --version check
Unix Setup
Redhat/CentOS
...
set JAVA_HOME in ~/.bashrc
...
yum install java-1.8.0-openjdk-devel
get it via alternatives --config javac
...
yum install git
yum groupinstall 'Development Tools'
...
download and install Maven 3.5.0
create an ~/.m2 folder and copy our settings.xml there
add maven to your path - check it with mvn --version
...
http://maven.apache.org/download.cgi
tar -xvf apache-maven-3.5.0-bin.tar.gz
...
Ubuntu 16.04
...
set JAVA_HOME in ~/.bashrc
...
download and install Maven 3.5.0
create an ~/.m2 folder and copy our settings.xml there
add maven to your path - check it with mvn --version
...
http://maven.apache.org/download.cgi
tar -xvf apache-maven-3.5.0-bin.tar.gz
or
sudo apt install maven
...
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-get update
apt-cache policy docker-engine
sudo apt-get install -y docker-engine
docker ps
root@obriendev:/home/ubuntu/onap# mvn clean install -U -DskipTests=true -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
-Dadditionalparam=-Xdoclint:none
...
<<TODO: describe a Linux client set-up for Git and git-review>>
To install git-review on Linux (Ubuntu), type the following command.
sudo apt-get install git-review
Windows Setup
Note: The DCAE and SDC repo will not fully clone in a windows environment (even git-bash) until some file paths are reduced below 255 chars -
Jira | ||||||
---|---|---|---|---|---|---|
|
Jira | ||||||
---|---|---|---|---|---|---|
|
Enabling long paths in windows - thanks Michael Lando
git config --system core.longpaths true |
---|
Installing Git
To install Git on your client, visit: https://www.atlassian.com/git/tutorials/install-git, and download the appropriate installation image for your host. Once downloaded, execute the installation script ("open" the .msi file).
During installation, you will see the following dialog box. Include the "Git Bash" and "Git GUI" components (this is the default).To do this, leave the following boxes checked:
If you intend to type Git commands from the Windows Command Prompt, leave the default setting for adjusting the PATH environment:
The repositories use Unix-style line-feed for line termination, so on your windows Git client, select the conversion option:
Select the following option based on your own preference (non-default shown, so 'winpty' is not required):
Choose the defaults here:
The installer lets you choose the experimental 'difftool'; either choice will work. Continue with the installation dialogs until the installation is complete.
Install Python on Windows (optional)
Not all components require Python for development. See the documentation for your component in the Development Guides section. (Note: the "node-gyp" tool requires Python.)
Download Python version 2.7.10:
Execute the install file that you just downloaded. (You must have administrative privileges.) During installation, select "Add python.exe to Path", overriding the default setting. Also, be sure to install "pip" (this is the default).
Continue with the installation until it is completed.
Set up Git review and Configure Git
Run Git Bash as Administrator (for example, in Windows 10, use the Windows menu, scroll to the Git directory, right-click on Git-bash, and select "Run as administrator":
Within Git Bash, type the following command:
$ pip 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), otherwise you will get the error message UnboundLocalError: local variable 'no_git_dir' referenced before assignment.
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):
git config --global user.email <your_LF_account_email>
git config --global --add gitreview.username
<your_LF_user_name>
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:
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.
Install Putty and Generate Keys
Info |
---|
An alternate method for creating public and private keys, without using PuTTY, is given here: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/ |
Info |
---|
If you already have keys registered with PuTTY, skip this section. |
PuTTY is a terminal emulator that uses Secure SHell (SSH) to communicate with a host. You need to install PuTTY in order to create a public/private encryption key pair. This pair of keys enables Git to communicate securely with the repositories.
To install PuTTY, visit, www.putty.org and follow the links to the appropriate Windows installation for your machine (32-bit or 64 bit). The downloaded file will be named putty-0.67-installer.msi
or the like.
Execute the .msi
file. Use all the default settings, thereby ensuring that you will install pageant.exe
, plink.exe
, and puttygen.exe
.
Generate Public and Private Keys
OSX
...
ssh-keygen -t rsa
...
The puttygen
utility, installed with putty
, generates public and private keys used for secure communication with Gerrit.
Info |
---|
You should execute |
To do this, right-click on C:\Program Files (x86)\PuTTY\puttygen.exe
and select Run as Administrator:
Answer "Yes" to the User Account Control challenge. Then click the "Generate" button in the puttygen window. puttygen will ask you to move your mouse over its dialog box to generate random seed bits. After it has computed a public key, it will display a dialog box resembling the following:
If you want to edit this key pair in the future, create a text file containing a short phrase, called a "passphrase". Copy and paste this passphrase into the "Key passphrase" and "Confirm passphrase" lines, then select "Save public key" and choose a filename (e.g. public.txt
); also "Save private key" and choose another filename (e.g. private.ppk
). Since you ran puttygen
as Administrator, the files are visible to Windows Explorer.
Close puttygen
.
Load Your Private Key Into Pageant
Pageant is an SSH authentication agent. It holds your private keys in memory, already decoded, so that you can use them often without needing to type a passphrase.
To load your private key into pageant
, right-click on the private key file (e.g. private.ppk
in this example), and select Load into pageant
:
This action not only loads private.ppk
into pageant, but also starts pageant if it is not already running. You will be prompted for the passphrase that you entered into puttygen
when you created the key. If successful, pageant will load the key without further interaction.
Panel | ||
---|---|---|
| ||
You can right-click on this icon to perform actions with pageant, including "View Keys" (which brings up a dialog box that allows you to add or remove keys.) The "Add Key" button offers another way to enter your private key into pegeant: after clicking on "Add Key", select the file containing your private key (for example, |
Set the GIT_SSH Environment Variable
From the Desktop, right-click the Windows logo at the very bottom left corner of the screen, , and select "System". Within the System dialog box, select "Advanced system settings" to get the Power User Task Menu.
In the next dialog box, select "Environment Variables":
If you don't already have a GIT_SSH entry in your System Variables list, click "New..." and create GIT_SSH, defined to be the location of plink.exe
:
Copy/paste the known_hosts entries listed, into a file named known_hosts under your .ssh profile (something like C:\Users\<my-id>\.ssh) (if known_hosts does not exist, create it).
Install NodeJS
The dcae build will install npm in most cases - however if you run into issues like the following - install it yourself
...
verify your install by doing
$ npm -version
3.10.10
From git bash
...
IDEs
IDE: Eclipse: Does Not Support Gerrit Plugin
Eclipse plugins (including the Mylin Gerrit connector plugin and Egit) do not support a 2.12 Gerrit server, so if you use Eclipse as your development IDE, you must do reviews using the Gerrit web interface.
IDE: IntelliJ
Installing IntelliJ Community Edition and the Java SDK on Windows
If you are using IntelliJ to do Java compilations, download the IntelliJ installation image from https://www.jetbrains.com/idea/. The installation dialog gives you the opportunity to associated IntelliJ with file type .java, among others. Installation takes several minutes.
When you start your first IntelliJ project, you will need to specify the Java Software Development Kit (SDK) as the project's. If you do not have the Java SDK installed on your machine, you can download it from within IntelliJ by selecting Maven as the New Project type and clicking on "Download SDK": (Or, visit http://www.oracle.com/technetwork/java/javase/downloads/index.html).
Installing the Gerrit plugin in IntelliJ
Open File -> Settings -> Plugins of IntelliJ, and click on the Browse repositories... button.
In the new window, search for Gerrit, click Install to install the plugin, and finally restart IntelliJ.
To verify whether the Gerrit plugin is installed successfully, you can click File -> New -> Project from Version Control and verify whether Gerrit is present.
Other Tools
The component you are working on may require additional tool installations, see the relevant section under Development Guides.
Maven
For console (mvn) Install maven 3.3.3+ (currently 3.5.0) - as 3.2.x will have issues with the ODL certificate not matching
Selecting a connection method
Once Git is installed, you will need to select a connection method to the Gerrit host, https://gerrit.openecomp.org/.
We recommend using SSH, in which case you need to register your private key in your account settings on the Gerrit host. However, if you are using a Virtual Private Network (VPN), you will require the HTTPS method, since most VPNs won't allow an ssh connection.
...
Log in to the Gerrit host https://gerrit.openecomp.org/, pull down the menu under your user name (at the extreme top right of the browser window), click on "Settings":
Click your account name on the top right corner of the website and click on Settings.
In the Settings window, select SSH Public Keys, and then click Add Key... .
...
If you choose to use HTTP/HTTPS, you'll need to generate an access password. Log in to the Gerrit host https://gerrit.openecomp.org/, pull down the menu under your user name (at the extreme top right of the browser window), click on "Settings", and select "HTTP Password":
The icon at the right of the generated password allows you to copy the generated password to your clipboard, it will be needed when you interact with Git/Gerrit.
This password may have a limited time to live, so you might get errors like this one:
Problem running 'git remote update gerrit'
Fetching gerrit
fatal: unable to access 'https://USERNAME@gerrit.openecomp.org/r/a/mso/ ': Unknown SSL protocol error in connection to gerrit.openecomp.org:443 error: Could not fetch gerrit
Regenerating a password will most likely solve the connectivity issue. Sometimes, the Gerrit interface on HTTPS might be temporarily faulty, so retries might be needed.
Working with a Proxy
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.
Building all ONAP projects
Maven Example settings.xml
Maven settings.xml file is located in ~/.m2/settings.xml
20170512 note addition of the 5th repo which will resolve some libraries in maven central that don't proxy through releases/snapshots repos https://nexus.onap.org/content/repositories/public, we also need the staging repo for some log handling versions.
View file | ||||
---|---|---|---|---|
|
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=2 tabstop=2: -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>openecomp-staging</id>
<repositories>
<repository>
<id>openecomp-staging</id>
<name>openecomp-staging</name>
<url>https://nexus.onap.org/content/repositories/staging/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>openecomp-staging</id>
<name>openecomp-staging</name>
<url>https://nexus.onap.org/content/repositories/staging/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>openecomp-public</id>
<repositories>
<repository>
<id>openecomp-public</id>
<name>openecomp-public</name>
<url>https://nexus.onap.org/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>openecomp-public</id>
<name>openecomp-public</name>
<url>https://nexus.onap.org/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>openecomp-release</id>
<repositories>
<repository>
<id>openecomp-release</id>
<name>openecomp-release</name>
<url>https://nexus.onap.org/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>openecomp-release</id>
<name>openecomp-release</name>
<url>https://nexus.onap.org/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>openecomp-snapshots</id>
<repositories>
<repository>
<id>openecomp-snapshot</id>
<name>openecomp-snapshot</name>
<url>https://nexus.onap.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>openecomp-snapshot</id>
<name>openecomp-snapshot</name>
<url>https://nexus.onap.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>opendaylight-release</id>
<repositories>
<repository>
<id>opendaylight-mirror</id>
<name>opendaylight-mirror</name>
<url>https://nexus.opendaylight.org/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>opendaylight-mirror</id>
<name>opendaylight-mirror</name>
<url>https://nexus.opendaylight.org/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>opendaylight-snapshots</id>
<repositories>
<repository>
<id>opendaylight-snapshot</id>
<name>opendaylight-snapshot</name>
<url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>opendaylight-snapshot</id>
<name>opendaylight-snapshot</name>
<url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>openecomp-staging</activeProfile>
<activeProfile>openecomp-public</activeProfile>
<activeProfile>openecomp-release</activeProfile>
<activeProfile>openecomp-snapshots</activeProfile>
<activeProfile>opendaylight-release</activeProfile>
<activeProfile>opendaylight-snapshots</activeProfile>
</activeProfiles>
</settings>
|
If you are behind a proxy you can add a proxy section to your settings.xml
...
language | xml |
---|
...
Since this is common for all OS, we will also use it to generate our SSH keys as well :
Code Block |
---|
ssh-keygen |
This should generate a private and public ssh key.
The public ssh key can then be uploaded to Gerrit (user setting, ssh keys, add new key) or elsewhere as needed for authorization.
Java
ONAP is moving to Java 11 but many projects still use Java 8.
Download and install the appropriate openjdk version in accordance with the component you are working and set JAVA_HOME environment variable to point to that
Maven
Download the latest Maven using installer from https://maven.apache.org/download.cgi
Add maven to your path variable.
To test the new installation run:
Code Block |
---|
mvn -version |
Use the settings.xml found in the oparent repo
Save this Maven settings.xml as your ~/.m2/settings.xml (windows c:\users\<username>\.m2)
WSL users can point to one common repo across Windows and Ubuntu as :
Code Block |
---|
ln -s /mnt/c/Users/<username>/.m2 ~ |
Proxy settings for Maven (if required)
If you are behind a proxy you can add a proxy section to your settings.xml
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<proxies>
<proxy>
<id>evil-corp-http</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.evil-corp.com</host>
<port>599</port>
<nonProxyHosts>localhost|127.0.0.1|*.evil-corp.com|*.happy.evil-corp.com|fun.evil-corp.com</nonProxyHosts>
</proxy>
<proxy>
<id>evil-corp-https</id>
<active>true</active>
<protocol>https</protocol>
<host>proxy.evil-corp.com</host>
<port>599</port>
<nonProxyHosts>localhost|127.0.0.1|*.evil-corp.com|*.happy.evil-corp.com|fun.evil-corp.com</nonProxyHosts>
</proxy>
</proxies> |
OS Specific Instructions
MAC/OSX (in review under 10.15.7)
Expand |
---|
get your MBP 2020 16 inch ready for development - refer to http://wiki.obrienlabs.cloud/display/DEV/Developer+Guide#DeveloperGuide-OSX 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 (in review under RHEL 8.3)
Expand | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Ubuntu (in review under 20.04 )
Expand | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Connecting to ONAP Gerrit
SSH Connection (Recommended)
Log in to the Gerrit host https://gerrit.onap.org/, pull down the menu under your user name (at the extreme top right of the browser window), click on "Settings":
Click your account name on the top right corner of the website and click on Settings.
Add the public ssh key that you created in the previous step.
HTTPS Connection
Expand |
---|
If you choose to use HTTP/HTTPS, you'll need to generate an access password. Log in to the Gerrit host https://gerrit.onap.org/, pull down the menu under your user name (at the extreme top right of the browser window), click on "Settings", and select "HTTP Password" This password may have a limited time to live, so you might get errors like this one: Problem running 'git remote update gerrit' Regenerating a password will most likely solve the connectivity issue. Sometimes, the Gerrit interface on HTTPS might be temporarily faulty, so retries might be needed. |
Proxy setting for IntelliJ and Git (if required)
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.
(updates to the settings should be committed and merged back into the repository)
ONAP uses Google Java Style with some modifications. ( See Java code style )
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.
Your projects should be imported in to Eclipse before this.
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.
Configure ONAP copyright for Eclipse
Expand | ||
---|---|---|
|
IntelliJ
Download & Install
see https://www.jetbrains.com/idea/download/#section=windows
Make sure you have added the Checkstyle plugin . Follow the below link
https://plugins.jetbrains.com/plugin/1065-checkstyle-idea
Configure ONAP code CheckStyle Plugin 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 code style auto formatting for IntelliJ (using the same checkstyle rules and automating it for you )
- Select, File, Settings, Editor, Code Style
- Click on the gear icon at the end of the line for "Scheme:"
- Optional: As importing a schema overrides the current scheme you might want to first use the 'Duplicate..' and 'Rename...' options to create an easily identifiable scheme e.g. 'ONAP Standard'
- Import Scheme→Checkstyle Configuration
- 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) - Click OK
Configure ONAP copyright for IntelliJ
Expand | |
---|---|
|
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 - Make sure you have added the SonarLint plugin
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) 'Bind 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 (optional)
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.
|