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.
...
set JAVA_HOME in ~/.bashrc | yum install java-1.8.0-openjdk-devel get it via alternatives --config javac currently export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64 | |||||
install git and development tools | yum install git yum groupinstall 'Development Tools' this will give you make and python | |||||
install npm (will also be installed automatically by the ecomp build) - TODO: UPDATE as ecomp is locked | ||||||
download and install Maven 3.6.3 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.6.3-bin.tar.gz | |||||
Add the following option to your MAVEN_OPTS in order not to periodically hang on downloading artifacts in linux | -Djava.net.preferIPv4Stack=true | |||||
enable IP4 forwarding to enable the RHEL VM to act as an edge router - without this docker containers cannot communicate | add to /etc/sysctl.conf | |||||
Install docker (required for some repos like dcae-inventory off dcae | 20190130
to install kubernetes follow Cloud Native Deployment#Scriptedundercloud(Helm/Kubernetes/Docker)andONAPinstall-SingleVM |
...
enable ubuntu desktop | apt-get update apt-get install ubuntu-desktop | |||||||
enable static IP | vi /etc/network/interfaces add iface enp0s25 inet static address 192.168.15.101 netmask 255.255.255.0 network 192.168.15.0 broadcast 192.168.15.255 gateway 192.168.15.1 dns-nameservers 8.8.4.4 | |||||||
disable strict host checking (client and server) |
| |||||||
Enable non CD repositories so an apt-get update will work | comment out the CD first line in /etc/apt/sources.list | |||||||
enable ssh if skipped during installation so we can remote ssh | sudo apt-get install openssh-server | |||||||
enable root login and gui (no sudo su -) | sudo passwd root sudo usermod -U root sudo reboot now sudo vi /etc/lightdm/lightdm.conf [SeatDefaults] greeter-session=unity-greeter user-session=ubuntu greeter-show-manual-login=true : enable root login vi /etc/ssh/sshd_config FROM: PermitRootLogin prohibit-password TO: PermitRootLogin yes systemctl restart sshd | |||||||
The 131 version of Java 8 is installed by default - currently running 151 set JAVA_HOME in ~/.bashrc or /etc/environment ubuntu@ubuntu:~$ echo $JAVA_HOME | if not sudo apt install openjdk-8-jdk | |||||||
install git and development tools | sudo apt-get install git | |||||||
install npm (will also be installed automatically by the ecomp build) | sudo apt install npm | |||||||
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 | |||||||
Add the following option to your MAVEN_OPTS in order not to periodically hang on downloading artifacts in linux | in /etc/environment -Djava.net.preferIPv4Stack=true | |||||||
Install docker (required when building docker images) | use the current as of 20180621 17.03 version in the script which is
|
...
Info |
---|
You should execute |
To do this, right-click on C:\Program Files (x86)\PuTTY\puttygen.exe
and select Run as Administrator:
...
Add the following option to your MAVEN_OPTS in order not to periodically hang on downloading artifacts in linux | -Djava.net.preferIPv4Stack=true | |||||
enable IP4 forwarding to enable the RHEL VM to act as an edge router - without this docker containers cannot communicate | add to /etc/sysctl.conf | |||||
Install docker (required for some repos like dcae-inventory off dcae |
|
...
enable ubuntu desktop | apt-get update apt-get install ubuntu-desktop | |||||||
enable static IP | vi /etc/network/interfaces add iface enp0s25 inet static address 192.168.15.101 netmask 255.255.255.0 network 192.168.15.0 broadcast 192.168.15.255 gateway 192.168.15.1 dns-nameservers 8.8.4.4 | |||||||
disable strict host checking (client and server) |
| |||||||
Enable non CD repositories so an apt-get update will work | comment out the CD first line in /etc/apt/sources.list | |||||||
enable ssh if skipped during installation so we can remote ssh | sudo apt-get install openssh-server | |||||||
enable root login and gui (no sudo su -) | sudo passwd root sudo usermod -U root sudo reboot now sudo vi /etc/lightdm/lightdm.conf [SeatDefaults] greeter-session=unity-greeter user-session=ubuntu greeter-show-manual-login=true : enable root login vi /etc/ssh/sshd_config FROM: PermitRootLogin prohibit-password TO: PermitRootLogin yes systemctl restart sshd | |||||||
Add the following option to your MAVEN_OPTS in order not to periodically hang on downloading artifacts in linux | in /etc/environment -Djava.net.preferIPv4Stack=true | |||||||
Install docker (required when building docker images) | use the current as of 20180621 17.03 version in the script
|
...
Follow instructions on: Installing the coding style settings in eclipse.
See also Java code style
ONAP Eclipse Java Formatter (Optional)
...
As per https://gerrit.onap.org/r/#/c/79312/1/onap-java-formatter.xml, an ONAP Eclipse Java Formatter XML file has been merged and can be imported into Eclipse. Updates to the settings should be committed and merged back into the repository (e.g.
Jira Legacy | ||||||
---|---|---|---|---|---|---|
|
Maven Plugins to Reformat Java code
Using the Eclipse Formatter file above and maven plugin configuration in pom.xml as per https://gerrit.onap.org/r/#/c/79312/1/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)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<plugins>
<!--
Using https://code.revelc.net/formatter-maven-plugin/ for Eclipse formatter
Using https://github.com/diffplug/spotless/tree/master/plugin-maven for import order
Use in combination to rewrite code and imports, then checkstyle
mvn formatter:format spotless:apply process-sources
-->
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<configFile>${project.parent.basedir}/onap-java-formatter.xml</configFile>
</configuration>
<!-- https://code.revelc.net/formatter-maven-plugin/
use mvn formatter:format to rewrite source files
use mvn formatter:validate to validate source files -->
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>1.18.0</version>
<configuration>
<java>
<importOrder>
<order>com,java,javax,org</order>
</importOrder>
</java>
</configuration>
<!-- https://github.com/diffplug/spotless/tree/master/plugin-maven
use mvn spotless:apply to rewrite source files
use mvn spotless:check to validate source files -->
</plugin>
</plugins> |
the combination can be used in a maven command to rewrite code and imports, then checkstyle audit like so
Code Block | ||
---|---|---|
| ||
mvn formatter:format spotless:apply process-sources |
Install useful plugins
Install EclEmma for code coverage, and SonarLint for static code analysis.
Set up Sonar towards ONAP
To bind your projects to the ONAP Sonar server, follow the instructions below. Your projects should be imported in to Eclipse before this.
- Right click on the project and select "SonarLint -> Bind to SonarQube or SonarCloud...".
- Select "sonarcloud" and press "Next".
- Click "Generate Token"
- A browser opens and you are taken to a Sonarcloud login page
- Login with an appropriate account from the list presented, most likely your GitHub account
- You are now directed to a sonarcloud token generation page
- Enter a name for your token and click "Generate"
- Copy the token hex string that is generated from the browser and paste it into the "Token" field in Eclipse and click "Next"
- In the "Organization" field, enter the string "onap" and press "Next"
- The Connection name "SonarCloud/onap" should be found by the system, click "Next"
- The connection should be successfully created, click "Finish"
- Press "Add...".
- Select the projects you want to add and press "OK".
- Press "Next".
- Start typing the name of your project, and it should appear in a list box where it should be selected.
- Press "Finish".
To see messages from Sonar introduced by edits made in the projects, select "Window -> Show Wiew -> Other...". Expand "SonarLint" and select "SonarLint -> On-The-Fly".
Setting up the ONAP Checkstyle in 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 in 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
...
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.
Hack oparent to fix "curly bracket" issue
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.
...
- Add the following tag to the above file:
<module name="SuppressionFilter">
<property name="file" value="<absolute path to the directory of the file>/suppressions.xml"/>
</module> - Create a file called "suppressions.xml" in the folder given above, and put the following content in it:
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
</suppressions>
...
Install useful plugins
Install EclEmma for code coverage, and SonarLint for static code analysis.
Set up Sonar towards ONAP
To bind your projects to the ONAP Sonar server, follow the instructions below. Your projects should be imported in to Eclipse before this.
- Right click on the project and select "SonarLint -> Bind to SonarQube or SonarCloud...".
- Select "sonarcloud" and press "Next".
- Click "Generate Token"
- A browser opens and you are taken to a Sonarcloud login page
- Login with an appropriate account from the list presented, most likely your GitHub account
- You are now directed to a sonarcloud token generation page
- Enter a name for your token and click "Generate"
- Copy the token hex string that is generated from the browser and paste it into the "Token" field in Eclipse and click "Next"
- In the "Organization" field, enter the string "onap" and press "Next"
- The Connection name "SonarCloud/onap" should be found by the system, click "Next"
- The connection should be successfully created, click "Finish"
- Press "Add...".
- Select the projects you want to add and press "OK".
- Press "Next".
- Start typing the name of your project, and it should appear in a list box where it should be selected.
- Press "Finish".
To see messages from Sonar introduced by edits made in the projects, select "Window -> Show Wiew -> Other...". Expand "SonarLint" and select "SonarLint -> On-The-Fly".
Setting up the ONAP Checkstyle in 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 in 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. Hack oparent to fix "curly bracket" issueTo 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.
|
ONAP Eclipse Java Formatter (Optional)
Expand | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
As per https://gerrit.onap.org/r/#/c/79312/1/onap-java-formatter.xml, an ONAP Eclipse Java Formatter XML file has been merged and can be imported into Eclipse. Updates to the settings should be committed and merged back into the repository (e.g.
Maven Plugins to Reformat Java codeUsing the Eclipse Formatter file above and maven plugin configuration in pom.xml as per https://gerrit.onap.org/r/#/c/79312/1/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
IntelliJ
...