OpenDaylight DLUX:Create application with archetype
This tutorial is aimed at a developer who would like a quick start to DLUX application development. It will create a Hello World kind of DLUX application for you. Once the tutorial is complete you will be able to deploy and see your application in DLUX.
Ideally you will have already have a working knowledge of Maven, angularJS and requireJS.
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 .
Once you have setup your development machine with Maven and Java, you will need to update your Maven settings.xml. A quick way to do this is to download via Edit 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, default location of local repository is ~/.m2/repository. Other platforms will vary.
Build an 'exampleApp'
Let's begin by creating a simple 'exampleApp' project using Maven and an archetype called 'dlux-app'.
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. Don't panic if this takes a while
mvn archetype:generate -DarchetypeGroupId=org.opendaylight.dlux -DarchetypeArtifactId=dlux-app \ -DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ \ -DarchetypeCatalog=http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/archetype-catalog.xml
In above command you can add another command line attribute for archetype version such as -DarchetypeVersion=0.3.0-SNAPSHOT and command will look like :
mvn archetype:generate -DarchetypeGroupId=org.opendaylight.dlux -DarchetypeArtifactId=dlux-app -DarchetypeVersion=0.3.0-SNAPSHOT \ -DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ \ -DarchetypeCatalog=http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/archetype-catalog.xml
Archetype version for current DLUX master is 0.3.0-SNAPSHOT, which points to Beryllium release. For stable lithium SR1, it is 0.2.1-SNAPSHOT.
Respond to the prompts (Please note that artifactId will be used as your application name):
Define value for property 'groupId': : org.opendaylight.dlux.example
Define value for property 'artifactId': : exampleApp (Don't use an archetype name with a dash in it. )
Define value for property 'version': 1.0-SNAPSHOT: : 1.0.0-SNAPSHOT
Define value for property 'package': org.opendaylight.dlux.example: :
Ok it's all downloaded....now what?
The archetype will have create a top level directory:
in our example:
Enter the directory:
and look around:
exampleApp-bundle/ exampleApp-module/ pom.xml
Time to build the 'exampleApp' project
Let's build the project for the first time. Depending on your development machine's specification this might take a little while. Ensure that you are in the project's root directory, exampleApp/, and then issue the build command, shown below.
mvn clean install
Before you deploy 'exampleApp' in ODL distribution, You must install 'odl-dlux-core' feature.
1. Once 'odl-dlux-core' feature is installed, enter the exampleApp-bundle's target directory :
2. Copy the 'exampleApp-bundle-1.0.0-SNAPSHOT.jar' file and put it in deploy folder of ODL distribution.
3. Access DLUX UI as http://localhost:8181/index.html, you should see you application in left hand navigation.
1. You will find most of the application code (JS, CSS etc) under directory 'example-module'. Modify this code as per your need. To more about modules, look at Create a module.
2. If you plan to change your module's name, you should update your blueprint.xml configuration file, that you will find under directory 'example-bundle'. To more about DLUX application bundle, look at DLUX application configuration
3. Once satisfied, you can create a new feature for your DLUX application or make this bundle as a part of your existing feature.