summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/tools/package
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/tools/package')
-rw-r--r--framework/src/onos/tools/package/README1
-rw-r--r--framework/src/onos/tools/package/archetypes/api/pom.xml31
-rw-r--r--framework/src/onos/tools/package/archetypes/api/src/main/resources/META-INF/maven/archetype-metadata.xml30
-rw-r--r--framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/pom.xml60
-rw-r--r--framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/src/main/java/AppService.java26
-rw-r--r--framework/src/onos/tools/package/archetypes/api/src/test/resources/projects/basic/archetype.properties21
-rw-r--r--framework/src/onos/tools/package/archetypes/api/src/test/resources/projects/basic/goal.txt0
-rw-r--r--framework/src/onos/tools/package/archetypes/bundle/pom.xml31
-rw-r--r--framework/src/onos/tools/package/archetypes/bundle/src/main/resources/META-INF/maven/archetype-metadata.xml36
-rw-r--r--framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml139
-rw-r--r--framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/main/java/AppComponent.java46
-rw-r--r--framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/test/java/AppComponentTest.java49
-rw-r--r--framework/src/onos/tools/package/archetypes/bundle/src/test/resources/projects/basic/archetype.properties21
-rw-r--r--framework/src/onos/tools/package/archetypes/bundle/src/test/resources/projects/basic/goal.txt0
-rw-r--r--framework/src/onos/tools/package/archetypes/cli/pom.xml32
-rw-r--r--framework/src/onos/tools/package/archetypes/cli/src/main/resources/META-INF/maven/archetype-metadata.xml36
-rw-r--r--framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/pom.xml126
-rw-r--r--framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/src/main/java/AppCommand.java33
-rw-r--r--framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-config.xml24
-rw-r--r--framework/src/onos/tools/package/archetypes/cli/src/test/resources/projects/basic/archetype.properties21
-rw-r--r--framework/src/onos/tools/package/archetypes/cli/src/test/resources/projects/basic/goal.txt0
-rw-r--r--framework/src/onos/tools/package/archetypes/pom.xml62
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/pom.xml31
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/META-INF/maven/archetype-metadata.xml38
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml139
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java76
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiMessageHandler.java189
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css35
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html46
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js139
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html1
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html1
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/test/resources/projects/basic/archetype.properties21
-rw-r--r--framework/src/onos/tools/package/archetypes/ui/src/test/resources/projects/basic/goal.txt0
-rwxr-xr-xframework/src/onos/tools/package/bin/onos-client17
-rwxr-xr-xframework/src/onos/tools/package/bin/onos-config2
-rwxr-xr-xframework/src/onos/tools/package/bin/onos-form-cluster39
-rwxr-xr-xframework/src/onos/tools/package/bin/onos-jpenable7
-rwxr-xr-xframework/src/onos/tools/package/bin/onos-secure-ssh38
-rwxr-xr-xframework/src/onos/tools/package/bin/onos-service44
-rwxr-xr-xframework/src/onos/tools/package/bin/onos-ssh6
-rwxr-xr-xframework/src/onos/tools/package/bin/onos-user-key20
-rw-r--r--framework/src/onos/tools/package/branding/pom.xml53
-rw-r--r--framework/src/onos/tools/package/branding/src/main/resources/org/apache/karaf/branding/branding.properties26
-rw-r--r--framework/src/onos/tools/package/config/README2
-rw-r--r--framework/src/onos/tools/package/config/samples/segmentrouting.conf78
-rw-r--r--framework/src/onos/tools/package/config/samples/segmentrouting_dell.conf93
-rw-r--r--framework/src/onos/tools/package/debian/onos.conf27
-rw-r--r--framework/src/onos/tools/package/etc/org.ops4j.pax.url.mvn.cfg101
-rw-r--r--framework/src/onos/tools/package/etc/org.ops4j.pax.web.cfg12
-rw-r--r--framework/src/onos/tools/package/etc/samples/linkGraph.cfg27
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.fwd.ReactiveForwarding.cfg79
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.provider.host.impl.HostLocationProvider.cfg13
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.provider.lldp.impl.LLDPLinkProvider.cfg21
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.provider.netconf.device.impl.NetconfDeviceProvider.cfg11
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg11
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg16
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.packet.impl.NullPacketProvider.cfg4
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.proxyarp.ProxyArp.cfg8
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.routing.bgp.BgpSessionManager.cfg8
-rw-r--r--framework/src/onos/tools/package/etc/samples/org.onosproject.xos.XOS.cfg0
-rw-r--r--framework/src/onos/tools/package/etc/users.properties34
-rw-r--r--framework/src/onos/tools/package/maven-plugin/pom.xml122
-rw-r--r--framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosAppMojo.java372
-rw-r--r--framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java141
-rw-r--r--framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosSwaggerMojo.java451
-rw-r--r--framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/app.xml22
-rw-r--r--framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/features.xml24
-rw-r--r--framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/registrator.javat31
69 files changed, 3501 insertions, 0 deletions
diff --git a/framework/src/onos/tools/package/README b/framework/src/onos/tools/package/README
new file mode 100644
index 00000000..3a2e4ff0
--- /dev/null
+++ b/framework/src/onos/tools/package/README
@@ -0,0 +1 @@
+Artifacts for packaging onos.tar.gz.
diff --git a/framework/src/onos/tools/package/archetypes/api/pom.xml b/framework/src/onos/tools/package/archetypes/api/pom.xml
new file mode 100644
index 00000000..d34db1f0
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/api/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-archetypes</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-api-archetype</artifactId>
+ <packaging>maven-archetype</packaging>
+
+ <description>ONOS OSGi API bundle archetype</description>
+
+</project>
diff --git a/framework/src/onos/tools/package/archetypes/api/src/main/resources/META-INF/maven/archetype-metadata.xml b/framework/src/onos/tools/package/archetypes/api/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 00000000..e35285e6
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/api/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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="onos-bundle"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
diff --git a/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/pom.xml b/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 00000000..f29a327a
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+ <packaging>bundle</packaging>
+
+ <description>ONOS OSGi API bundle archetype</description>
+ <url>http://onosproject.org</url>
+
+ <properties>
+ <onos.version>1.3.0-SNAPSHOT</onos.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.3</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/src/main/java/AppService.java b/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/src/main/java/AppService.java
new file mode 100644
index 00000000..4878f2ba
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/api/src/main/resources/archetype-resources/src/main/java/AppService.java
@@ -0,0 +1,26 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * 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.
+ */
+package ${package};
+
+/**
+ * Skeletal ONOS application API.
+ */
+public interface AppService {
+
+}
diff --git a/framework/src/onos/tools/package/archetypes/api/src/test/resources/projects/basic/archetype.properties b/framework/src/onos/tools/package/archetypes/api/src/test/resources/projects/basic/archetype.properties
new file mode 100644
index 00000000..a1213b40
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/api/src/test/resources/projects/basic/archetype.properties
@@ -0,0 +1,21 @@
+#
+# Copyright 2014 Open Networking Laboratory
+#
+# 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.
+#
+
+#Thu Dec 04 09:24:50 PST 2014
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
diff --git a/framework/src/onos/tools/package/archetypes/api/src/test/resources/projects/basic/goal.txt b/framework/src/onos/tools/package/archetypes/api/src/test/resources/projects/basic/goal.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/api/src/test/resources/projects/basic/goal.txt
diff --git a/framework/src/onos/tools/package/archetypes/bundle/pom.xml b/framework/src/onos/tools/package/archetypes/bundle/pom.xml
new file mode 100644
index 00000000..ff6aa52e
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/bundle/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-archetypes</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-bundle-archetype</artifactId>
+ <packaging>maven-archetype</packaging>
+
+ <description>ONOS OSGi bundle archetype</description>
+
+</project>
diff --git a/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/META-INF/maven/archetype-metadata.xml b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 00000000..ef60bd05
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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="onos-bundle"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
diff --git a/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 00000000..c9e747c9
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+ <packaging>bundle</packaging>
+
+ <description>ONOS OSGi bundle archetype</description>
+ <url>http://onosproject.org</url>
+
+ <properties>
+ <onos.version>1.3.0-SNAPSHOT</onos.version>
+ <!-- Uncomment to generate ONOS app from this module.
+ <onos.app.name>org.foo.app</onos.app.name>
+ <onos.app.origin>Foo, Inc.</onos.app.origin>
+ -->
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <version>1.9.8</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.3</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <version>1.20.0</version>
+ <executions>
+ <execution>
+ <id>generate-scr-srcdescriptor</id>
+ <goals>
+ <goal>scr</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <supportedProjectTypes>
+ <supportedProjectType>bundle</supportedProjectType>
+ <supportedProjectType>war</supportedProjectType>
+ </supportedProjectTypes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ <version>1.5</version>
+ <executions>
+ <execution>
+ <id>cfg</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>cfg</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>swagger</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>swagger</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>app</id>
+ <phase>package</phase>
+ <goals>
+ <goal>app</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/main/java/AppComponent.java b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/main/java/AppComponent.java
new file mode 100644
index 00000000..693b6fd4
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/main/java/AppComponent.java
@@ -0,0 +1,46 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * 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.
+ */
+package ${package};
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Skeletal ONOS application component.
+ */
+@Component(immediate = true)
+public class AppComponent {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Activate
+ protected void activate() {
+ log.info("Started");
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ log.info("Stopped");
+ }
+
+}
diff --git a/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/test/java/AppComponentTest.java b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/test/java/AppComponentTest.java
new file mode 100644
index 00000000..b981225d
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/test/java/AppComponentTest.java
@@ -0,0 +1,49 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * 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.
+ */
+package ${package};
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Set of tests of the ONOS application component.
+ */
+public class AppComponentTest {
+
+ private AppComponent component;
+
+ @Before
+ public void setUp() {
+ component = new AppComponent();
+ component.activate();
+
+ }
+
+ @After
+ public void tearDown() {
+ component.deactivate();
+ }
+
+ @Test
+ public void basics() {
+
+ }
+
+}
diff --git a/framework/src/onos/tools/package/archetypes/bundle/src/test/resources/projects/basic/archetype.properties b/framework/src/onos/tools/package/archetypes/bundle/src/test/resources/projects/basic/archetype.properties
new file mode 100644
index 00000000..a1213b40
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/bundle/src/test/resources/projects/basic/archetype.properties
@@ -0,0 +1,21 @@
+#
+# Copyright 2014 Open Networking Laboratory
+#
+# 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.
+#
+
+#Thu Dec 04 09:24:50 PST 2014
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
diff --git a/framework/src/onos/tools/package/archetypes/bundle/src/test/resources/projects/basic/goal.txt b/framework/src/onos/tools/package/archetypes/bundle/src/test/resources/projects/basic/goal.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/bundle/src/test/resources/projects/basic/goal.txt
diff --git a/framework/src/onos/tools/package/archetypes/cli/pom.xml b/framework/src/onos/tools/package/archetypes/cli/pom.xml
new file mode 100644
index 00000000..1ab9c1f2
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/cli/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-archetypes</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-cli-archetype</artifactId>
+ <packaging>maven-archetype</packaging>
+
+ <name>onos-cli-archetype</name>
+ <description>ONOS Apache Karaf bundle archetype</description>
+
+</project>
diff --git a/framework/src/onos/tools/package/archetypes/cli/src/main/resources/META-INF/maven/archetype-metadata.xml b/framework/src/onos/tools/package/archetypes/cli/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 00000000..8558d476
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/cli/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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="onos-cli" partial="true"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" packaged="false" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
diff --git a/framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/pom.xml b/framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 00000000..cb3862c3
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+ <packaging>bundle</packaging>
+
+ <description>ONOS OSGi bundle archetype</description>
+ <url>http://onosproject.org</url>
+
+ <properties>
+ <onos.version>1.3.0-SNAPSHOT</onos.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${onos.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.3.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <version>1.9.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <version>3.0.3</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.3</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <version>1.20.0</version>
+ <executions>
+ <execution>
+ <id>generate-scr-srcdescriptor</id>
+ <goals>
+ <goal>scr</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <supportedProjectTypes>
+ <supportedProjectType>bundle</supportedProjectType>
+ <supportedProjectType>war</supportedProjectType>
+ </supportedProjectTypes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/src/main/java/AppCommand.java b/framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/src/main/java/AppCommand.java
new file mode 100644
index 00000000..9262b2e4
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/src/main/java/AppCommand.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * 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.
+ */
+package ${package};
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+
+/**
+ * Sample Apache Karaf CLI command
+ */
+@Command(scope = "onos", name = "sample",
+ description = "Sample Apache Karaf CLI command")
+public class AppCommand extends AbstractShellCommand {
+
+ @Override
+ protected void execute() {
+ print("Hello %s", "World");
+ }
+
+}
diff --git a/framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-config.xml
new file mode 100644
index 00000000..202ab9ed
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/cli/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,24 @@
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+ <command>
+ <action class="${package}.AppCommand"/>
+ </command>
+ </command-bundle>
+
+</blueprint>
diff --git a/framework/src/onos/tools/package/archetypes/cli/src/test/resources/projects/basic/archetype.properties b/framework/src/onos/tools/package/archetypes/cli/src/test/resources/projects/basic/archetype.properties
new file mode 100644
index 00000000..a1213b40
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/cli/src/test/resources/projects/basic/archetype.properties
@@ -0,0 +1,21 @@
+#
+# Copyright 2014 Open Networking Laboratory
+#
+# 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.
+#
+
+#Thu Dec 04 09:24:50 PST 2014
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
diff --git a/framework/src/onos/tools/package/archetypes/cli/src/test/resources/projects/basic/goal.txt b/framework/src/onos/tools/package/archetypes/cli/src/test/resources/projects/basic/goal.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/cli/src/test/resources/projects/basic/goal.txt
diff --git a/framework/src/onos/tools/package/archetypes/pom.xml b/framework/src/onos/tools/package/archetypes/pom.xml
new file mode 100644
index 00000000..2fd5f874
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-base</artifactId>
+ <version>1</version>
+ <relativePath>../../build/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-archetypes</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <description>ONOS archetypes project</description>
+
+ <modules>
+ <module>api</module>
+ <module>bundle</module>
+ <module>cli</module>
+ <module>ui</module>
+ </modules>
+
+ <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/framework/src/onos/tools/package/archetypes/ui/pom.xml b/framework/src/onos/tools/package/archetypes/ui/pom.xml
new file mode 100644
index 00000000..ca7b2d87
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-archetypes</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-ui-archetype</artifactId>
+ <packaging>maven-archetype</packaging>
+
+ <description>ONOS UI overlay archetype</description>
+
+</project>
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/META-INF/maven/archetype-metadata.xml b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 00000000..309fd6ad
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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="onos-ui" partial="true"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" packaged="false" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.html</include>
+ <include>**/*.js</include>
+ <include>**/*.css</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 00000000..a6beae99
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+ <packaging>bundle</packaging>
+
+ <description>ONOS OSGi UI bundle archetype</description>
+ <url>http://onosproject.org</url>
+
+ <properties>
+ <onos.version>1.3.0-SNAPSHOT</onos.version>
+ <!-- Uncomment to generate ONOS app from this module.
+ <onos.app.name>org.foo.app</onos.app.name>
+ <onos.app.origin>Foo, Inc.</onos.app.origin>
+ -->
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <version>1.9.8</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.3</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <version>1.20.0</version>
+ <executions>
+ <execution>
+ <id>generate-scr-srcdescriptor</id>
+ <goals>
+ <goal>scr</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <supportedProjectTypes>
+ <supportedProjectType>bundle</supportedProjectType>
+ <supportedProjectType>war</supportedProjectType>
+ </supportedProjectTypes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ <version>1.5</version>
+ <executions>
+ <execution>
+ <id>cfg</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>cfg</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>swagger</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>swagger</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>app</id>
+ <phase>package</phase>
+ <goals>
+ <goal>app</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java
new file mode 100644
index 00000000..f40bcb5f
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java
@@ -0,0 +1,76 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Copyright 2014,2015 Open Networking Laboratory
+ *
+ * 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.
+ */
+package ${package};
+
+import com.google.common.collect.ImmutableList;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.ui.UiExtension;
+import org.onosproject.ui.UiExtensionService;
+import org.onosproject.ui.UiMessageHandlerFactory;
+import org.onosproject.ui.UiView;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * Skeletal ONOS UI application component.
+ */
+@Component(immediate = true)
+public class AppUiComponent {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected UiExtensionService uiExtensionService;
+
+ // List of application views
+ private final List<UiView> uiViews = ImmutableList.of(
+ new UiView(UiView.Category.OTHER, "sample", "Sample")
+ );
+
+ // Factory for UI message handlers
+ private final UiMessageHandlerFactory messageHandlerFactory =
+ () -> ImmutableList.of(
+ new AppUiMessageHandler()
+ );
+
+ // Application UI extension
+ protected UiExtension extension =
+ new UiExtension.Builder(getClass().getClassLoader(), uiViews)
+ .messageHandlerFactory(messageHandlerFactory)
+ .build();
+
+ @Activate
+ protected void activate() {
+ uiExtensionService.register(extension);
+ log.info("Started");
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ uiExtensionService.unregister(extension);
+ log.info("Stopped");
+ }
+
+}
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiMessageHandler.java b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiMessageHandler.java
new file mode 100644
index 00000000..d9d68b53
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiMessageHandler.java
@@ -0,0 +1,189 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Copyright 2014,2015 Open Networking Laboratory
+ *
+ * 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.
+ */
+package ${package};
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.ImmutableSet;
+import org.onosproject.ui.RequestHandler;
+import org.onosproject.ui.UiMessageHandler;
+import org.onosproject.ui.table.TableModel;
+import org.onosproject.ui.table.TableRequestHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.Override;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Skeletal ONOS UI message handler.
+ * <p>
+ * This example specifically supporting a "table" view.
+ */
+public class AppUiMessageHandler extends UiMessageHandler {
+
+ private static final String SAMPLE_DATA_REQ = "sampleDataRequest";
+ private static final String SAMPLE_DATA_RESP = "sampleDataResponse";
+ private static final String SAMPLES = "samples";
+
+ private static final String SAMPLE_DETAIL_REQ = "sampleDetailsRequest";
+ private static final String SAMPLE_DETAIL_RESP = "sampleDetailsResponse";
+ private static final String DETAILS = "details";
+
+ private static final String ID = "id";
+ private static final String LABEL = "label";
+ private static final String CODE = "code";
+ private static final String COMMENT = "comment";
+ private static final String RESULT = "result";
+
+ private static final String[] COLUMN_IDS = { ID, LABEL, CODE };
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+
+ @Override
+ protected Collection<RequestHandler> createRequestHandlers() {
+ return ImmutableSet.of(
+ new SampleDataRequestHandler(),
+ new SampleDetailRequestHandler()
+ );
+ }
+
+ // handler for sample table requests
+ private final class SampleDataRequestHandler extends TableRequestHandler {
+
+ private SampleDataRequestHandler() {
+ super(SAMPLE_DATA_REQ, SAMPLE_DATA_RESP, SAMPLES);
+ }
+
+ // if necessary, override defaultColumnId() -- if it isn't "id"
+
+ @Override
+ protected String[] getColumnIds() {
+ return COLUMN_IDS;
+ }
+
+ @Override
+ protected void populateTable(TableModel tm, ObjectNode payload) {
+ // === set custom column cell formatters/comparators if need be...
+ // tm.setFormatter(CODE, new CodeFormatter());
+ // tm.setComparator(CODE, new CodeComparator());
+
+ // === retrieve table row items from some service...
+ // SomeService ss = get(SomeService.class);
+ // List<Item> items = ss.getItems()
+
+ // fake data for demonstration purposes...
+ List<Item> items = getItems();
+ for (Item item: items) {
+ populateRow(tm.addRow(), item);
+ }
+ }
+
+ private void populateRow(TableModel.Row row, Item item) {
+ row.cell(ID, item.id())
+ .cell(LABEL, item.label())
+ .cell(CODE, item.code());
+ }
+ }
+
+
+ // handler for sample item details requests
+ private final class SampleDetailRequestHandler extends RequestHandler {
+
+ private SampleDetailRequestHandler() {
+ super(SAMPLE_DETAIL_REQ);
+ }
+
+ @Override
+ public void process(long sid, ObjectNode payload) {
+ String id = string(payload, ID, "(none)");
+
+ // SomeService ss = get(SomeService.class);
+ // Item item = ss.getItemDetails(id)
+
+ // fake data for demonstration purposes...
+ Item item = getItem(id);
+
+ ObjectNode rootNode = MAPPER.createObjectNode();
+ ObjectNode data = MAPPER.createObjectNode();
+ rootNode.set(DETAILS, data);
+
+ if (item == null) {
+ rootNode.put(RESULT, "Item with id '" + id + "' not found");
+ log.warn("attempted to get item detail for id '{}'", id);
+
+ } else {
+ rootNode.put(RESULT, "Found item with id '" + id + "'");
+
+ data.put(ID, item.id());
+ data.put(LABEL, item.label());
+ data.put(CODE, item.code());
+ data.put(COMMENT, "Some arbitrary comment");
+ }
+
+ sendMessage(SAMPLE_DETAIL_RESP, 0, rootNode);
+ }
+ }
+
+
+ // ===================================================================
+ // NOTE: The code below this line is to create fake data for this
+ // sample code. Normally you would use existing services to
+ // provide real data.
+
+ // Lookup a single item.
+ private static Item getItem(String id) {
+ // We realize this code is really inefficient, but
+ // it suffices for our purposes of demonstration...
+ for (Item item : getItems()) {
+ if (item.id().equals(id)) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ // Produce a list of items.
+ private static List<Item> getItems() {
+ List<Item> items = new ArrayList<>();
+ items.add(new Item("item-1", "foo", 42));
+ items.add(new Item("item-2", "bar", 99));
+ items.add(new Item("item-3", "baz", 65));
+ return items;
+ }
+
+ // Simple model class to provide sample data
+ private static class Item {
+ private final String id;
+ private final String label;
+ private final int code;
+
+ Item(String id, String label, int code) {
+ this.id = id;
+ this.label = label;
+ this.code = code;
+ }
+
+ String id() { return id; }
+ String label() { return label; }
+ int code() { return code; }
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css
new file mode 100644
index 00000000..c492e203
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css
@@ -0,0 +1,35 @@
+/* css for sample app view */
+
+#ov-sample h2 {
+ display: inline-block;
+}
+
+/* Panel Styling */
+#item-details-panel.floatpanel {
+ position: absolute;
+ top: 115px;
+}
+
+.light #item-details-panel.floatpanel {
+ background-color: rgb(229, 234, 237);
+}
+.dark #item-details-panel.floatpanel {
+ background-color: #3A4042;
+}
+
+#item-details-panel h3 {
+ margin: 0;
+ font-size: large;
+}
+
+#item-details-panel h4 {
+ margin: 0;
+}
+
+#item-details-panel td {
+ padding: 5px;
+}
+#item-details-panel td.label {
+ font-style: italic;
+ opacity: 0.8;
+} \ No newline at end of file
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html
new file mode 100644
index 00000000..03a7383e
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html
@@ -0,0 +1,46 @@
+<!-- partial HTML -->
+<div id="ov-sample">
+ <div class="tabular-header">
+ <h2>Items ({{tableData.length}} total)</h2>
+ <div class="ctrl-btns">
+ <div class="refresh" ng-class="{active: autoRefresh}"
+ icon icon-id="refresh" icon-size="36"
+ tooltip tt-msg="autoRefreshTip"
+ ng-click="toggleRefresh()"></div>
+ </div>
+ </div>
+
+ <div class="summary-list" onos-table-resize>
+
+ <div class="table-header" onos-sortable-header>
+ <table>
+ <tr>
+ <td colId="id" sortable>Item ID </td>
+ <td colId="label" sortable>Label </td>
+ <td colId="code" sortable>Code </td>
+ </tr>
+ </table>
+ </div>
+
+ <div class="table-body">
+ <table>
+ <tr ng-if="!tableData.length" class="no-data">
+ <td colspan="3">
+ No Items found
+ </td>
+ </tr>
+
+ <tr ng-repeat="item in tableData track by $index"
+ ng-click="selectCallback($event, item)"
+ ng-class="{selected: item.id === selId}">
+ <td>{{item.id}}</td>
+ <td>{{item.label}}</td>
+ <td>{{item.code}}</td>
+ </tr>
+ </table>
+ </div>
+
+ </div>
+
+ <item-details-panel></item-details-panel>
+</div>
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js
new file mode 100644
index 00000000..2d4aed48
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js
@@ -0,0 +1,139 @@
+// js for sample app view
+(function () {
+ 'use strict';
+
+ // injected refs
+ var $log, $scope, fs, wss, ps;
+
+ // constants
+ var detailsReq = 'sampleDetailsRequest',
+ detailsResp = 'sampleDetailsResponse',
+ pName = 'item-details-panel',
+
+ propOrder = ['id', 'label', 'code'],
+ friendlyProps = ['Item ID', 'Item Label', 'Special Code'];
+
+
+ function addProp(tbody, index, value) {
+ var tr = tbody.append('tr');
+
+ function addCell(cls, txt) {
+ tr.append('td').attr('class', cls).html(txt);
+ }
+ addCell('label', friendlyProps[index] + ' :');
+ addCell('value', value);
+ }
+
+ function populatePanel(panel) {
+ var title = panel.append('h3'),
+ tbody = panel.append('table').append('tbody');
+
+ title.text('Item Details');
+
+ propOrder.forEach(function (prop, i) {
+ addProp(tbody, i, $scope.panelDetails[prop]);
+ });
+
+ panel.append('hr');
+ panel.append('h4').text('Comments');
+ panel.append('p').text($scope.panelDetails.comment);
+ }
+
+ function respDetailsCb(data) {
+ $scope.panelDetails = data.details;
+ $scope.$apply();
+ }
+
+ angular.module('ovSample', [])
+ .controller('OvSampleCtrl',
+ ['$log', '$scope', 'TableBuilderService',
+ 'FnService', 'WebSocketService',
+
+ function (_$log_, _$scope_, tbs, _fs_, _wss_) {
+ $log = _$log_;
+ $scope = _$scope_;
+ fs = _fs_;
+ wss = _wss_;
+
+ var handlers = {};
+ $scope.panelDetails = {};
+
+ // details response handler
+ handlers[detailsResp] = respDetailsCb;
+ wss.bindHandlers(handlers);
+
+ // custom selection callback
+ function selCb($event, row) {
+ if ($scope.selId) {
+ wss.sendEvent(detailsReq, { id: row.id });
+ } else {
+ $scope.hidePanel();
+ }
+ $log.debug('Got a click on:', row);
+ }
+
+ // TableBuilderService creating a table for us
+ tbs.buildTable({
+ scope: $scope,
+ tag: 'sample',
+ selCb: selCb
+ });
+
+ // cleanup
+ $scope.$on('$destroy', function () {
+ wss.unbindHandlers(handlers);
+ });
+
+ $log.log('OvSampleCtrl has been created');
+ }])
+
+ .directive('itemDetailsPanel', ['PanelService', 'KeyService',
+ function (_ps_, ks) {
+ return {
+ restrict: 'E',
+ link: function (scope, element, attrs) {
+ ps = _ps_;
+ // insert details panel with PanelService
+ // create the panel
+ var panel = ps.createPanel(pName, {
+ width: 200,
+ margin: 20,
+ hideMargin: 0
+ });
+ panel.hide();
+ scope.hidePanel = function () { panel.hide(); };
+
+ function closePanel() {
+ if (panel.isVisible()) {
+ $scope.selId = null;
+ panel.hide();
+ }
+ }
+
+ // create key bindings to handle panel
+ ks.keyBindings({
+ esc: [closePanel, 'Close the details panel'],
+ _helpFormat: ['esc']
+ });
+ ks.gestureNotes([
+ ['click', 'Select a row to show item details']
+ ]);
+
+ // update the panel's contents when the data is changed
+ scope.$watch('panelDetails', function () {
+ if (!fs.isEmptyObject(scope.panelDetails)) {
+ panel.empty();
+ populatePanel(panel);
+ panel.show();
+ }
+ });
+
+ // cleanup on destroyed scope
+ scope.$on('$destroy', function () {
+ ks.unbindKeys();
+ ps.destroyPanel(pName);
+ });
+ }
+ };
+ }]);
+}());
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html
new file mode 100644
index 00000000..c4697256
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html
@@ -0,0 +1 @@
+<link rel="stylesheet" href="app/view/sample/sample.css"> \ No newline at end of file
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html
new file mode 100644
index 00000000..7cacc707
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html
@@ -0,0 +1 @@
+<script src="app/view/sample/sample.js"></script> \ No newline at end of file
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/test/resources/projects/basic/archetype.properties b/framework/src/onos/tools/package/archetypes/ui/src/test/resources/projects/basic/archetype.properties
new file mode 100644
index 00000000..a1213b40
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/test/resources/projects/basic/archetype.properties
@@ -0,0 +1,21 @@
+#
+# Copyright 2014 Open Networking Laboratory
+#
+# 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.
+#
+
+#Thu Dec 04 09:24:50 PST 2014
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
diff --git a/framework/src/onos/tools/package/archetypes/ui/src/test/resources/projects/basic/goal.txt b/framework/src/onos/tools/package/archetypes/ui/src/test/resources/projects/basic/goal.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/framework/src/onos/tools/package/archetypes/ui/src/test/resources/projects/basic/goal.txt
diff --git a/framework/src/onos/tools/package/bin/onos-client b/framework/src/onos/tools/package/bin/onos-client
new file mode 100755
index 00000000..2a37087a
--- /dev/null
+++ b/framework/src/onos/tools/package/bin/onos-client
@@ -0,0 +1,17 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# ONOS command-line client that uses the built-in Apache Karaf client.
+# -----------------------------------------------------------------------------
+
+if [ -z "${JAVA_HOME}" ]; then
+ if [ -x /usr/libexec/java_home ]; then
+ export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
+ elif [ -d /usr/lib/jvm/java-8-oracle ]; then
+ export JAVA_HOME="/usr/lib/jvm/java-8-oracle"
+ elif [ -d /usr/lib/jvm/java-7-openjdk-amd64 ]; then
+ export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
+ fi
+fi
+
+cd $(dirname $0)/../apache-karaf-$KARAF_VERSION/bin
+./client -h localhost -u karaf "$@"
diff --git a/framework/src/onos/tools/package/bin/onos-config b/framework/src/onos/tools/package/bin/onos-config
new file mode 100755
index 00000000..2265d002
--- /dev/null
+++ b/framework/src/onos/tools/package/bin/onos-config
@@ -0,0 +1,2 @@
+#!/bin/bash
+echo "This command has been deprecated as this step is no longer required." \ No newline at end of file
diff --git a/framework/src/onos/tools/package/bin/onos-form-cluster b/framework/src/onos/tools/package/bin/onos-form-cluster
new file mode 100755
index 00000000..7a0abda6
--- /dev/null
+++ b/framework/src/onos/tools/package/bin/onos-form-cluster
@@ -0,0 +1,39 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Forms ONOS cluster using REST API of each separate instance.
+# -----------------------------------------------------------------------------
+
+[ $# -lt 2 ] && echo "usage: $(basename $0) ip1 ip2..." && exit 1
+
+# Scan arguments for user/password or other options...
+while getopts u:p: o; do
+ case "$o" in
+ u) user=$OPTARG;;
+ p) password=$OPTARG;;
+ esac
+done
+user=${user:-onos} # user defaults to 'onos'
+password=${password:-$user} # password defaults to user name if not specified
+let OPC=$OPTIND-1
+shift $OPC
+
+ip=$1
+shift
+nodes=$*
+
+ipPrefix=${ip%.*}
+
+aux=/tmp/${ipPrefix}.cluster.json
+trap "rm -f $aux" EXIT
+
+echo "{ \"nodes\": [ { \"ip\": \"$ip\" }" > $aux
+for node in $nodes; do
+ echo ", { \"ip\": \"$node\" }" >> $aux
+done
+echo "], \"ipPrefix\": \"$ipPrefix.*\" }" >> $aux
+
+for node in $ip $nodes; do
+ echo "Forming cluster on $node..."
+ curl --user $user:$password -X POST \
+ http://$node:8181/onos/v1/cluster/configuration -d @$aux
+done \ No newline at end of file
diff --git a/framework/src/onos/tools/package/bin/onos-jpenable b/framework/src/onos/tools/package/bin/onos-jpenable
new file mode 100755
index 00000000..7c69602a
--- /dev/null
+++ b/framework/src/onos/tools/package/bin/onos-jpenable
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+kpid=$(ps -ef | grep karaf.main.Main | grep -v grep | cut -c10-15 | tr -d ' ')
+
+[ -z "$kpid" ] && echo "No ONOS!" && exit 1
+
+/opt/jprofiler8/bin/jpenable --gui --port=8849 --pid=$kpid
diff --git a/framework/src/onos/tools/package/bin/onos-secure-ssh b/framework/src/onos/tools/package/bin/onos-secure-ssh
new file mode 100755
index 00000000..3f541dbe
--- /dev/null
+++ b/framework/src/onos/tools/package/bin/onos-secure-ssh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Enables secure access to ONOS console by removing default users & keys.
+# -----------------------------------------------------------------------------
+
+rm -f $(dirname $0)/onos
+
+set -e
+
+# Scan arguments for user/password or other options...
+while getopts u:p: o; do
+ case "$o" in
+ u) user=$OPTARG;;
+ p) password=$OPTARG;;
+ esac
+done
+password=${password:-$user} # password defaults to the user if not specified
+let OPC=$OPTIND-1
+shift $OPC
+
+cd $(dirname $0)/../apache-karaf-*/etc
+USERS=users.properties
+KEYS=keys.properties
+
+# Remove the built-in users and keys to secure the access implicitly.
+egrep -v "^(karaf|onos)[ ]*=" $USERS > $USERS.new && mv $USERS.new $USERS
+egrep -v "^(#karaf|onos)[ ]*=" $KEYS > $KEYS.new && mv $KEYS.new $KEYS
+
+# Remove any previous known keys for the local host.
+ssh-keygen -f "$HOME/.ssh/known_hosts" -R [localhost]:8101
+
+# Swap the onos client to use the SSH variant.
+ln -s $(dirname $0)/onos-ssh $(dirname $0)/onos
+
+# If user and password options were given, setup the user/password.
+if [ -n "$user" -a -n "$password" ]; then
+ echo "$user = $password,_g_:admingroup" >> $USERS
+fi \ No newline at end of file
diff --git a/framework/src/onos/tools/package/bin/onos-service b/framework/src/onos/tools/package/bin/onos-service
new file mode 100755
index 00000000..2f00ca02
--- /dev/null
+++ b/framework/src/onos/tools/package/bin/onos-service
@@ -0,0 +1,44 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Starts ONOS Apache Karaf container
+# -----------------------------------------------------------------------------
+
+# uncomment the following line for performance testing
+#export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+PrintGCDetails -XX:+PrintGCTimeStamps}"
+
+# uncomment the following line for Netty TLS encryption
+# Do modify the keystore location/password and truststore location/password accordingly
+#export JAVA_OPTS="${JAVA_OPTS:--DenableNettyTLS=true -Djavax.net.ssl.keyStore=/home/ubuntu/onos.jks -Djavax.net.ssl.keyStorePassword=222222 -Djavax.net.ssl.trustStore=/home/ubuntu/onos.jks -Djavax.net.ssl.trustStorePassword=222222}"
+
+ONOS_HOME=/opt/onos
+KARAF_ARGS=
+SYS_APPS=drivers
+
+[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..
+
+# Parse out arguments destinted for karaf invocation v. arguments that
+# will be processed in line
+while [ $# -gt 0 ]; do
+ case $1 in
+ apps-clean)
+ # Deactivate all applications
+ find ${ONOS_HOME}/apps -name "active" -exec rm \{\} \;
+ ;;
+ *)
+ KARAF_ARGS+=" $1"
+ ;;
+ esac
+ shift
+done
+
+# Activate the system required applications (SYS_APPS) as well as any
+# specified applications in the var ONOS_APPS
+for app in ${SYS_APPS//,/ } ${ONOS_APPS//,/ }; do
+ if [[ "$app" =~ \. ]]; then
+ touch ${ONOS_HOME}/apps/$app/active
+ else
+ touch ${ONOS_HOME}/apps/org.onosproject.$app/active
+ fi
+done
+
+exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf $KARAF_ARGS
diff --git a/framework/src/onos/tools/package/bin/onos-ssh b/framework/src/onos/tools/package/bin/onos-ssh
new file mode 100755
index 00000000..7e082aa5
--- /dev/null
+++ b/framework/src/onos/tools/package/bin/onos-ssh
@@ -0,0 +1,6 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# ONOS command-line client that uses raw ssh.
+# -----------------------------------------------------------------------------
+
+ssh -p 8101 localhost "$@" \ No newline at end of file
diff --git a/framework/src/onos/tools/package/bin/onos-user-key b/framework/src/onos/tools/package/bin/onos-user-key
new file mode 100755
index 00000000..db24da17
--- /dev/null
+++ b/framework/src/onos/tools/package/bin/onos-user-key
@@ -0,0 +1,20 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Adds or removes a user key for managing passwordless loging to ONOS console.
+# -----------------------------------------------------------------------------
+
+[ $# -lt 2 ] && echo "usage: $(basename $0) user {key|remove}" && exit 1
+
+set -e
+
+user=$1
+[ -f $2 ] && key=$(cut -d\ -f2 $2) || key=$2
+
+cd $(dirname $0)/../apache-karaf-*/etc
+KEYS=keys.properties
+
+# Remove the user key first, in case one was already present
+egrep -v "^$user[ ]*=" $KEYS > $KEYS.new && mv $KEYS.new $KEYS
+if [ $key != "remove" ]; then
+ echo "$user=$key,_g_:admingroup" >> $KEYS
+fi
diff --git a/framework/src/onos/tools/package/branding/pom.xml b/framework/src/onos/tools/package/branding/pom.xml
new file mode 100644
index 00000000..452a03c9
--- /dev/null
+++ b/framework/src/onos/tools/package/branding/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<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>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-branding</artifactId>
+ <packaging>bundle</packaging>
+ <description>Custom Karaf CLI motd</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>manual</Bundle-SymbolicName>
+ <Import-Package>*</Import-Package>
+ <Private-Package>!*</Private-Package>
+ <Export-Package>
+ org.apache.karaf.branding
+ </Export-Package>
+ <Spring-Context>*;public-context:=false</Spring-Context>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
diff --git a/framework/src/onos/tools/package/branding/src/main/resources/org/apache/karaf/branding/branding.properties b/framework/src/onos/tools/package/branding/src/main/resources/org/apache/karaf/branding/branding.properties
new file mode 100644
index 00000000..7a9f9f2d
--- /dev/null
+++ b/framework/src/onos/tools/package/branding/src/main/resources/org/apache/karaf/branding/branding.properties
@@ -0,0 +1,26 @@
+#
+# Copyright 2014 Open Networking Laboratory
+#
+# 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.
+#
+welcome = Welcome to Open Network Operating System (ONOS)!\r\n\
+\u001B[1;31m ____ _ ______ ____ \u001B[0m\r\n\
+\u001B[1;31m / __ \\/ |/ / __ \\/ __/ \u001B[0m\r\n\
+\u001B[1;31m / /_/ / / /_/ /\\ \\ \u001B[0m\r\n\
+\u001B[1;31m \\____/_/|_/\\____/___/ \u001B[0m\r\n\
+\u001B[1;31m \u001B[0m\r\n\
+ \r\n\
+ Hit '\u001B[1m<tab>\u001B[0m' for a list of available commands\r\n\
+ and '\u001B[1m[cmd] --help\u001B[0m' for help on a specific command.\r\n\
+ Hit '\u001B[1m<ctrl-d>\u001B[0m' or type '\u001B[1msystem:shutdown\u001B[0m' or '\u001B[1mlogout\u001B[0m' to shutdown ONOS.\r\n
+prompt = \u001B[32monos> \u001B[0m
diff --git a/framework/src/onos/tools/package/config/README b/framework/src/onos/tools/package/config/README
new file mode 100644
index 00000000..970f87a5
--- /dev/null
+++ b/framework/src/onos/tools/package/config/README
@@ -0,0 +1,2 @@
+The onos-config command will copy files contained in this directory to ONOS
+instances according to cell definition.
diff --git a/framework/src/onos/tools/package/config/samples/segmentrouting.conf b/framework/src/onos/tools/package/config/samples/segmentrouting.conf
new file mode 100644
index 00000000..8df6c3d2
--- /dev/null
+++ b/framework/src/onos/tools/package/config/samples/segmentrouting.conf
@@ -0,0 +1,78 @@
+{
+ "comment": " Multilayer topology description and configuration",
+ "restrictSwitches": true,
+ "restrictLinks": true,
+
+ "switchConfig":
+ [
+ { "nodeDpid" : "of:0000000000000001", "name": "Dallas-R1", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.1/32",
+ "routerMac": "00:00:01:01:01:80",
+ "nodeSid": 101,
+ "isEdgeRouter" : true,
+ "adjacencySids": [
+ { "ports": [ 4, 5 ], "adjSid": 10234 },
+ { "ports": [ 6, 7 ], "adjSid": 29019 }
+ ],
+ "subnets": [
+ { "portNo": 1, "subnetIp": "10.0.1.128/24" }
+ ]
+ }
+ },
+
+ { "nodeDpid": "of:0000000000000002", "name": "Dallas-R2", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.2/32",
+ "routerMac": "00:00:02:02:02:80",
+ "nodeSid": 102,
+ "isEdgeRouter" : false,
+ "adjacencySids": [
+ { "ports": [ 1, 2 ], "adjSid": 12453 },
+ { "ports": [ 2, 3 ], "adjSid": 23333 },
+ { "ports": [ 3, 1 ], "adjSid": 22233 }
+ ]
+ }
+ },
+
+ { "nodeDpid": "of:0000000000000003", "name": "Dallas-R3", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.3/32",
+ "routerMac": "00:00:03:03:03:80",
+ "nodeSid": 103,
+ "isEdgeRouter" : false
+ }
+ },
+
+ { "nodeDpid": "of:0000000000000004", "name": "Dallas-R4", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.4/32",
+ "routerMac": "00:00:04:04:04:80",
+ "nodeSid": 104,
+ "isEdgeRouter" : false
+ }
+ },
+
+ { "nodeDpid": "of:0000000000000005", "name": "Dallas-R5", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.5/32",
+ "routerMac": "00:00:05:05:05:80",
+ "nodeSid": 105,
+ "isEdgeRouter" : false
+ }
+ },
+
+ { "nodeDpid": "of:0000000000000006", "name": "Dallas-R6", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.6/32",
+ "routerMac": "00:00:07:07:07:80",
+ "nodeSid": 106,
+ "isEdgeRouter" : true,
+ "subnets": [
+ { "portNo": 1, "subnetIp": "7.7.7.128/24" }
+ ]
+ }
+ }
+
+ ]
+}
diff --git a/framework/src/onos/tools/package/config/samples/segmentrouting_dell.conf b/framework/src/onos/tools/package/config/samples/segmentrouting_dell.conf
new file mode 100644
index 00000000..be489a65
--- /dev/null
+++ b/framework/src/onos/tools/package/config/samples/segmentrouting_dell.conf
@@ -0,0 +1,93 @@
+{
+ "comment": " Multilayer topology description and configuration",
+ "restrictSwitches": true,
+ "restrictLinks": true,
+
+ "switchConfig":
+ [
+ { "nodeDpid" : "of:00010001e88b9368", "name": "Dell-R1", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.1/32",
+ "routerMac": "00:01:e8:8b:93:6b",
+ "nodeSid": 101,
+ "isEdgeRouter" : true,
+ "subnets": [
+ { "portNo": 46, "subnetIp": "10.200.1.1/24" }
+ ]
+ }
+ },
+
+ { "nodeDpid": "of:00010001e88b939b", "name": "Dell-R2", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.2/32",
+ "routerMac": "00:01:e8:8b:93:9e",
+ "nodeSid": 102,
+ "isEdgeRouter" : true,
+ "subnets": [
+ { "portNo": 46, "subnetIp": "10.200.2.1/24" }
+ ]
+ }
+ },
+
+ { "nodeDpid": "of:00010001e88b938c", "name": "Dell-R3", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.3/32",
+ "routerMac": "00:01:e8:8b:93:8f",
+ "nodeSid": 103,
+ "isEdgeRouter" : true,
+ "subnets": [
+ { "portNo": 46, "subnetIp": "10.200.3.1/24" }
+ ]
+ }
+ },
+
+ { "nodeDpid": "of:00010001e88b93ad", "name": "Dell-R4", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.4/32",
+ "routerMac": "00:01:e8:8b:93:b0",
+ "nodeSid": 104,
+ "isEdgeRouter" : true,
+ "subnets": [
+ { "portNo": 46, "subnetIp": "10.200.4.1/24" }
+ ]
+ }
+ },
+
+ { "nodeDpid": "of:00010001e88b93bc", "name": "Dell-R5", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.5/32",
+ "routerMac": "00:01:e8:8b:93:bf",
+ "nodeSid": 105,
+ "isEdgeRouter" : false
+ }
+ },
+
+ { "nodeDpid": "of:00010001e88b93c2", "name": "Dell-R6", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.6/32",
+ "routerMac": "00:01:e8:8b:93:c5",
+ "nodeSid": 106,
+ "isEdgeRouter" : false
+ }
+ },
+
+ { "nodeDpid": "of:00010001e88b9398", "name": "Dell-R7", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.7/32",
+ "routerMac": "00:01:e8:8b:93:9b",
+ "nodeSid": 107,
+ "isEdgeRouter": false
+ }
+ },
+
+ { "nodeDpid": "of:00010001e88b27e3", "name": "Dell-R8", "type": "Router_SR", "allowed": true,
+ "latitude": 80.80, "longitude": 90.10,
+ "params": { "routerIp": "192.168.0.8/32",
+ "routerMac": "00:01:e8:8b:27:e6",
+ "nodeSid": 108,
+ "isEdgeRouter": false
+ }
+ }
+
+ ]
+}
diff --git a/framework/src/onos/tools/package/debian/onos.conf b/framework/src/onos/tools/package/debian/onos.conf
new file mode 100644
index 00000000..634a2636
--- /dev/null
+++ b/framework/src/onos/tools/package/debian/onos.conf
@@ -0,0 +1,27 @@
+description "Open Network Operating System"
+author "ON.Lab"
+
+start on (net-device-up
+ and local-filesystems
+ and runlevel [2345])
+stop on runlevel [016]
+
+console output
+kill timeout 60
+respawn
+
+env LANG=en_US.UTF-8
+#env JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
+#env NEW_JAVA_HOME=/usr/lib/jvm/java-8-oracle/
+
+pre-stop script
+ /opt/onos/bin/onos halt 2>>/opt/onos/var/stderr.log
+ sleep 1
+end script
+
+script
+ [ -f /opt/onos/options ] && . /opt/onos/options
+ start-stop-daemon --signal INT --start --chuid $ONOS_USER \
+ --exec /opt/onos/bin/onos-service -- $ONOS_OPTS \
+ >/opt/onos/var/stdout.log 2>/opt/onos/var/stderr.log
+end script
diff --git a/framework/src/onos/tools/package/etc/org.ops4j.pax.url.mvn.cfg b/framework/src/onos/tools/package/etc/org.ops4j.pax.url.mvn.cfg
new file mode 100644
index 00000000..15167a3b
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/org.ops4j.pax.url.mvn.cfg
@@ -0,0 +1,101 @@
+################################################################################
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+################################################################################
+
+#
+# If set to true, the following property will not allow any certificate to be used
+# when accessing Maven repositories through SSL
+#
+#org.ops4j.pax.url.mvn.certificateCheck=
+
+#
+# Path to the local Maven settings file.
+# The repositories defined in this file will be automatically added to the list
+# of default repositories if the 'org.ops4j.pax.url.mvn.repositories' property
+# below is not set.
+# The following locations are checked for the existence of the settings.xml file
+# * 1. looks for the specified url
+# * 2. if not found looks for ${user.home}/.m2/settings.xml
+# * 3. if not found looks for ${maven.home}/conf/settings.xml
+# * 4. if not found looks for ${M2_HOME}/conf/settings.xml
+#
+#org.ops4j.pax.url.mvn.settings=
+
+#
+# Path to the local Maven repository which is used to avoid downloading
+# artifacts when they already exist locally.
+# The value of this property will be extracted from the settings.xml file
+# above, or defaulted to:
+# System.getProperty( "user.home" ) + "/.m2/repository"
+#
+#org.ops4j.pax.url.mvn.localRepository=
+
+#
+# Default this to false. It's just weird to use undocumented repos
+#
+org.ops4j.pax.url.mvn.useFallbackRepositories=false
+
+#
+# Uncomment if you don't wanna use the proxy settings
+# from the Maven conf/settings.xml file
+#
+# org.ops4j.pax.url.mvn.proxySupport=false
+
+#
+# Comma separated list of repositories scanned when resolving an artifact.
+# Those repositories will be checked before iterating through the
+# below list of repositories and even before the local repository
+# A repository url can be appended with zero or more of the following flags:
+# @snapshots : the repository contains snaphots
+# @noreleases : the repository does not contain any released artifacts
+#
+# The following property value will add the system folder as a repo.
+#
+org.ops4j.pax.url.mvn.defaultRepositories=\
+ file:${karaf.home}/${karaf.default.repository}@id=system.repository@snapshots,\
+ file:${karaf.data}/kar@id=kar.repository@multi@snapshots
+
+# Use the default local repo (e.g.~/.m2/repository) as a "remote" repo
+#org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote=false
+
+#
+# Comma separated list of repositories scanned when resolving an artifact.
+# The default list includes the following repositories:
+# http://repo1.maven.org/maven2@id=central
+# http://repository.springsource.com/maven/bundles/release@id=spring.ebr
+# http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external
+# http://zodiac.springsource.com/maven/bundles/release@id=gemini
+# http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases
+# https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases
+# https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases
+# To add repositories to the default ones, prepend '+' to the list of repositories
+# to add.
+# A repository url can be appended with zero or more of the following flags:
+# @snapshots : the repository contains snapshots
+# @noreleases : the repository does not contain any released artifacts
+# @id=repository.id : the id for the repository, just like in the settings.xml this is optional but recommended
+#
+org.ops4j.pax.url.mvn.repositories= \
+ ${org.ops4j.pax.url.mvn.defaultRepositories}, \
+ http://repo1.maven.org/maven2@id=central, \
+ http://repository.springsource.com/maven/bundles/release@id=spring.ebr.release, \
+ http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, \
+ http://zodiac.springsource.com/maven/bundles/release@id=gemini, \
+ http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, \
+ https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases, \
+ https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases
diff --git a/framework/src/onos/tools/package/etc/org.ops4j.pax.web.cfg b/framework/src/onos/tools/package/etc/org.ops4j.pax.web.cfg
new file mode 100644
index 00000000..c8fb3b3d
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/org.ops4j.pax.web.cfg
@@ -0,0 +1,12 @@
+org.osgi.service.http.port=8181
+org.osgi.service.http.port.secure=8443
+
+org.osgi.service.http.enabled=true
+org.osgi.service.http.secure.enabled=false
+
+org.ops4j.pax.web.ssl.keystore=etc/keystore
+org.ops4j.pax.web.ssl.password=OBF:1xtn1w1u1uob1xtv1y7z1xtn1unn1w1o1xtv
+org.ops4j.pax.web.ssl.keypassword=OBF:1xtn1w1u1uob1xtv1y7z1xtn1unn1w1o1xtv
+
+org.ops4j.pax.web.session.url=none
+org.ops4j.pax.web.config.file=./etc/jetty.xml
diff --git a/framework/src/onos/tools/package/etc/samples/linkGraph.cfg b/framework/src/onos/tools/package/etc/samples/linkGraph.cfg
new file mode 100644
index 00000000..41ce5bdc
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/linkGraph.cfg
@@ -0,0 +1,27 @@
+# NullLinkProvider topology description (config file).
+#
+# Dot-style topology graph. Each controller's topology begins with
+#
+# graph <node ID>, followed by a list of links between braces.
+#
+# The links are either bidirectional (--) or directed (->). The directed
+# edges are used to connect together Null devices of different controllers.
+# The endpoint has the format:
+#
+# devID:port:NodeId
+#
+# The NodeId is only added if the destination is another node's device.
+#
+graph 192.168.56.20 {
+ 0:0 -- 1:0
+ 1:1 -> 0:0:192.168.56.30
+ 1:2 -- 2:0
+ 2:1 -> 1:0:192.168.56.30
+}
+graph 192.168.56.30 {
+ 0:0 -> 1:1:192.168.56.20
+ 0:1 -- 1:1
+ 1:0 -> 2:1:192.168.56.20
+ 1:2 -- 2:0
+}
+# Bugs: Comments cannot be appended to a line to be read.
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.fwd.ReactiveForwarding.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.fwd.ReactiveForwarding.cfg
new file mode 100644
index 00000000..4befc706
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.fwd.ReactiveForwarding.cfg
@@ -0,0 +1,79 @@
+#
+# Sample configuration for onos-app-fwd.
+#
+
+#
+# Reactive flows default matching is InPort, Src MAC, Dst MAC and EtherType fields
+#
+
+#
+# Enable packet-out only forwarding.
+# This flag affects to both IPv4 and IPv6.
+#
+# packetOutOnly = true
+
+#
+# Enable forwarding of the first packet by using OFPP_TABLE port in the
+# PacketOut message instead of sending it directly to the switch port
+#
+# packetOutOfppTable = true
+
+#
+# Timeout of reactively installed flows (in seconds).
+# Default is 10 sec
+#
+# flowTimeout = 10
+
+#
+# Priority of reactively installed flows
+#
+# flowPriority = 10
+
+#
+# Enable IPv6 forwarding.
+#
+# ipv6Forwarding = true
+
+#
+# Flows matching destination MAC only - as legacy L2 switches
+# - This option overrides all other options below
+#
+# matchDstMacOnly = true
+
+#
+# Matching of VLAN ID in Ethernet header
+#
+# matchVlanId = true
+
+#
+# Matching of IPv4 addresses and Protocol field
+# - must be enabled to match IPv4 DSCP, TCP/UDP ports and ICMP type/code
+#
+# matchIpv4Address = true
+
+#
+# Matching of IPv4 DSCP and ECN fields
+#
+# matchIpv4Dscp = true
+
+#
+# Matching of IPv6 addresses and Next-Header field
+# - must be enabled to match IPv6 Flow Label, TCP/UDP ports and ICMP type/code
+#
+# matchIpv6Address = true
+
+#
+# Matching of IPv6 Flow Label
+#
+# matchIpv6FlowLabel = true
+
+#
+# Matching of TCP/UDP ports for IPv4 and IPv6
+#
+# matchTcpUdpPorts = true
+
+#
+# Matching of ICMP Type and Code fields for IPv4 and IPv6
+#
+# matchIcmpFields = true
+
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.host.impl.HostLocationProvider.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.host.impl.HostLocationProvider.cfg
new file mode 100644
index 00000000..6d3a50d9
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.host.impl.HostLocationProvider.cfg
@@ -0,0 +1,13 @@
+#
+# Sample configuration for Host Location Provider
+#
+
+#
+# Enable host removal on port/device down events.
+#
+# hostRemovalEnabled = true
+
+#
+# Enable using IPv6 Neighbor Discovery by the Host Location Provider.
+#
+# ipv6NeighborDiscovery = true
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.lldp.impl.LLDPLinkProvider.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.lldp.impl.LLDPLinkProvider.cfg
new file mode 100644
index 00000000..6eb39a11
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.lldp.impl.LLDPLinkProvider.cfg
@@ -0,0 +1,21 @@
+#
+# Sample configuration for link discovery
+#
+
+#
+# Disable Link Dicovery Permanently (Note: changing this property at runtime will have NO effect)
+# WARNING: This should only be used for special projects like bgprouter, where ONOS is controlling
+# a single switch
+#
+#disableLinkDiscovery = true
+
+#
+# Enable Broadcast Discovery Protocol (EthType=0x8942)
+#
+#useBDDP = false
+
+#
+# Disable LLDP's received from specific devices
+# Details of the devices are in the file configured below
+#
+#lldpSuppression = ../config/lldp_suppresion.json
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.netconf.device.impl.NetconfDeviceProvider.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.netconf.device.impl.NetconfDeviceProvider.cfg
new file mode 100644
index 00000000..30ed0c26
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.netconf.device.impl.NetconfDeviceProvider.cfg
@@ -0,0 +1,11 @@
+#
+# Instance-specific configurations, in this case, the number of
+# devices per node.
+#
+devConfigs = cisco:cisco@192.168.56.20:2022:inactive,sdn:rocks@192.168.56.30:22:inactive
+
+#
+# Number of ports per device. This is global to all devices
+# on all instances.
+#
+# numPorts = 8
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg
new file mode 100644
index 00000000..194bf037
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg
@@ -0,0 +1,11 @@
+#
+# Instance-specific configurations, in this case, the number of
+# devices per node.
+#
+devConfigs = 192.168.56.20:3,192.168.56.30:3
+
+#
+# Number of ports per device. This is global to all devices
+# on all instances.
+#
+# numPorts = 8
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg
new file mode 100644
index 00000000..ef72b1ee
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg
@@ -0,0 +1,16 @@
+#
+# Sample configurations for the NullLinkProvider.
+#
+
+#
+# If enabled, sets the time between LinkEvent generation,
+# in microseconds.
+#
+
+#eventRate = 1000000
+
+#
+# If enabled, points to the full path to the topology file.
+#
+
+#cfgFile = /tmp/foo.cfg
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.packet.impl.NullPacketProvider.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.packet.impl.NullPacketProvider.cfg
new file mode 100644
index 00000000..db4342c0
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.provider.nil.packet.impl.NullPacketProvider.cfg
@@ -0,0 +1,4 @@
+#
+# Uncomment and tweak to tune the rate of Packet events (per second)
+#
+# pktRate = 100
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.proxyarp.ProxyArp.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.proxyarp.ProxyArp.cfg
new file mode 100644
index 00000000..108de136
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.proxyarp.ProxyArp.cfg
@@ -0,0 +1,8 @@
+#
+# Sample configuration for onos-app-proxyarp.
+#
+
+#
+# Enable IPv6 Neighbor Discovery.
+#
+# ipv6NeighborDiscovery = true
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.routing.bgp.BgpSessionManager.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.routing.bgp.BgpSessionManager.cfg
new file mode 100644
index 00000000..fbcc13f9
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.routing.bgp.BgpSessionManager.cfg
@@ -0,0 +1,8 @@
+#
+# Sample configuration for onos-app-sdnip.
+#
+
+#
+# The port number that SDN-IP listens for incoming BGP connections on.
+#
+# bgpPort=2000 \ No newline at end of file
diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.xos.XOS.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.xos.XOS.cfg
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.xos.XOS.cfg
diff --git a/framework/src/onos/tools/package/etc/users.properties b/framework/src/onos/tools/package/etc/users.properties
new file mode 100644
index 00000000..9f7a2667
--- /dev/null
+++ b/framework/src/onos/tools/package/etc/users.properties
@@ -0,0 +1,34 @@
+################################################################################
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+################################################################################
+
+#
+# This file contains the users, groups, and roles.
+# Each line has to be of the format:
+#
+# USER=PASSWORD,ROLE1,ROLE2,...
+# USER=PASSWORD,_g_:GROUP,...
+# _g_\:GROUP=ROLE1,ROLE2,...
+#
+# All users, grousp, and roles entered in this file are available after Karaf startup
+# and modifiable via the JAAS command group. These users reside in a JAAS domain
+# with the name "karaf".
+#
+karaf = karaf,_g_:admingroup
+onos = rocks,_g_:admingroup
+_g_\:admingroup = group,admin,manager,viewer,webconsole
diff --git a/framework/src/onos/tools/package/maven-plugin/pom.xml b/framework/src/onos/tools/package/maven-plugin/pom.xml
new file mode 100644
index 00000000..54839b11
--- /dev/null
+++ b/framework/src/onos/tools/package/maven-plugin/pom.xml
@@ -0,0 +1,122 @@
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-base</artifactId>
+ <version>1</version>
+ <relativePath>../../build/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-maven-plugin</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <description>Maven plugin for packaging ONOS applications or generating
+ component configuration resources
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thoughtworks.qdox</groupId>
+ <artifactId>qdox</artifactId>
+ <version>2.0-M3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>18.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.10</version>
+ </dependency>
+
+ <!-- dependencies to annotations -->
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>2.4.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.4</version>
+ <executions>
+ <execution>
+ <id>default-descriptor</id>
+ <phase>process-classes</phase>
+ </execution>
+ <!-- if you want to generate help goal -->
+ <execution>
+ <id>help-goal</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosAppMojo.java b/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosAppMojo.java
new file mode 100644
index 00000000..bfc6127a
--- /dev/null
+++ b/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosAppMojo.java
@@ -0,0 +1,372 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.
+ */
+package org.onosproject.maven;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import static com.google.common.io.ByteStreams.toByteArray;
+import static org.codehaus.plexus.util.FileUtils.*;
+
+/**
+ * Produces ONOS application archive using the app.xml file information.
+ */
+@Mojo(name = "app", defaultPhase = LifecyclePhase.PACKAGE)
+public class OnosAppMojo extends AbstractMojo {
+
+ private static final String APP = "app";
+ private static final String NAME = "[@name]";
+ private static final String VERSION = "[@version]";
+ private static final String FEATURES_REPO = "[@featuresRepo]";
+ private static final String ARTIFACT = "artifact";
+
+ private static final String APP_XML = "app.xml";
+ private static final String FEATURES_XML = "features.xml";
+
+ private static final String MVN_URL = "mvn:";
+ private static final String M2_PREFIX = "m2";
+
+ private static final String ONOS_APP_NAME = "onos.app.name";
+ private static final String ONOS_APP_ORIGIN = "onos.app.origin";
+
+ private static final String JAR = "jar";
+ private static final String XML = "xml";
+ private static final String APP_ZIP = "oar";
+ private static final String PACKAGE_DIR = "oar";
+
+ private static final String DEFAULT_ORIGIN = "ON.Lab";
+ private static final String DEFAULT_VERSION = "${project.version}";
+
+ private static final String DEFAULT_FEATURES_REPO =
+ "mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features";
+ private static final String DEFAULT_ARTIFACT =
+ "mvn:${project.groupId}/${project.artifactId}/${project.version}";
+
+ private static final int BUFFER_SIZE = 8192;
+
+ private String name;
+ private String origin;
+ private String version = DEFAULT_VERSION;
+ private String featuresRepo = DEFAULT_FEATURES_REPO;
+ private List<String> artifacts;
+
+ /**
+ * The project base directory.
+ */
+ @Parameter(defaultValue = "${basedir}")
+ protected File baseDir;
+
+ /**
+ * The directory where the generated catalogue file will be put.
+ */
+ @Parameter(defaultValue = "${project.build.directory}")
+ protected File dstDirectory;
+
+ /**
+ * The project group ID.
+ */
+ @Parameter(defaultValue = "${project.groupId}")
+ protected String projectGroupId;
+
+ /**
+ * The project artifact ID.
+ */
+ @Parameter(defaultValue = "${project.artifactId}")
+ protected String projectArtifactId;
+
+ /**
+ * The project version.
+ */
+ @Parameter(defaultValue = "${project.version}")
+ protected String projectVersion;
+
+ /**
+ * The project version.
+ */
+ @Parameter(defaultValue = "${project.description}")
+ protected String projectDescription;
+
+ @Parameter(defaultValue = "${localRepository}")
+ protected ArtifactRepository localRepository;
+
+ /**
+ * Maven project
+ */
+ @Parameter(defaultValue = "${project}")
+ protected MavenProject project;
+
+ /**
+ * Maven project helper.
+ */
+ @Component
+ protected MavenProjectHelper projectHelper;
+
+
+ private File m2Directory;
+ protected File stageDirectory;
+ protected String projectPath;
+
+ @Override
+ public void execute() throws MojoExecutionException {
+ File appFile = new File(baseDir, APP_XML);
+ File featuresFile = new File(baseDir, FEATURES_XML);
+
+ name = (String) project.getProperties().get(ONOS_APP_NAME);
+
+ // If neither the app.xml file exists, nor the onos.app.name property
+ // is defined, there is nothing for this Mojo to do, so bail.
+ if (!appFile.exists() && name == null) {
+ return;
+ }
+
+ m2Directory = new File(localRepository.getBasedir());
+ stageDirectory = new File(dstDirectory, PACKAGE_DIR);
+ projectPath = M2_PREFIX + "/" + artifactDir(projectGroupId, projectArtifactId, projectVersion);
+
+ origin = (String) project.getProperties().get(ONOS_APP_ORIGIN);
+ origin = origin != null ? origin : DEFAULT_ORIGIN;
+
+ if (appFile.exists()) {
+ loadAppFile(appFile);
+ } else {
+ artifacts = ImmutableList.of(eval(DEFAULT_ARTIFACT));
+ }
+
+ // If there are any artifacts, stage the
+ if (!artifacts.isEmpty()) {
+ getLog().info("Building ONOS application package for " + name + " (v" + eval(version) + ")");
+ artifacts.forEach(a -> getLog().debug("Including artifact: " + a));
+
+ if (stageDirectory.exists() || stageDirectory.mkdirs()) {
+ processAppXml(appFile);
+ processFeaturesXml(featuresFile);
+ processArtifacts();
+ generateAppPackage();
+ } else {
+ throw new MojoExecutionException("Unable to create directory: " + stageDirectory);
+ }
+ }
+ }
+
+ // Loads the app.xml file.
+ private void loadAppFile(File appFile) throws MojoExecutionException {
+ XMLConfiguration xml = new XMLConfiguration();
+ xml.setRootElementName(APP);
+
+ try (FileInputStream stream = new FileInputStream(appFile)) {
+ xml.load(stream);
+ xml.setAttributeSplittingDisabled(true);
+ xml.setDelimiterParsingDisabled(true);
+
+ name = xml.getString(NAME);
+ version = eval(xml.getString(VERSION));
+ featuresRepo = eval(xml.getString(FEATURES_REPO));
+
+ artifacts = xml.configurationsAt(ARTIFACT).stream()
+ .map(cfg -> eval(cfg.getRootNode().getValue().toString()))
+ .collect(Collectors.toList());
+
+ } catch (ConfigurationException e) {
+ throw new MojoExecutionException("Unable to parse app.xml file", e);
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException("Unable to find app.xml file", e);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Unable to read app.xml file", e);
+ }
+ }
+
+ // Processes and stages the app.xml file.
+ private void processAppXml(File appFile) throws MojoExecutionException {
+ try {
+ File file = new File(stageDirectory, APP_XML);
+ forceMkdir(stageDirectory);
+ String contents;
+
+ if (appFile.exists()) {
+ contents = fileRead(appFile);
+ } else {
+ byte[] bytes = toByteArray(getClass().getResourceAsStream(APP_XML));
+ contents = new String(bytes);
+ }
+ fileWrite(file.getAbsolutePath(), eval(contents));
+ } catch (IOException e) {
+ throw new MojoExecutionException("Unable to process app.xml", e);
+ }
+ }
+
+ private void processFeaturesXml(File featuresFile) throws MojoExecutionException {
+ boolean specified = featuresRepo != null && featuresRepo.length() > 0;
+
+ // If featuresRepo attribute is specified and there is a features.xml
+ // file present, add the features repo as an artifact
+ try {
+ if (specified && featuresFile.exists()) {
+ processFeaturesXml(new FileInputStream(featuresFile));
+ } else if (specified) {
+ processFeaturesXml(getClass().getResourceAsStream(FEATURES_XML));
+ }
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException("Unable to find features.xml file", e);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Unable to process features.xml file", e);
+ }
+ }
+
+ // Processes and stages the features.xml file.
+ private void processFeaturesXml(InputStream stream) throws IOException {
+ String featuresArtifact =
+ artifactFile(projectArtifactId, projectVersion, XML, "features");
+ File dstDir = new File(stageDirectory, projectPath);
+ forceMkdir(dstDir);
+ String s = eval(new String(toByteArray(stream)));
+ fileWrite(new File(dstDir, featuresArtifact).getAbsolutePath(), s);
+ }
+
+ // Stages all artifacts.
+ private void processArtifacts() throws MojoExecutionException {
+ for (String artifact : artifacts) {
+ processArtifact(artifact);
+ }
+ }
+
+ // Stages the specified artifact.
+ private void processArtifact(String artifact) throws MojoExecutionException {
+ if (!artifact.startsWith(MVN_URL)) {
+ throw new MojoExecutionException("Unsupported artifact URL:" + artifact);
+ }
+
+ String[] fields = artifact.substring(4).split("/");
+ if (fields.length < 3) {
+ throw new MojoExecutionException("Illegal artifact URL:" + artifact);
+ }
+
+ try {
+ String file = artifactFile(fields);
+
+ if (projectGroupId.equals(fields[0]) && projectArtifactId.equals(fields[1])) {
+ // Local artifact is not installed yet, package it from target directory.
+ File dstDir = new File(stageDirectory, projectPath);
+ forceMkdir(dstDir);
+ copyFile(new File(dstDirectory, file), new File(dstDir, file));
+ } else {
+ // Other artifacts are packaged from ~/.m2/repository directory.
+ String m2Path = artifactDir(fields);
+ File srcDir = new File(m2Directory, m2Path);
+ File dstDir = new File(stageDirectory, M2_PREFIX + "/" + m2Path);
+ forceMkdir(dstDir);
+ copyFile(new File(srcDir, file), new File(dstDir, file));
+ }
+ } catch (IOException e) {
+ throw new MojoExecutionException("Unable to stage artifact " + artifact, e);
+ }
+ }
+
+ // Generates the ONOS package ZIP file.
+ private void generateAppPackage() throws MojoExecutionException {
+ File appZip = new File(dstDirectory, artifactFile(projectArtifactId, projectVersion,
+ APP_ZIP, null));
+ try (FileOutputStream fos = new FileOutputStream(appZip);
+ ZipOutputStream zos = new ZipOutputStream(fos)) {
+ zipDirectory("", stageDirectory, zos);
+ projectHelper.attachArtifact(this.project, APP_ZIP, null, appZip);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Unable to compress application package", e);
+ }
+ }
+
+ // Generates artifact directory name from the specified fields.
+ private String artifactDir(String[] fields) {
+ return artifactDir(fields[0], fields[1], fields[2]);
+ }
+
+ // Generates artifact directory name from the specified elements.
+ private String artifactDir(String gid, String aid, String version) {
+ return gid.replace('.', '/') + "/" + aid.replace('.', '/') + "/" + version;
+ }
+
+ // Generates artifact file name from the specified fields.
+ private String artifactFile(String[] fields) {
+ return fields.length < 5 ?
+ artifactFile(fields[1], fields[2],
+ (fields.length < 4 ? JAR : fields[3]), null) :
+ artifactFile(fields[1], fields[2], fields[3], fields[4]);
+ }
+
+ // Generates artifact file name from the specified elements.
+ private String artifactFile(String aid, String version, String type,
+ String classifier) {
+ return classifier == null ? aid + "-" + version + "." + type :
+ aid + "-" + version + "-" + classifier + "." + type;
+ }
+
+ // Returns the given string with project variable substitutions.
+ private String eval(String string) {
+ return string == null ? null :
+ string.replaceAll("\\$\\{onos.app.name\\}", name)
+ .replaceAll("\\$\\{onos.app.origin\\}", origin)
+ .replaceAll("\\$\\{project.groupId\\}", projectGroupId)
+ .replaceAll("\\$\\{project.artifactId\\}", projectArtifactId)
+ .replaceAll("\\$\\{project.version\\}", projectVersion)
+ .replaceAll("\\$\\{project.description\\}", projectDescription);
+ }
+
+ // Recursively archives the specified directory into a given ZIP stream.
+ private void zipDirectory(String root, File dir, ZipOutputStream zos)
+ throws IOException {
+ byte[] buffer = new byte[BUFFER_SIZE];
+ File[] files = dir.listFiles();
+ if (files != null && files.length > 0) {
+ for (File file : files) {
+ if (file.isDirectory()) {
+ String path = root + file.getName() + "/";
+ zos.putNextEntry(new ZipEntry(path));
+ zipDirectory(path, file, zos);
+ zos.closeEntry();
+ } else {
+ FileInputStream fin = new FileInputStream(file);
+ zos.putNextEntry(new ZipEntry(root + file.getName()));
+ int length;
+ while ((length = fin.read(buffer)) > 0) {
+ zos.write(buffer, 0, length);
+ }
+ zos.closeEntry();
+ fin.close();
+ }
+ }
+ }
+ }
+}
diff --git a/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java b/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java
new file mode 100644
index 00000000..3e3e17a0
--- /dev/null
+++ b/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.
+ */
+package org.onosproject.maven;
+
+import com.thoughtworks.qdox.JavaProjectBuilder;
+import com.thoughtworks.qdox.model.JavaAnnotation;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Produces ONOS component configuration catalogue resources.
+ */
+@Mojo(name = "cfg", defaultPhase = LifecyclePhase.GENERATE_RESOURCES)
+public class OnosCfgMojo extends AbstractMojo {
+
+ private static final String COMPONENT = "org.apache.felix.scr.annotations.Component";
+ private static final String PROPERTY = "org.apache.felix.scr.annotations.Property";
+ private static final String SEP = "|";
+
+ /**
+ * The directory where the generated catalogue file will be put.
+ */
+ @Parameter(defaultValue = "${basedir}")
+ protected File srcDirectory;
+
+ /**
+ * The directory where the generated catalogue file will be put.
+ */
+ @Parameter(defaultValue = "${project.build.outputDirectory}")
+ protected File dstDirectory;
+
+ @Override
+ public void execute() throws MojoExecutionException {
+ getLog().info("Generating ONOS component configuration catalogues...");
+ try {
+ JavaProjectBuilder builder = new JavaProjectBuilder();
+ builder.addSourceTree(new File(srcDirectory, "src/main/java"));
+ builder.getClasses().forEach(this::processClass);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ private void processClass(JavaClass javaClass) {
+ boolean isComponent = javaClass.getAnnotations().stream()
+ .map(ja -> ja.getType().getName().equals(COMPONENT))
+ .findFirst().isPresent();
+ if (isComponent) {
+ List<String> lines = new ArrayList<>();
+ javaClass.getFields().forEach(field -> processField(lines, javaClass, field));
+ if (!lines.isEmpty()) {
+ writeCatalog(javaClass, lines);
+ }
+ }
+ }
+
+ private void writeCatalog(JavaClass javaClass, List<String> lines) {
+ File dir = new File(dstDirectory, javaClass.getPackageName().replace('.', '/'));
+ dir.mkdirs();
+
+ File cfgDef = new File(dir, javaClass.getName().replace('.', '/') + ".cfgdef");
+ try (FileWriter fw = new FileWriter(cfgDef);
+ PrintWriter pw = new PrintWriter(fw)) {
+ pw.println("# This file is auto-generated by onos-maven-plugin");
+ lines.forEach(pw::println);
+ } catch (IOException e) {
+ System.err.println("Unable to write catalog for " + javaClass.getName());
+ e.printStackTrace();
+ }
+ }
+
+ private void processField(List<String> lines, JavaClass javaClass, JavaField field) {
+ field.getAnnotations().forEach(ja -> {
+ if (ja.getType().getName().equals(PROPERTY)) {
+ lines.add(expand(javaClass, ja.getNamedParameter("name").toString()) +
+ SEP + type(field) +
+ SEP + defaultValue(javaClass, field, ja) +
+ SEP + description(ja));
+ }
+ });
+ }
+
+ // TODO: Stuff below is very much hack-ish and should be redone; it works for now though.
+
+ private String description(JavaAnnotation annotation) {
+ String description = (String) annotation.getNamedParameter("label");
+ return description.replaceAll("\" \\+ \"", "")
+ .replaceFirst("^[^\"]*\"", "").replaceFirst("\"$", "");
+ }
+
+ private String type(JavaField field) {
+ String ft = field.getType().getName().toUpperCase();
+ return ft.equals("INT") ? "INTEGER" : ft;
+ }
+
+ private String defaultValue(JavaClass javaClass, JavaField field,
+ JavaAnnotation annotation) {
+ String ft = field.getType().getName().toLowerCase();
+ String defValueName = ft.equals("boolean") ? "boolValue" :
+ ft.equals("string") ? "value" : ft + "Value";
+ Object dv = annotation.getNamedParameter(defValueName);
+ return dv == null ? "" : expand(javaClass, dv.toString());
+ }
+
+ private String stripQuotes(String string) {
+ return string.trim().replaceFirst("^[^\"]*\"", "").replaceFirst("\"$", "");
+ }
+
+ private String expand(JavaClass javaClass, String value) {
+ JavaField field = javaClass.getFieldByName(value);
+ return field == null ? stripQuotes(value) :
+ stripQuotes(field.getCodeBlock().replaceFirst(".*=", "").replaceFirst(";$", ""));
+ }
+
+}
diff --git a/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosSwaggerMojo.java b/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosSwaggerMojo.java
new file mode 100644
index 00000000..ea847459
--- /dev/null
+++ b/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosSwaggerMojo.java
@@ -0,0 +1,451 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.
+ */
+package org.onosproject.maven;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.io.ByteStreams;
+import com.google.common.io.Files;
+import com.thoughtworks.qdox.JavaProjectBuilder;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaAnnotation;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaParameter;
+import com.thoughtworks.qdox.model.JavaType;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
+
+/**
+ * Produces ONOS Swagger api-doc.
+ */
+@Mojo(name = "swagger", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class OnosSwaggerMojo extends AbstractMojo {
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ private static final String JSON_FILE = "swagger.json";
+ private static final String GEN_SRC = "generated-sources";
+ private static final String REG_SRC = "registrator.javat";
+
+ private static final String PATH = "javax.ws.rs.Path";
+ private static final String PATH_PARAM = "javax.ws.rs.PathParam";
+ private static final String QUERY_PARAM = "javax.ws.rs.QueryParam";
+ private static final String POST = "javax.ws.rs.POST";
+ private static final String GET = "javax.ws.rs.GET";
+ private static final String PUT = "javax.ws.rs.PUT";
+ private static final String DELETE = "javax.ws.rs.DELETE";
+ private static final String PRODUCES = "javax.ws.rs.Produces";
+ private static final String CONSUMES = "javax.ws.rs.Consumes";
+ private static final String JSON = "MediaType.APPLICATION_JSON";
+
+ /**
+ * The directory where the generated catalogue file will be put.
+ */
+ @Parameter(defaultValue = "${basedir}")
+ protected File srcDirectory;
+
+ /**
+ * The directory where the generated catalogue file will be put.
+ */
+ @Parameter(defaultValue = "${project.build.directory}")
+ protected File dstDirectory;
+
+ /**
+ * REST API web-context
+ */
+ @Parameter(defaultValue = "${web.context}")
+ protected String webContext;
+
+ /**
+ * REST API version
+ */
+ @Parameter(defaultValue = "${api.version}")
+ protected String apiVersion;
+
+ /**
+ * REST API description
+ */
+ @Parameter(defaultValue = "${api.description}")
+ protected String apiDescription;
+
+ /**
+ * REST API title
+ */
+ @Parameter(defaultValue = "${api.title}")
+ protected String apiTitle;
+
+ /**
+ * REST API title
+ */
+ @Parameter(defaultValue = "${api.package}")
+ protected String apiPackage;
+
+ /**
+ * Maven project
+ */
+ @Parameter(defaultValue = "${project}")
+ protected MavenProject project;
+
+
+ @Override
+ public void execute() throws MojoExecutionException {
+ try {
+ JavaProjectBuilder builder = new JavaProjectBuilder();
+ builder.addSourceTree(new File(srcDirectory, "src/main/java"));
+
+ ObjectNode root = initializeRoot();
+ ArrayNode tags = mapper.createArrayNode();
+ ObjectNode paths = mapper.createObjectNode();
+
+ root.set("tags", tags);
+ root.set("paths", paths);
+
+ builder.getClasses().forEach(jc -> processClass(jc, paths, tags));
+
+ if (paths.size() > 0) {
+ getLog().info("Generating ONOS REST API documentation...");
+ genCatalog(root);
+
+ if (!isNullOrEmpty(apiPackage)) {
+ genRegistrator();
+ }
+ }
+
+ project.addCompileSourceRoot(new File(dstDirectory, GEN_SRC).getPath());
+
+ } catch (Exception e) {
+ getLog().warn("Unable to generate ONOS REST API documentation", e);
+ throw e;
+ }
+ }
+
+ // initializes top level root with Swagger required specifications
+ private ObjectNode initializeRoot() {
+ ObjectNode root = mapper.createObjectNode();
+ root.put("swagger", "2.0");
+ ObjectNode info = mapper.createObjectNode();
+ root.set("info", info);
+
+ root.put("basePath", webContext);
+ info.put("version", apiVersion);
+ info.put("title", apiTitle);
+ info.put("description", apiDescription);
+
+ ArrayNode produces = mapper.createArrayNode();
+ produces.add("application/json");
+ root.set("produces", produces);
+
+ ArrayNode consumes = mapper.createArrayNode();
+ consumes.add("application/json");
+ root.set("consumes", consumes);
+
+ return root;
+ }
+
+ // Checks whether javaClass has a path tag associated with it and if it does
+ // processes its methods and creates a tag for the class on the root
+ void processClass(JavaClass javaClass, ObjectNode paths, ArrayNode tags) {
+ // If the class does not have a Path tag then ignore it
+ JavaAnnotation annotation = getPathAnnotation(javaClass);
+ if (annotation == null) {
+ return;
+ }
+
+ String path = getPath(annotation);
+ if (path == null) {
+ return;
+ }
+
+ String resourcePath = "/" + path;
+ String tagPath = path.isEmpty() ? "/" : path;
+
+ // Create tag node for this class.
+ ObjectNode tagObject = mapper.createObjectNode();
+ tagObject.put("name", tagPath);
+ if (javaClass.getComment() != null) {
+ tagObject.put("description", shortText(javaClass.getComment()));
+ }
+ tags.add(tagObject);
+
+ // Create an array node add to all methods from this class.
+ ArrayNode tagArray = mapper.createArrayNode();
+ tagArray.add(tagPath);
+
+ processAllMethods(javaClass, resourcePath, paths, tagArray);
+ }
+
+ private JavaAnnotation getPathAnnotation(JavaClass javaClass) {
+ Optional<JavaAnnotation> optional = javaClass.getAnnotations()
+ .stream().filter(a -> a.getType().getName().equals(PATH)).findAny();
+ return optional.isPresent() ? optional.get() : null;
+ }
+
+ // Checks whether a class's methods are REST methods and then places all the
+ // methods under a specific path into the paths node
+ private void processAllMethods(JavaClass javaClass, String resourcePath,
+ ObjectNode paths, ArrayNode tagArray) {
+ // map of the path to its methods represented by an ObjectNode
+ Map<String, ObjectNode> pathMap = new HashMap<>();
+
+ javaClass.getMethods().forEach(javaMethod -> {
+ javaMethod.getAnnotations().forEach(annotation -> {
+ String name = annotation.getType().getName();
+ if (name.equals(POST) || name.equals(GET) || name.equals(DELETE) || name.equals(PUT)) {
+ // substring(12) removes "javax.ws.rs."
+ String method = annotation.getType().toString().substring(12).toLowerCase();
+ processRestMethod(javaMethod, method, pathMap, resourcePath, tagArray);
+ }
+ });
+ });
+
+ // for each path add its methods to the path node
+ for (Map.Entry<String, ObjectNode> entry : pathMap.entrySet()) {
+ paths.set(entry.getKey(), entry.getValue());
+ }
+
+
+ }
+
+ private void processRestMethod(JavaMethod javaMethod, String method,
+ Map<String, ObjectNode> pathMap,
+ String resourcePath, ArrayNode tagArray) {
+ String fullPath = resourcePath, consumes = "", produces = "",
+ comment = javaMethod.getComment();
+ for (JavaAnnotation annotation : javaMethod.getAnnotations()) {
+ String name = annotation.getType().getName();
+ if (name.equals(PATH)) {
+ fullPath = resourcePath + "/" + getPath(annotation);
+ fullPath = fullPath.replaceFirst("^//", "/");
+ }
+ if (name.equals(CONSUMES)) {
+ consumes = getIOType(annotation);
+ }
+ if (name.equals(PRODUCES)) {
+ produces = getIOType(annotation);
+ }
+ }
+ ObjectNode methodNode = mapper.createObjectNode();
+ methodNode.set("tags", tagArray);
+
+ addSummaryDescriptions(methodNode, comment);
+ processParameters(javaMethod, methodNode);
+
+ processConsumesProduces(methodNode, "consumes", consumes);
+ processConsumesProduces(methodNode, "produces", produces);
+
+ addResponses(methodNode);
+
+ ObjectNode operations = pathMap.get(fullPath);
+ if (operations == null) {
+ operations = mapper.createObjectNode();
+ operations.set(method, methodNode);
+ pathMap.put(fullPath, operations);
+ } else {
+ operations.set(method, methodNode);
+ }
+ }
+
+ private void processConsumesProduces(ObjectNode methodNode, String type, String io) {
+ if (!io.equals("")) {
+ ArrayNode array = mapper.createArrayNode();
+ methodNode.set(type, array);
+ array.add(io);
+ }
+ }
+
+ private void addSummaryDescriptions(ObjectNode methodNode, String comment) {
+ String summary = "", description;
+ if (comment != null) {
+ if (comment.contains(".")) {
+ int periodIndex = comment.indexOf(".");
+ summary = comment.substring(0, periodIndex);
+ description = comment.length() > periodIndex + 1 ?
+ comment.substring(periodIndex + 1).trim() : "";
+ } else {
+ description = comment;
+ }
+ methodNode.put("summary", summary);
+ methodNode.put("description", description);
+ }
+ }
+
+ // Temporary solution to add responses to a method
+ // TODO Provide annotations in the web resources for responses and parse them
+ private void addResponses(ObjectNode methodNode) {
+ ObjectNode responses = mapper.createObjectNode();
+ methodNode.set("responses", responses);
+
+ ObjectNode success = mapper.createObjectNode();
+ success.put("description", "successful operation");
+ responses.set("200", success);
+
+ ObjectNode defaultObj = mapper.createObjectNode();
+ defaultObj.put("description", "Unexpected error");
+ responses.set("default", defaultObj);
+ }
+
+ // Checks if the annotations has a value of JSON and returns the string
+ // that Swagger requires
+ private String getIOType(JavaAnnotation annotation) {
+ if (annotation.getNamedParameter("value").toString().equals(JSON)) {
+ return "application/json";
+ }
+ return "";
+ }
+
+ // If the annotation has a Path tag, returns the value with leading and
+ // trailing double quotes and slash removed.
+ private String getPath(JavaAnnotation annotation) {
+ String path = annotation.getNamedParameter("value").toString();
+ return path == null ? null : path.replaceAll("(^[\\\"/]*|[/\\\"]*$)", "");
+ }
+
+ // Processes parameters of javaMethod and enters the proper key-values into the methodNode
+ private void processParameters(JavaMethod javaMethod, ObjectNode methodNode) {
+ ArrayNode parameters = mapper.createArrayNode();
+ methodNode.set("parameters", parameters);
+ boolean required = true;
+
+ for (JavaParameter javaParameter : javaMethod.getParameters()) {
+ ObjectNode individualParameterNode = mapper.createObjectNode();
+ Optional<JavaAnnotation> optional = javaParameter.getAnnotations().stream().filter(
+ annotation -> annotation.getType().getName().equals(PATH_PARAM) ||
+ annotation.getType().getName().equals(QUERY_PARAM)).findAny();
+ JavaAnnotation pathType = optional.isPresent() ? optional.get() : null;
+
+ String annotationName = javaParameter.getName();
+
+
+ if (pathType != null) { //the parameter is a path or query parameter
+ individualParameterNode.put("name",
+ pathType.getNamedParameter("value").toString().replace("\"", ""));
+ if (pathType.getType().getName().equals(PATH_PARAM)) {
+ individualParameterNode.put("in", "path");
+ } else if (pathType.getType().getName().equals(QUERY_PARAM)) {
+ individualParameterNode.put("in", "query");
+ }
+ individualParameterNode.put("type", getType(javaParameter.getType()));
+ } else { // the parameter is a body parameter
+ individualParameterNode.put("name", annotationName);
+ individualParameterNode.put("in", "body");
+
+ // TODO add actual hardcoded schemas and a type
+ // body parameters must have a schema associated with them
+ ArrayNode schema = mapper.createArrayNode();
+ individualParameterNode.set("schema", schema);
+ }
+ for (DocletTag p : javaMethod.getTagsByName("param")) {
+ if (p.getValue().contains(annotationName)) {
+ try {
+ String description = p.getValue().split(" ", 2)[1].trim();
+ if (description.contains("optional")) {
+ required = false;
+ }
+ individualParameterNode.put("description", description);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ individualParameterNode.put("required", required);
+ parameters.add(individualParameterNode);
+ }
+ }
+
+ // Returns the Swagger specified strings for the type of a parameter
+ private String getType(JavaType javaType) {
+ String type = javaType.getFullyQualifiedName();
+ String value;
+ if (type.equals(String.class.getName())) {
+ value = "string";
+ } else if (type.equals("int")) {
+ value = "integer";
+ } else if (type.equals(boolean.class.getName())) {
+ value = "boolean";
+ } else if (type.equals(long.class.getName())) {
+ value = "number";
+ } else {
+ value = "";
+ }
+ return value;
+ }
+
+ // Writes the swagger.json file using the supplied JSON root.
+ private void genCatalog(ObjectNode root) {
+ File swaggerCfg = new File(dstDirectory, JSON_FILE);
+ if (dstDirectory.exists() || dstDirectory.mkdirs()) {
+ try (FileWriter fw = new FileWriter(swaggerCfg);
+ PrintWriter pw = new PrintWriter(fw)) {
+ pw.println(root.toString());
+ } catch (IOException e) {
+ getLog().warn("Unable to write " + JSON_FILE);
+ }
+ } else {
+ getLog().warn("Unable to create " + dstDirectory);
+ }
+ }
+
+ // Generates the registrator Java component.
+ private void genRegistrator() {
+ File dir = new File(dstDirectory, GEN_SRC);
+ File reg = new File(dir, apiPackage.replaceAll("\\.", "/") + "/ApiDocRegistrator.java");
+ File pkg = reg.getParentFile();
+ if (pkg.exists() || pkg.mkdirs()) {
+ try {
+ String src = new String(ByteStreams.toByteArray(getClass().getResourceAsStream(REG_SRC)));
+ src = src.replace("${api.package}", apiPackage)
+ .replace("${web.context}", webContext)
+ .replace("${api.title}", apiTitle)
+ .replace("${api.description}", apiTitle);
+ Files.write(src.getBytes(), reg);
+ } catch (IOException e) {
+ getLog().warn("Unable to write " + reg);
+ }
+ } else {
+ getLog().warn("Unable to create " + reg);
+ }
+ }
+
+ // Returns "nickname" based on method and path for a REST method
+ private String setNickname(String method, String path) {
+ if (!path.equals("")) {
+ return (method + path.replace('/', '_').replace("{", "").replace("}", "")).toLowerCase();
+ } else {
+ return method.toLowerCase();
+ }
+ }
+
+ private String shortText(String comment) {
+ int i = comment.indexOf('.');
+ return i > 0 ? comment.substring(0, i) : comment;
+ }
+
+}
diff --git a/framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/app.xml b/framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/app.xml
new file mode 100644
index 00000000..0f3133d3
--- /dev/null
+++ b/framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/app.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<app name="${onos.app.name}" origin="${onos.app.origin}" version="${project.version}"
+ featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
+ features="${project.artifactId}">
+ <description>${project.description}</description>
+ <artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
+</app>
diff --git a/framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/features.xml b/framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/features.xml
new file mode 100644
index 00000000..d5a91e2a
--- /dev/null
+++ b/framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/features.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
+ <repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
+ <feature name="${project.artifactId}" version="${project.version}"
+ description="${project.description}">
+ <feature>onos-api</feature>
+ <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
+ </feature>
+</features>
diff --git a/framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/registrator.javat b/framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/registrator.javat
new file mode 100644
index 00000000..a8e26536
--- /dev/null
+++ b/framework/src/onos/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/registrator.javat
@@ -0,0 +1,31 @@
+/*
+ * Auto-generated by OnosSwaggerMojo.
+ *
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.
+ */
+package ${api.package};
+
+import org.apache.felix.scr.annotations.Component;
+import org.onosproject.rest.AbstractApiDocRegistrator;
+import org.onosproject.rest.ApiDocProvider;
+
+@Component(immediate = true)
+public class ApiDocRegistrator extends AbstractApiDocRegistrator {
+ public ApiDocRegistrator() {
+ super(new ApiDocProvider("${web.context}",
+ "${api.title}",
+ ApiDocRegistrator.class.getClassLoader()));
+ }
+}