Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

  1. Check out oparent
  2. git tag -l
  3. git co tags/1.2.3 -b 1.2.3
  4. If you want CheckStyle to ignore generated files, do the following:
    1. 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>
    2. 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>
  5. The versions in the POMs in oparent are snapshot, so we need to change those to 1.2.1
     mvn versions:set -DnewVersion=1.2.1
  6. Now build locally:
    mvn clean install

IntelliJ

Installing Intellij Community Edition on Linux 

Download

https://www.jetbrains.com/idea/download/#section=windows

Installing IntelliJ Community Edition and the Java SDK on Windows

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).


Configure ONAP code formatting for IntelliJ

ONAP is using google java style as mentioned in ONAP java style.  Import intellij-java-google-style.xml in intelliJ settings→code style→java and modify the following items,

Tabs and Indents→Indent ( from 2 to 4)

Wrapping and Braces → hard wrap at ( 120)

SO Project: Method above won't work, install plugin Eclipse Code Formatter and configure it with the corresponding xml file (so/project-configs/code-tools/onap-eclipse-format.xml)

Configure ONAP copyright for IntelliJ

You can create copyright profile to auto-generate the copyright text. e.g, add the following text to new profile,
Replace <organization name>

Expand


============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

To use SonarLint with Onap projects you need to setup a connection with SonarCloud

  1. Select, File, Settings, Tools, SonarLint.
  2. Click on + beside the 'SonarCube / SonarClod connections' box to add a new connection
  3. Set Configuration Name to something like 'ONAP'
  4. Ensure sonarcloud is selected  and click [Next]
  5. Click [Create Token]
  6. Select GitHub, logon and follow the GitHub wizard to create a Token
  7. Copy Token into IntelliJ wizard
  8. Click [Next] (might have to wait a little while your data is being downloaded)
  9. Select 'Open Network Automation Platform (ONAP)' from 'Your Organizations' and click [Next]
  10. Click [Finish] to close the wizard
  11. Click [OK] to leave settings

Then you need to bind each project to the corresponding project in GitHub/SonarCloud:

  1. Select, File, Settings, Tools, SonarLint, Project Settings
  2. Enable (check) 'Binfd project to SonarQube / SonarCloud'
  3. Select the connection created above using the [Configure the connection] button
  4. Enter the project name (e.g. 'onap_ccsdk-sli-plugins') or select it using [Search in list..] 
  5. Start typing the name of your project, and it should appear in a list box where it should be selected.
  6. Click [OK] to finish

Optional 

Python

Info

Check which version of python your project is using before installing. 

...

  1. Start the server by running:

    Code Block
    languagebash
    $ docker run -d --name sonarqube -p 9000:9000 sonarqube:latest


  2. Log in to http://localhost:9000 with System Administrator credentials (login=admin, password=admin).
  3. Click the Create new project button to analyze your first project.

Other Tools

The component you are working on may require additional tool installations, see the relevant section under Development Guides.

Troubleshooting

Appendix