Jump to: navigation, search

OpenDaylight Controller:MD-SAL:Startup Project Archetype

THIS PAGE IS OUTDATED, AND ONLY KEPT HERE AS LEGACY DOCUMENTATION FOR EOL RELEASES.

https://docs.opendaylight.org/en/latest/developer-guide/developing-apps-on-the-opendaylight-controller.html IS THE CURRENT DOCUMENTATION.

Introduction

This tutorial is aimed at a developer who would like a quick start to OpenDaylight Development. It will create a local repository for the code and guide you through a simple build process. Once the tutorial is complete you will be able to start OpenDaylight and the test a simple RPC. The test RPC will be one you have created, based on the principle of 'hello world'.

Ideally you will have already have a working knowledge of Maven 3.2.1 (at time of writing), Java 1.8.0_60 (at time of writing) and how to set up an environment with the correct paths/variables on your development machine. The GettingStarted: Eclipse automated set up is a convenient way to get started.

During this tutorial you will use the Maven Archetype framework, which provides a template approach to downloading projects. For more details please read http://maven.apache.org/guides/introduction/introduction-to-archetypes.html .

Setup

Once you have setup your development machine with Maven and Java, you will need to update your Maven settings.xml. If you are using GettingStarted: Eclipse, then this is automatically set up for you. Otherwise, do this by editing your settings.xml file. (You should view this file to get a better understanding as to what it is for, which is to define the repositories for this project.)

IMPORTANT: If you already have previously downloaded OpenDaylight for another project it is recommended that you remove an existing repository before you start this project. If you are simply rebuilding the projects below, having previously run this tutorial, then you don't need to delete your local repository. (If you are using Linux on as your development machine, you will find your local repository in ~/.m2/repository. Other platforms may vary.)

If you are using Windows, please make sure Microsoft Visual C++ environment is correctly installed, otherwise opendaylight will quit with error.

Part 1 - Build with a simple 'Example' module

Let's begin by creating a simple 'Example' project using Maven and an archetype called 'opendaylight-startup-archetype'.

If this is the first time you are downloading this project then it will take a while to pull all the code from the remote repository.

NOTE: If it is failing below, remove ~/.m2 directory. Also make sure you have the OpenDaylight setting.xml file as described above.

If you are using the GettingStarted: Eclipse fully automated set up, then you can now use menu File > New > Project > Maven > Maven Project, Next; Advanced: Name template: [groupId].[artifactId], and then check [X] Include snapshot archetypes, and choose Artifact Id opendaylight-startup-archetype. (Note that opendaylight-eclipse-setup already has a catalog with the required archetypeRepository from ODL.)

Otherwise, create your project with the archetype by typing:

mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype \
-DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/<Snapshot-Type>/ \
-DarchetypeCatalog=remote -DarchetypeVersion=<Archetype-Version>

You need to enter the proper <Archetype-Version> and <Snapshot-Type> that depends on the ODL release you want to work in. for example:

  • For the current Master (Carbon) use Snapshot-Type=opendaylight.snapshot Archetype-Version=1.4.0-SNAPSHOT
  • For the Carbon snapshot use Snapshot-Type=opendaylight.release Archetype-Version=1.3.0-Carbon
  • For Boron "SR0" use Snapshot-Type=opendaylight.release Archetype-Version=1.2.0-Boron
  • For Boron SR1 use Snapshot-Type=opendaylight.release Archetype-Version=1.2.1-Boron-SR1
  • For Boron SR2 use Snapshot-Type=opendaylight.release Archetype-Version=1.2.2-Boron-SR2
  • For the Boron snapshot use Snapshot-Type=opendaylight.snapshot Archetype-Version=1.2.2-SNAPSHOT

Note each version of the archetype generates version numbers in pom.xml dependencies for its intended ODL revision.

Respond to the prompts (Please note that groupid and artifactid need to be all lower case):

Define value for property 'groupId': : org.opendaylight.example
Define value for property 'artifactId': : example
Define value for property 'package':  org.opendaylight.example: : 
Define value for property 'classPrefix':  ${artifactId.substring(0,1).toUpperCase()}${artifactId.substring(1)}
Define value for property 'copyright': : Yoyodyne, Inc. 

In particular, accept the default value of classPrefix (${artifactId.substring(0,1).toUpperCase()}${artifactId.substring(1)}) which creates a Java Class Prefix by capitalizing the first character of the artifactId ( so in this example the classPrefix will be Example). If you want to change any of the defaults, say 'N' at the last question; which will give you the opportunity to change them.

Next Steps

Check out the other tutorials!