Reorganizing ODTN app structure

- separated code which could be referenced from drivers

Change-Id: Ic2c0ae0507abc626771dfaf7a8fc18b5a715cc30
diff --git a/apps/odtn/api/BUCK b/apps/odtn/api/BUCK
new file mode 100644
index 0000000..c3cdf13
--- /dev/null
+++ b/apps/odtn/api/BUCK
@@ -0,0 +1,34 @@
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+    '//lib:JACKSON',
+    '//lib:onos-yang-model',
+    '//lib:onos-yang-runtime',
+    '//models/tapi:onos-models-tapi',
+    '//models/openconfig:onos-models-openconfig',
+    '//apps/yang:onos-apps-yang',
+]
+
+TEST_DEPS = [
+    '//lib:TEST_ADAPTERS',
+]
+
+osgi_jar_with_tests (
+    deps = COMPILE_DEPS,
+    test_deps = TEST_DEPS,
+)
+
+APPS = [
+    'org.onosproject.yang',
+    'org.onosproject.models.tapi',
+    'org.onosproject.models.openconfig',
+]
+
+# TODO probably bucklet, etc. should escape title & description
+onos_app (
+    app_name = 'org.onosproject.odtn-api',
+    title = 'ODTN API & Utilities Application',
+    category = 'Traffic Steering',
+    url = 'http://onosproject.org',
+    description = 'ODTN API & Utilities Application',
+    required_apps = APPS,
+)
diff --git a/apps/odtn/api/pom.xml b/apps/odtn/api/pom.xml
new file mode 100644
index 0000000..1d971fc
--- /dev/null
+++ b/apps/odtn/api/pom.xml
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2018 Open Networking Foundation
+  ~
+  ~ 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-apps-odtn</artifactId>
+        <version>1.14.0-SNAPSHOT</version>
+    </parent>
+
+
+    <artifactId>onos-apps-odtn-api</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>ONOS ODTN API</description>
+    <url>http://onosproject.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <onos.version>${project.version}</onos.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-runtime</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-models-tapi</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-models-openconfig</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-osgi</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <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>
+                <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/apps/odtn/src/main/java/org/onosproject/odtn/behaviour/ConfigurableTransceiver.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/ConfigurableTransceiver.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/behaviour/ConfigurableTransceiver.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/ConfigurableTransceiver.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java
similarity index 95%
rename from apps/odtn/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java
index 025f1c5..e8657ea 100644
--- a/apps/odtn/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java
@@ -23,7 +23,7 @@
 /**
  * DeviceDescriptionDiscovery used in ODTN.
  *
- * Certain Annotations will be required.
+ * Just declaring certain Annotations will be required.
  */
 public interface OdtnDeviceDescriptionDiscovery
         extends DeviceDescriptionDiscovery {
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/behaviour/PlainTransceiver.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/PlainTransceiver.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/behaviour/PlainTransceiver.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/PlainTransceiver.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/behaviour/package-info.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/package-info.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/behaviour/package-info.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/package-info.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/package-info.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/package-info.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/package-info.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/package-info.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/utils/YangToolUtil.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/YangToolUtil.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/utils/YangToolUtil.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/utils/YangToolUtil.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/utils/openconfig/OpticalChannel.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/openconfig/OpticalChannel.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/utils/openconfig/OpticalChannel.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/utils/openconfig/OpticalChannel.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/utils/openconfig/PlainPlatform.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/openconfig/PlainPlatform.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/utils/openconfig/PlainPlatform.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/utils/openconfig/PlainPlatform.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/utils/openconfig/Transceiver.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/openconfig/Transceiver.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/utils/openconfig/Transceiver.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/utils/openconfig/Transceiver.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/utils/openconfig/package-info.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/openconfig/package-info.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/utils/openconfig/package-info.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/utils/openconfig/package-info.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/utils/package-info.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/utils/package-info.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/utils/package-info.java
rename to apps/odtn/api/src/main/java/org/onosproject/odtn/utils/package-info.java
diff --git a/apps/odtn/pom.xml b/apps/odtn/pom.xml
index 095b9af..c6686aa 100644
--- a/apps/odtn/pom.xml
+++ b/apps/odtn/pom.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  ~ Copyright 2018 Open Networking Foundation
+  ~ Copyright 2014-present Open Networking Foundation
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
@@ -14,7 +14,8 @@
   ~ 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">
+<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>
@@ -23,153 +24,14 @@
         <version>1.14.0-SNAPSHOT</version>
     </parent>
 
-
     <artifactId>onos-apps-odtn</artifactId>
-    <packaging>bundle</packaging>
+    <packaging>pom</packaging>
 
-    <description>ONOS ODTN service application</description>
-    <url>http://onosproject.org</url>
+    <description>ONOS ODTN application</description>
 
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <onos.version>${project.version}</onos.version>
-        <onos.app.name>org.onosproject.odtn</onos.app.name>
-    </properties>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-yang-runtime</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-apps-config</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-models-tapi</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-models-openconfig</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-api</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onlab-osgi</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-cli</artifactId>
-            <version>${onos.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.karaf.shell</groupId>
-            <artifactId>org.apache.karaf.shell.console</artifactId>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-api</artifactId>
-            <scope>test</scope>
-            <classifier>tests</classifier>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr.annotations</artifactId>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-protocols-netconf-api</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <extensions>true</extensions>
-            </plugin>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-            </plugin>
-
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-                <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>
-                <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>
+    <modules>
+        <module>api</module>
+        <module>service</module>
+    </modules>
 
 </project>
diff --git a/apps/odtn/BUCK b/apps/odtn/service/BUCK
similarity index 79%
rename from apps/odtn/BUCK
rename to apps/odtn/service/BUCK
index 9408d9b..12e6e1e 100644
--- a/apps/odtn/BUCK
+++ b/apps/odtn/service/BUCK
@@ -1,20 +1,6 @@
-APPS = [
-    'org.onosproject.yang',
-    'org.onosproject.config',
-    'org.onosproject.configsync',
-    'org.onosproject.models.tapi',
-    'org.onosproject.models.openconfig',
-
-    # strictly speaking following are not mandatory
-    'org.onosproject.restconf',
-    'org.onosproject.drivers.netconf',# probably don't need this
-    'org.onosproject.netconf',
-    'org.onosproject.configsync-netconf',
-    'org.onosproject.protocols.restconfserver'
-]
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
+    '//apps/odtn/api:onos-apps-odtn-api',
     '//lib:onos-yang-model',
     '//lib:onos-yang-runtime',
     '//apps/config:onos-apps-config',
@@ -25,7 +11,6 @@
     '//lib:org.apache.karaf.shell.console',
     '//cli:onos-cli',
     '//lib:JACKSON',
-    '//lib:COMPILE',
     '//protocols/netconf/api:onos-protocols-netconf-api'
 ]
 
@@ -38,7 +23,25 @@
     test_deps = TEST_DEPS,
 )
 
+APPS = [
+    'org.onosproject.yang',
+    'org.onosproject.config',
+    'org.onosproject.configsync',
+    'org.onosproject.models.tapi',
+    'org.onosproject.models.openconfig',
+    'org.onosproject.odtn-api'
+
+    # strictly speaking following are not mandatory
+    'org.onosproject.restconf',
+    'org.onosproject.drivers.netconf',# will need if using TemplateManager
+    'org.onosproject.drivers.odtn',
+    'org.onosproject.netconf',
+    'org.onosproject.configsync-netconf',
+    'org.onosproject.protocols.restconfserver',
+]
+
 onos_app (
+    app_name = 'org.onosproject.odtn-service',
     title = 'ODTN Service Application',
     category = 'Traffic Steering',
     url = 'http://onosproject.org',
diff --git a/apps/odtn/service/pom.xml b/apps/odtn/service/pom.xml
new file mode 100644
index 0000000..d678001
--- /dev/null
+++ b/apps/odtn/service/pom.xml
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2018 Open Networking Foundation
+  ~
+  ~ 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-apps-odtn</artifactId>
+        <version>1.14.0-SNAPSHOT</version>
+    </parent>
+
+
+    <artifactId>onos-apps-odtn-service</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>ONOS ODTN service application</description>
+    <url>http://onosproject.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <onos.version>${project.version}</onos.version>
+        <onos.app.name>org.onosproject.odtn</onos.app.name>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-apps-odtn-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-runtime</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-apps-config</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-models-tapi</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-models-openconfig</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-osgi</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-cli</artifactId>
+            <version>${onos.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-protocols-netconf-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <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>
+                <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/apps/odtn/src/main/java/org/onosproject/odtn/cli/impl/ModeCompleter.java b/apps/odtn/service/src/main/java/org/onosproject/odtn/cli/impl/ModeCompleter.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/cli/impl/ModeCompleter.java
rename to apps/odtn/service/src/main/java/org/onosproject/odtn/cli/impl/ModeCompleter.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/cli/impl/OdtnManualTestCommand.java b/apps/odtn/service/src/main/java/org/onosproject/odtn/cli/impl/OdtnManualTestCommand.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/cli/impl/OdtnManualTestCommand.java
rename to apps/odtn/service/src/main/java/org/onosproject/odtn/cli/impl/OdtnManualTestCommand.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/cli/impl/package-info.java b/apps/odtn/service/src/main/java/org/onosproject/odtn/cli/impl/package-info.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/cli/impl/package-info.java
rename to apps/odtn/service/src/main/java/org/onosproject/odtn/cli/impl/package-info.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/impl/ServiceApplicationComponent.java b/apps/odtn/service/src/main/java/org/onosproject/odtn/impl/ServiceApplicationComponent.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/impl/ServiceApplicationComponent.java
rename to apps/odtn/service/src/main/java/org/onosproject/odtn/impl/ServiceApplicationComponent.java
diff --git a/apps/odtn/src/main/java/org/onosproject/odtn/impl/package-info.java b/apps/odtn/service/src/main/java/org/onosproject/odtn/impl/package-info.java
similarity index 100%
rename from apps/odtn/src/main/java/org/onosproject/odtn/impl/package-info.java
rename to apps/odtn/service/src/main/java/org/onosproject/odtn/impl/package-info.java
diff --git a/apps/odtn/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/apps/odtn/service/src/main/resources/OSGI-INF/blueprint/shell-config.xml
similarity index 100%
rename from apps/odtn/src/main/resources/OSGI-INF/blueprint/shell-config.xml
rename to apps/odtn/service/src/main/resources/OSGI-INF/blueprint/shell-config.xml
diff --git a/apps/odtn/src/test/resources/create-connectivity.json b/apps/odtn/service/src/test/resources/create-connectivity.json
similarity index 100%
rename from apps/odtn/src/test/resources/create-connectivity.json
rename to apps/odtn/service/src/test/resources/create-connectivity.json
diff --git a/apps/odtn/src/test/resources/nbi-tapi-sample.json b/apps/odtn/service/src/test/resources/nbi-tapi-sample.json
similarity index 100%
rename from apps/odtn/src/test/resources/nbi-tapi-sample.json
rename to apps/odtn/service/src/test/resources/nbi-tapi-sample.json
diff --git a/apps/odtn/src/test/resources/post-nbi-tapi-rpc b/apps/odtn/service/src/test/resources/post-nbi-tapi-rpc
similarity index 100%
rename from apps/odtn/src/test/resources/post-nbi-tapi-rpc
rename to apps/odtn/service/src/test/resources/post-nbi-tapi-rpc
diff --git a/apps/odtn/src/test/resources/post-nbi-tapi-sample b/apps/odtn/service/src/test/resources/post-nbi-tapi-sample
similarity index 100%
rename from apps/odtn/src/test/resources/post-nbi-tapi-sample
rename to apps/odtn/service/src/test/resources/post-nbi-tapi-sample
diff --git a/drivers/odtn-driver/BUCK b/drivers/odtn-driver/BUCK
index 9078939..d62183e 100644
--- a/drivers/odtn-driver/BUCK
+++ b/drivers/odtn-driver/BUCK
@@ -2,7 +2,7 @@
     '//lib:CORE_DEPS',
     '//protocols/netconf/api:onos-protocols-netconf-api',
     '//lib:commons-jxpath',
-    '//apps/odtn:onos-apps-odtn', # FIXME direction of dependency not ideal
+    '//apps/odtn/api:onos-apps-odtn-api',
 ]
 
 TEST_DEPS = [
@@ -34,6 +34,6 @@
     included_bundles = BUNDLES,
     required_apps = [
         'org.onosproject.netconf',
-        'org.onosproject.odtn',
+        'org.onosproject.odtn-api',
     ],
 )
diff --git a/drivers/odtn-driver/pom.xml b/drivers/odtn-driver/pom.xml
index 0f93c09..6f1df76 100644
--- a/drivers/odtn-driver/pom.xml
+++ b/drivers/odtn-driver/pom.xml
@@ -33,10 +33,9 @@
 
     <dependencies>
 
-        <!-- FIXME direction of dependency not ideal -->
         <dependency>
             <groupId>org.onosproject</groupId>
-            <artifactId>onos-apps-odtn</artifactId>
+            <artifactId>onos-apps-odtn-api</artifactId>
             <version>${project.version}</version>
         </dependency>
 
diff --git a/modules.defs b/modules.defs
index 5f6ce6d..bd785ba 100644
--- a/modules.defs
+++ b/modules.defs
@@ -245,7 +245,8 @@
     '//apps/simplefabric:onos-apps-simplefabric-oar',
     '//apps/kafka-integration:onos-apps-kafka-integration-oar',
     '//apps/rabbitmq:onos-apps-rabbitmq-oar',
-    '//apps/odtn:onos-apps-odtn-oar',
+    '//apps/odtn/api:onos-apps-odtn-api-oar',
+    '//apps/odtn/service:onos-apps-odtn-service-oar',
     '//apps/mcast:onos-apps-mcast-oar',
     '//apps/layout:onos-apps-layout-oar',
     '//apps/imr:onos-apps-imr-oar',