GettingStarted:Development Environment Setup

无人久伴 提交于 2020-03-01 01:25:35

GettingStarted:Development Environment Setup

Contents

 [hide

Overview

This page is intended to help developers get started on setting up their development environment, specifically links to operating systems, tools and utilities that prove useful during development.

Quick Start

If you are looking for a quick start, consider downloading one of the Fedora VMs located on the downloads page of the OpenDaylight project, specifically the Techtorial Fedora VM.

Manual Set Up

Mac OS-X

1) Download and install latest JDK (e.g. JDK8)

http://www.oracle.com/technetwork/java/javase/downloads/

2) Download and install Maven (e.g. Maven 3.3.3)

http://maven.apache.org/download.cgi

3) Set following environment variables in your ~/.profile

export ODL_USERNAME=${YOUR_GERRIT_ID}
export MAVEN_OPTS="-Xmx1024m"
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
export PATH=${JAVA_HOME}/bin:${PATH}
export M2_HOME=${WHERE_YOU_UNZIPPED_MAVEN}/apache-maven-${MVN_VERSION}
export PATH=${M2_HOME}/bin:${PATH}

export KARAF_DEBUG=true
export JAVA_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"

The remainder of this guide discusses how to set up a development environment in Fedora or Ubuntu Linux.

Linux Operating System

Fedora

Follow the steps on the Get Fedora page.

Ubuntu

Information on Ubuntu Desktop can be found here: Ubuntu Deskop.

Download and install the Java JDK

OpenDaylight requires Java 7 JDK for Lithium (current release). For Beryllium (upcoming release) a Java 8 JDK may be required.

Fedora:

sudo dnf install java-1.7.0-openjdk java-1.7.0-openjdk-devel

or

sudo dnf install java-1.8.0-openjdk java-1.8.0-openjdk-devel

Ubuntu:

sudo apt-get install openjdk-7-jdk

or

sudo apt-get install openjdk-8-jdk

Download and install maven

OpenDaylight uses Apache Maven for building all projects. You need to have version 3.3.1 or later installed.

Fedora:

sudo dnf install maven

Ubuntu:

sudo apt-get install maven

NOTE: For Ubuntu the default version installed for Maven is 3.0.5. Some projects are moving to a newer version of Maven so you can optionally go directly to the Download Maven page and grab a newer version, or install a newer Maven package from Ubuntu (download the maven and libmaven3-core-java packages).

Install Git

OpenDaylight maintains all its code in Git repositories. You will need a git client to access them.

Fedora:

sudo dnf install git

Ubuntu:

sudo apt-get install git-core

Edit your ~/.m2/settings.xml

OpenDaylight maintains its own repositories outside of Maven Central, which means maven cannot resolve OpenDaylight artifacts by default. Since OpenDaylight is organized as multiple inter-dependent projects, building a particular project usually means pulling in some artifacts. In order to make this work, your maven installation needs to know the location of OpenDaylight repositories and has to taught to use them.

This is achieved by making sure ~/.m2/settings.xml looks something like the copy kept in odlparent. You can do that quickly with the following command"

cp -n ~/.m2/settings.xml{,.orig} ; \
wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml

If you are behind a proxy, you might need to add proxy configuration to ~/.m2/settings.xml. Read - Maven proxy configuration

【Attention Please!】Edit by Mao Jianwei

If you get this Failure:

[WARNING] Error initializing: org.codehaus.plexus.velocity.DefaultVelocityComponent
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils

Add this dependency in the ~/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin/{version}/maven-archetype-plugin-{version}.pom

<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.6</version>
</dependency>

Optional: Increase the amount of RAM maven can use

Some of OpenDaylight's projects are quite big and may cause your builds to be slower than necessary. You can tell maven to have more memory at its disposal by setting the MAVEN_OPTS environment variable. To do this, edit your ~/.bashrc (or ~/.zshrc, or similar depending on you shell):

vi ~/.bashrc

Add the following:

export MAVEN_OPTS='-Xmx1048m -XX:MaxPermSize=512m'

Note, you can increase the heap space, the -Xmx setting, to greater than 1G if memory is available. When building in maven, the max memory reached will be displayed at the end of the build. You can use this as a guide to determine if more memory would help decrease build times. Approx 1.5G of RAM is needed by the JVM to run the Helium Controller repeatedly and avoid OOM errors.

Optional: Install Wireshark

Wireshark is a packet capture and inspection tool. You may find it handy when working with southbound plugins.

Fedora:

sudo dnf install wireshark

Ubuntu:

sudo apt-get install wireshark

Per-project environment setup incl. Eclipse IDE

Once you have reached this step, your environment has basic prerequisites to do development on OpenDaylight projects. Individual projects may require further setup, though. Consult the next steps outline on the Getting Started page, in particular the GettingStarted: Eclipse IDE set-up page.

Note: If you find there are missing tools or utilities that are required for a develop to get started, please add them to the list!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!