Adding pom files for P4Runtime and GRPC

Change-Id: I9e205fc054875813200fe83a0bca4a9152ec66ae
diff --git a/lib/pom.xml b/lib/pom.xml
index c6ca6a3..f904eaa 100644
--- a/lib/pom.xml
+++ b/lib/pom.xml
@@ -54,6 +54,7 @@
                   to fix locale errors for non-US developers. However, it breaks
                   SonarQube's test coverage, so moving here for now. -->
         <argLine>-Duser.language=en -Duser.region=US</argLine>
+        <grpccore.version>1.3.0</grpccore.version>
     </properties>
 
     <dependencyManagement>
@@ -675,6 +676,12 @@
             <groupId>com.google.code.findbugs</groupId>
             <artifactId>jsr305</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-core</artifactId>
+            <version>${grpccore.version}</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/pipelines/basic/pom.xml b/pipelines/basic/pom.xml
index 6e8eeca..ea234f5 100644
--- a/pipelines/basic/pom.xml
+++ b/pipelines/basic/pom.xml
@@ -14,7 +14,6 @@
   ~ 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">
@@ -26,8 +25,24 @@
     <modelVersion>4.0.0</modelVersion>
 
     <description>ONOS Basic pipeline</description>
-
     <artifactId>onos-pipelines-basic</artifactId>
     <packaging>bundle</packaging>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-incubator-bmv2-model</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-protocols-p4runtime-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-drivers-default</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
 </project>
diff --git a/pom.xml b/pom.xml
index 89cad86..72e61e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,10 +68,10 @@
 
         <module>models</module>
 
-        <module>pipelines/basic</module>
-
         <module>tools/package/archetypes</module>
         <module>tools/package/branding</module>
+
+        <module>pipelines</module>
     </modules>
 
     <!--<repositories>-->
diff --git a/protocols/p4runtime/api/pom.xml b/protocols/p4runtime/api/pom.xml
index 0d31cb5..79e797f 100644
--- a/protocols/p4runtime/api/pom.xml
+++ b/protocols/p4runtime/api/pom.xml
@@ -14,7 +14,6 @@
   ~ 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">
@@ -30,4 +29,10 @@
     <artifactId>onos-protocols-p4runtime-api</artifactId>
     <packaging>bundle</packaging>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+        </dependency>
+    </dependencies>
 </project>
diff --git a/protocols/p4runtime/ctl/pom.xml b/protocols/p4runtime/ctl/pom.xml
new file mode 100644
index 0000000..99ff844
--- /dev/null
+++ b/protocols/p4runtime/ctl/pom.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+  ~ Copyright 2015-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.
+  ~ 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
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-protocols-p4runtime</artifactId>
+        <version>1.12.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>onos-protocols-p4runtime-ctl</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>ONOS P4Runtime Controller</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-protocols-p4runtime-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-protocols-p4runtime-proto</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-grpc-protocol-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git a/protocols/p4runtime/pom.xml b/protocols/p4runtime/pom.xml
index e1afc1f..6dfdde6 100644
--- a/protocols/p4runtime/pom.xml
+++ b/protocols/p4runtime/pom.xml
@@ -32,6 +32,8 @@
 
     <modules>
         <module>api</module>
+	<module>proto</module>
+	<module>ctl</module>
     </modules>
 
     <!--<properties>
diff --git a/protocols/p4runtime/proto/pom.xml b/protocols/p4runtime/proto/pom.xml
new file mode 100644
index 0000000..7e16bad
--- /dev/null
+++ b/protocols/p4runtime/proto/pom.xml
@@ -0,0 +1,193 @@
+<?xml version="1.0"?>
+<!--
+  ~ Copyright 2015-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.
+  ~ 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
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-protocols-p4runtime</artifactId>
+        <version>1.12.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>onos-protocols-p4runtime-proto</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>ONOS P4Runtime Proto</description>
+
+    <properties>
+        <os.detected.classifier>linux-x86_64</os.detected.classifier>
+        <protobuf.version>3.0.2</protobuf.version>
+        <piCommit>a8814a8ac40838a9df83fe47a17a025b69026fcf</piCommit>
+        <piBaseUrl>https://github.com/p4lang/PI.git</piBaseUrl>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-protocols-p4runtime-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-incubator-grpc</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-core</artifactId>
+            <version>${grpccore.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.protobuf</groupId>
+            <artifactId>protobuf-java</artifactId>
+            <version>${protobuf.version}</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.1.1</version>
+                <executions>
+                    <execution>
+                        <id>clone pi</id>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <phase>initialize</phase>
+                        <configuration>
+                            <workingDirectory>target</workingDirectory>
+                            <executable>git</executable>
+                            <arguments>
+                                <argument>clone</argument>
+                                <!--<argument>&#45;&#45;quiet</argument>-->
+                                <argument>${piBaseUrl}</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>checkout pi</id>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <phase>initialize</phase>
+                        <configuration>
+                            <workingDirectory>target/PI</workingDirectory>
+                            <executable>git</executable>
+                            <arguments>
+                                <argument>checkout</argument>
+                                <!--<argument>&#45;&#45;quiet</argument>-->
+                                <argument>-b</argument>
+                                <argument>buck-build</argument>
+                                <argument>${piCommit}</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>submodule pi</id>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <phase>initialize</phase>
+                        <configuration>
+                            <workingDirectory>target/PI</workingDirectory>
+                            <executable>git</executable>
+                            <arguments>
+                                <argument>submodule</argument>
+                                <argument>update</argument>
+                                <!--<argument>&#45;&#45;quiet</argument>-->
+                                <argument>--init</argument>
+                                <argument>--recursive</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.xolstice.maven.plugins</groupId>
+                <artifactId>protobuf-maven-plugin</artifactId>
+                <version>0.5.0</version>
+                <configuration>
+                    <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
+                    <pluginId>grpc</pluginId>
+                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpccore.version}:exe:${os.detected.classifier}</pluginArtifact>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>compile</goal>
+                            <goal>compile-custom</goal>
+                        </goals>
+                        <phase>generate-sources</phase>
+                        <configuration>
+                            <protoSourceRoot>${project.basedir}/target/PI/proto</protoSourceRoot>
+                            <includes>
+                                <include>p4/**/*.proto</include>
+                                <include>google/rpc/*.proto</include>
+                            </includes>
+                            <excludes>
+                                <exclude>openconfig/**/*.proto</exclude>
+                            </excludes>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>3.0.0</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources combine.children="append">
+                                <source>${project.build.directory}/generated-sources/protobuf/grpc-java</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <!--<plugin>-->
+                <!--<groupId>com.googlecode.maven-download-plugin</groupId>-->
+                <!--<artifactId>download-maven-plugin</artifactId>-->
+                <!--<version>1.3.0</version>-->
+                <!--<executions>-->
+                    <!--<execution>-->
+                        <!--<id>install-any</id>-->
+                        <!--<phase>generate-resources</phase>-->
+                        <!--<goals>-->
+                            <!--<goal>wget</goal>-->
+                        <!--</goals>-->
+                        <!--<configuration>-->
+                            <!--<url>https://raw.githubusercontent.com/google/protobuf/master/src/google/protobuf/any.proto</url>-->
+                            <!--<outputDirectory>${project.basedir}/target/PI/proto/googleapis/google/protobuf</outputDirectory>-->
+                        <!--</configuration>-->
+                    <!--</execution>-->
+                <!--</executions>-->
+            <!--</plugin>-->
+
+        </plugins>
+    </build>
+
+</project>