Adding a maven archetype to kick start DLUX application creation. 35/24735/2
authorHarman Singh <harmasin@cisco.com>
Mon, 3 Aug 2015 21:17:30 +0000 (14:17 -0700)
committerHarman Singh <harmasin@cisco.com>
Tue, 4 Aug 2015 01:37:17 +0000 (18:37 -0700)
This archetype provides a basic structure for application including all necessary wirings.

Change-Id: I50f5096609e5e805db8b6a0f1ae724cd80d1eedd
Signed-off-by: Harman Singh <harmasin@cisco.com>
13 files changed:
archetype/pom.xml [new file with mode: 0644]
archetype/src/main/resources/META-INF/maven/archetype-metadata.xml [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/README.md [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/__rootArtifactId__-bundle/pom.xml [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/__rootArtifactId__-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/pom.xml [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__-custom.css [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.controller.js [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.module.js [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.services.js [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.tpl.html [new file with mode: 0644]
archetype/src/main/resources/archetype-resources/pom.xml [new file with mode: 0644]
pom.xml

diff --git a/archetype/pom.xml b/archetype/pom.xml
new file mode 100644 (file)
index 0000000..7053bb5
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.dlux</groupId>
+        <artifactId>dlux-parent</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+        <relativePath>../</relativePath>
+    </parent>
+    <artifactId>dlux-app</artifactId>
+    <packaging>maven-archetype</packaging>
+    <name>archetype-dlux-app</name>
+
+    <build>
+        <extensions>
+            <extension>
+                <groupId>org.apache.maven.archetype</groupId>
+                <artifactId>archetype-packaging</artifactId>
+                <version>2.2</version>
+            </extension>
+        </extensions>
+
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <artifactId>maven-archetype-plugin</artifactId>
+                    <version>2.2</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+</project>
diff --git a/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644 (file)
index 0000000..cd562f8
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype-descriptor
+        xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+        name="dlux-app"
+        xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+    <requiredProperties>
+        <requiredProperty key="stateProvider">
+            <defaultValue>$stateProvider</defaultValue>
+        </requiredProperty>
+    </requiredProperties>
+    <modules>
+        <module id="${rootArtifactId}-module" dir="__rootArtifactId__-module" name="${rootArtifactId}-module">
+            <fileSets>
+                <fileSet filtered="true" encoding="UTF-8">
+                    <directory>src/main/resources</directory>
+                    <includes>
+                        <include>**/*.*</include>
+                    </includes>
+                </fileSet>
+            </fileSets>
+        </module>
+
+        <module id="${rootArtifactId}-bundle" dir="__rootArtifactId__-bundle" name="${rootArtifactId}-bundle">
+            <fileSets>
+                <fileSet filtered="true" encoding="UTF-8">
+                    <directory>src/main/resources</directory>
+                    <includes>
+                        <include>**/*.*</include>
+                    </includes>
+                </fileSet>
+            </fileSets>
+        </module>
+
+    </modules>
+
+</archetype-descriptor>
\ No newline at end of file
diff --git a/archetype/src/main/resources/archetype-resources/README.md b/archetype/src/main/resources/archetype-resources/README.md
new file mode 100644 (file)
index 0000000..8e89a89
--- /dev/null
@@ -0,0 +1,101 @@
+This project was generated using the DLUX Maven Archetype. This is a sample project generated to kick start DLUX application creation. You should add/update JS/HTML/CSS files as per your own requirements. 
+
+This README has the following sections:
+
+* Details of project structure
+* Build and deploy the application bundle
+* Next Steps
+
+
+==========================================================
+## Details of application structure
+
+
+The application code structure is generated using the **artifactId** property provided during creation of this application. 
+
+For example, if the value of **artifactId** property was **network**, application name should be **network** and you should see two directories **network-module** and **network-bundle** along with a pom.xml file at the same location of this README file. We will use **network** as application name through out this README file.
+
+Considering **network** as application name or value for **artifactId**, generated application directory structure should be as follow - 
+
+* network-module
+* network-bundle
+* pom.xml
+* README
+
+
+### Module
+
+Following the previous example, application module such as **network-module** is a maven sub-project, that contains all of your **Javascript** code. The strcture of module project should be as follow - 
+
+       network-module
+       ---pom.xml
+       ---src
+          ---main
+             ---resources
+                ---network
+                   ---network.controller.js
+                   ---network.module.js
+                   ---network.services.js
+                   ---network.tpl.html
+                   ---network-custom.css
+
+
+The application's **angular module, controller and service name ** is also derived from **artifactId**. You should change them as per your own requirements.
+
+### Bundle
+
+Application bundle is a maven sub-project to hold **blueprint** configuration, that Karaf understands. This project depends on application module's resources. It generates a **Karaf bundle** that contains the **blueprint.xml** and **resources from module**. The structure of bundle project should be as following - 
+
+       network-bundle
+       ---pom.xml
+       ---src
+          ---main
+             ---resources
+                ---OSGI-INF
+                   ---blueprint
+                      ---blueprint.xml
+                      
+
+
+The content of **blueprint.xml** use the sample angularJS module name and directory path as defined in bundle project above. If you make any changes in directory, file or angular module Name, make sure to update blueprint.xml accordingly.
+
+
+
+================================================
+## Build and deploy the application bundle
+
+
+These steps outline how to manually build and deploy your application in Karaf.
+
+
+1. In your application root directory, build both sub-projects module and bundle via running following command - 
+
+       mvn clean install
+2. Go to the {artifactId}-bundle/target, you should see your application bundle jar.           
+    
+3. Locate your ODL distribution. You can download ODL distribution or use distribution from Integration or DLUX repository (after running a mvn clean install from the respective project's root). The path for dlux distribution is dlux/distribution-dlux/target/assembly/bin.
+
+4. Start karaf  via command ./karaf.
+
+5. Install dlux core feature via command on karaf console - 
+
+               feature:install odl-dlux-core
+
+6. Access the DLUX on browser at http://localhost:8181/index.html and login with credentials admin/admin.
+
+7. Copy your application's bundle jar to your ODL distribution deploy directory. Location for that directory for dlux distribution is dlux/distribution-dlux/target/assembly/deploy.
+
+8. Refresh the browser page, you should see your application in left hand Navigation.
+
+
+================================================
+## Next Steps
+
+1. Add your JS code in controller.js  and service.js file. 
+2. Create more HTML template files as per your requirements.
+3. Create controller and view mappings in module.js.
+4. Add your application related custom CSS in custom.css.
+5. Any static content such as Images, JS, CSS etc you will put under your application module resources, should be visible in browser with use of correct URL, because all the required wiring of URL with directory is already done in blueprint.xml
+
+you can ask any questions at **dlux-dev@lists.opendaylight.org** 
\ No newline at end of file
diff --git a/archetype/src/main/resources/archetype-resources/__rootArtifactId__-bundle/pom.xml b/archetype/src/main/resources/archetype-resources/__rootArtifactId__-bundle/pom.xml
new file mode 100644 (file)
index 0000000..8bc38fe
--- /dev/null
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>${rootArtifactId}</artifactId>
+        <groupId>${groupId}</groupId>
+        <version>${version}</version>
+    </parent>
+    <artifactId>${rootArtifactId}-bundle</artifactId>
+    <packaging>bundle</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>${osgi.core.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>${osgi.core.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>${apache.felix.compendium}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.dlux</groupId>
+            <artifactId>loader</artifactId>
+            <version>${dlux.loader.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${groupId}</groupId>
+            <artifactId>${rootArtifactId}-module</artifactId>
+            <version>${version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <resources>
+            <resource>
+                <directory>target/generated-resources</directory>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>2.6</version>
+                <executions>
+                    <!--loader Resources-->
+                    <execution>
+                        <id>unpack-loader-resources</id>
+                        <goals>
+                            <goal>unpack-dependencies</goal>
+                        </goals>
+                        <phase>generate-resources</phase>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
+                            <groupId>${groupId}</groupId>
+                            <includeArtifactIds>${rootArtifactId}-module</includeArtifactIds>
+                            <excludes>META-INF\/**</excludes>
+                            <excludeTransitive>true</excludeTransitive>
+                            <ignorePermissions>false</ignorePermissions>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Import-Package>org.osgi.service.http,
+                            org.osgi.framework;version="1.0.0",
+                            org.opendaylight.dlux.loader
+                        </Import-Package>
+                        <Export-Package></Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/archetype/src/main/resources/archetype-resources/__rootArtifactId__-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/archetype/src/main/resources/archetype-resources/__rootArtifactId__-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644 (file)
index 0000000..42dc7fc
--- /dev/null
@@ -0,0 +1,19 @@
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+    <reference id="httpService" availability="mandatory" activation="eager" interface="org.osgi.service.http.HttpService"/>
+    <reference id="loader" availability="mandatory" activation="eager" interface="org.opendaylight.dlux.loader.DluxModuleLoader"/>
+
+    <bean id="bundle" init-method="initialize" destroy-method="clean" class="org.opendaylight.dlux.loader.DluxModule">
+        <property name="httpService" ref="httpService"/>
+        <property name="loader" ref="loader"/>
+        <property name="moduleName" value="${rootArtifactId}"/>
+        <property name="url" value="/src/app/${rootArtifactId}"/>
+        <property name="directory" value="/${rootArtifactId}"/>
+        <property name="requireJs" value="app/${rootArtifactId}/${rootArtifactId}.module"/>
+        <property name="angularJs" value="app.${rootArtifactId}"/>
+        <property name="cssDependencies">
+            <list>
+                <value>src/app/${rootArtifactId}/${rootArtifactId}-custom.css</value>
+            </list>
+        </property>
+    </bean>
+</blueprint>
\ No newline at end of file
diff --git a/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/pom.xml b/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/pom.xml
new file mode 100644 (file)
index 0000000..0121518
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>${rootArtifactId}</artifactId>
+        <groupId>${groupId}</groupId>
+        <version>${version}</version>
+    </parent>
+    <artifactId>${rootArtifactId}-module</artifactId>
+    <packaging>jar</packaging>
+
+</project>
diff --git a/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__-custom.css b/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__-custom.css
new file mode 100644 (file)
index 0000000..4d9f8d2
--- /dev/null
@@ -0,0 +1,3 @@
+/**
+ *  Add your application related css here
+ */
\ No newline at end of file
diff --git a/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.controller.js b/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.controller.js
new file mode 100644 (file)
index 0000000..2eadcfe
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+define(['app/${rootArtifactId}/${rootArtifactId}.module','app/${rootArtifactId}/${rootArtifactId}.services'], function(${rootArtifactId}App) {
+
+  ${rootArtifactId}App.register.controller('${rootArtifactId}Ctrl', ['$scope', '$rootScope', '${rootArtifactId}Svc', function($scope, $rootScope, ${rootArtifactId}Svc) {
+
+    $rootScope['section_logo'] = ''; // Add your topbar logo location here such as 'assets/images/logo_topology.gif'
+
+    $scope.${rootArtifactId}Info = {};
+
+    $scope.data = "${rootArtifactId}";
+
+  }]);
+
+
+});
diff --git a/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.module.js b/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.module.js
new file mode 100644 (file)
index 0000000..333351a
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+define(['angularAMD', 'app/routingConfig', 'app/core/core.services', 'common/config/env.module'], function(ng) {
+  var ${rootArtifactId}App = angular.module('app.${rootArtifactId}', ['app.core', 'ui.router.state','config']);
+
+  ${rootArtifactId}App.config(function($stateProvider, $compileProvider, $controllerProvider, $provide, NavHelperProvider, $translateProvider) {
+    ${rootArtifactId}App.register = {
+      controller : $controllerProvider.register,
+      directive : $compileProvider.directive,
+      factory : $provide.factory,
+      service : $provide.service
+
+    };
+
+
+    NavHelperProvider.addControllerUrl('app/${rootArtifactId}/${rootArtifactId}.controller');
+    NavHelperProvider.addToMenu('${rootArtifactId}', {
+     "link" : "#/${rootArtifactId}",
+     "active" : "main.${rootArtifactId}",
+     "title" : "${rootArtifactId}",
+     "icon" : "",  // Add navigation icon css class here
+     "page" : {
+        "title" : "${rootArtifactId}",
+        "description" : "${rootArtifactId}"
+     }
+    });
+
+    var access = routingConfig.accessLevels;
+
+    ${stateProvider}.state('main.${rootArtifactId}', {
+        url: '${rootArtifactId}',
+        access: access.admin,
+        views : {
+            'content' : {
+                templateUrl: 'src/app/${rootArtifactId}/${rootArtifactId}.tpl.html',
+                controller: '${rootArtifactId}Ctrl'
+            }
+        }
+    });
+
+  });
+
+  return ${rootArtifactId}App;
+});
diff --git a/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.services.js b/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.services.js
new file mode 100644 (file)
index 0000000..de5a9f9
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+define(['app/${rootArtifactId}/${rootArtifactId}.module'],function(${rootArtifactId}App) {
+
+
+  ${rootArtifactId}App.register.factory('${rootArtifactId}Svc', function($http, ENV) {
+    var svc = {
+      base: ENV.getBaseURL("MD_SAL") + "/restconf/"
+    };
+
+    /*
+     * You can define all of your REST API interactions here.
+     */
+
+    return svc;
+  });
+
+});
diff --git a/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.tpl.html b/archetype/src/main/resources/archetype-resources/__rootArtifactId__-module/src/main/resources/__rootArtifactId__/__rootArtifactId__.tpl.html
new file mode 100644 (file)
index 0000000..b9d2e10
--- /dev/null
@@ -0,0 +1,3 @@
+<!-- This is the landing page of you application, Update the content as per your requirements -->
+
+<h4>Your {{data}} application is loaded</h4>
diff --git a/archetype/src/main/resources/archetype-resources/pom.xml b/archetype/src/main/resources/archetype-resources/pom.xml
new file mode 100644 (file)
index 0000000..3eb25aa
--- /dev/null
@@ -0,0 +1,20 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <packaging>pom</packaging>
+    <groupId>${groupId}</groupId>
+    <artifactId>${artifactId}</artifactId>
+    <version>${version}</version>
+
+    <prerequisites>
+        <maven>3.0</maven>
+    </prerequisites>
+
+    <properties>
+        <osgi.core.version>5.0.0</osgi.core.version>
+        <apache.felix.compendium>1.4.0</apache.felix.compendium>
+        <dlux.loader.version>0.3.0-SNAPSHOT</dlux.loader.version>
+    </properties>
+
+
+</project>
diff --git a/pom.xml b/pom.xml
index 1a37d5cfb00c019726496ae0471552d819f62337..ca904b0c6276e01c9f9e02c9aa16866d8654caed 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -41,7 +41,6 @@
       <mdsal.version>1.3.0-SNAPSHOT</mdsal.version>
       <branding.version>1.2.0-SNAPSHOT</branding.version>
       <karaf.resources.version>1.6.0-SNAPSHOT</karaf.resources.version>
-       <!-- bump l2switch, aaa and openflowplugin version by 1 once those projects update it-->
       <feature.l2switch.version>0.3.0-SNAPSHOT</feature.l2switch.version>
       <feature.aaa.version>0.3.0-SNAPSHOT</feature.aaa.version>
       <feature.openflowplugin.version>0.2.0-SNAPSHOT</feature.openflowplugin.version>
@@ -67,6 +66,7 @@
        <module>bundles</module>
        <module>features</module>
        <module>distribution-dlux</module>
+       <module>archetype</module>
     </modules>
 
     <build>