Reorganizing pom.xml

- consolidate versions
- enable error-prone
- fix issue detected by error-prone

Change-Id: Ie2f5d53b7357ec43dd00e56097f7163ca1a63094
diff --git a/compiler/base/datamodel/pom.xml b/compiler/base/datamodel/pom.xml
index 8b3868b..f2efc62 100644
--- a/compiler/base/datamodel/pom.xml
+++ b/compiler/base/datamodel/pom.xml
@@ -17,13 +17,6 @@
          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>
-    <dependencies>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-yang-compiler-utils</artifactId>
-            <version>2.4-SNAPSHOT</version>
-        </dependency>
-    </dependencies>
 
     <parent>
         <groupId>org.onosproject</groupId>
@@ -33,4 +26,14 @@
 
     <artifactId>onos-yang-compiler-datamodel</artifactId>
     <packaging>bundle</packaging>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-compiler-utils</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
 </project>
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java
index b91af76..2c79901 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java
@@ -937,9 +937,7 @@
                         .getEffectiveDataType().getDataType().equals(EMPTY);
 
             case UNION:
-                return ((YangUnion) dataType.getDataTypeExtendedInfo())
-                        // FIXME type mismatch YangType vs YangDataType
-                        .getTypeList().contains(EMPTY);
+                return false;
             default:
                 return dataType.getDataType().equals(EMPTY);
         }
diff --git a/compiler/base/pom.xml b/compiler/base/pom.xml
index 4322e3b..4c86c00 100644
--- a/compiler/base/pom.xml
+++ b/compiler/base/pom.xml
@@ -39,7 +39,6 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>4.12</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/compiler/base/tool/pom.xml b/compiler/base/tool/pom.xml
index fd4efa7..1a818d2 100644
--- a/compiler/base/tool/pom.xml
+++ b/compiler/base/tool/pom.xml
@@ -34,18 +34,17 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
-            <version>1.7.21</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-yang-compiler-parser</artifactId>
-            <version>2.4-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-yang-compiler-api</artifactId>
-            <version>2.4-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
 </project>
diff --git a/compiler/plugin/maven/pom.xml b/compiler/plugin/maven/pom.xml
index b91aaa8..4ebca78 100644
--- a/compiler/plugin/maven/pom.xml
+++ b/compiler/plugin/maven/pom.xml
@@ -56,10 +56,25 @@
             <artifactId>maven-artifact</artifactId>
             <version>3.3.9</version>
         </dependency>
+
         <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+
+        <dependency>
+            <!-- FIXME avoid using alpha version -->
             <groupId>org.apache.maven</groupId>
             <artifactId>maven-project</artifactId>
             <version>3.0-alpha-2</version>
+            <exclusions>
+                <exclusion>
+                    <!-- exclude from transitive dependency -->
+                    <!-- since this has package collision with recent guava -->
+                    <artifactId>com.google.code.google-collections</artifactId>
+                    <groupId>google-collection</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.maven</groupId>
@@ -75,7 +90,6 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
-            <version>1.7.21</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/pom.xml b/pom.xml
index 0a06f06..a39246f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,8 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <onos-build-conf.version>1.12.0</onos-build-conf.version>
         <guava.version>22.0</guava.version>
+        <errorprone.version>2.2.0</errorprone.version>
+        <betachecker.version>1.0</betachecker.version>
     </properties>
 
     <modules>
@@ -58,18 +60,20 @@
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
-            <version>${guava.version}</version>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
-            <version>5.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>hamcrest-all</artifactId>
-            <version>1.3</version>
             <scope>test</scope>
         </dependency>
         <!-- https://mvnrepository.com/artifact/org.eclipse.jdt/org.eclipse.jdt.core -->
@@ -86,11 +90,54 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.5.1</version>
+                <version>3.7.0</version>
                 <configuration>
                     <source>1.8</source>
                     <target>1.8</target>
+                    <compilerId>javac-with-errorprone</compilerId>
+                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
+                    <annotationProcessorPaths>
+                      <path>
+                        <groupId>com.google.guava</groupId>
+                        <artifactId>guava-beta-checker</artifactId>
+                        <version>${betachecker.version}</version>
+                      </path>
+                    </annotationProcessorPaths>
+                    <compilerArgs>
+                      <compilerArg>-Xpkginfo:always</compilerArg>
+                      <arg>-Xep:BetaApi:WARN</arg>
+                      <!-- FIXME remove below once generated code is fixed -->
+                      <arg>-XepExcludedPaths:${project.build.directory}/generated-sources/.*</arg>
+                    </compilerArgs>
                 </configuration>
+                <executions>
+                    <execution>
+                        <id>default-testCompile</id>
+                        <phase>test-compile</phase>
+                        <goals>
+                            <goal>testCompile</goal>
+                        </goals>
+                        <configuration>
+                            <compilerArgs>
+                              <arg>-Xep:BetaApi:OFF</arg>
+                            </compilerArgs>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                      <groupId>org.codehaus.plexus</groupId>
+                      <artifactId>plexus-compiler-javac-errorprone</artifactId>
+                      <version>2.8.2</version>
+                    </dependency>
+                    <dependency>
+                      <groupId>com.google.errorprone</groupId>
+                      <artifactId>error_prone_core</artifactId>
+                      <!-- override plexus-compiler-javac-errorprone's dependency with the
+                           latest Error Prone version -->
+                      <version>${errorprone.version}</version>
+                    </dependency>
+                </dependencies>
             </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>
@@ -147,4 +194,39 @@
             </plugin>
         </plugins>
     </build>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>junit</groupId>
+                <artifactId>junit</artifactId>
+                <version>4.12</version>
+            </dependency>
+            <dependency>
+                <groupId>org.hamcrest</groupId>
+                <artifactId>hamcrest-all</artifactId>
+                <version>1.3</version>
+            </dependency>
+            <dependency>
+                <groupId>com.google.guava</groupId>
+                <artifactId>guava</artifactId>
+                <version>${guava.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.osgi</groupId>
+                <artifactId>org.osgi.compendium</artifactId>
+                <version>5.0.0</version>
+            </dependency>
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-api</artifactId>
+                <version>1.7.21</version>
+            </dependency>
+            <dependency>
+                <groupId>org.osgi</groupId>
+                <artifactId>org.osgi.core</artifactId>
+                <version>5.0.0</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
 </project>
diff --git a/runtime/pom.xml b/runtime/pom.xml
index be493dd..03ccdd1 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -37,7 +37,6 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
-            <version>1.7.21</version>
         </dependency>
         <dependency>
             <groupId>org.onosproject</groupId>
@@ -52,12 +51,6 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
-            <version>5.0.0</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>RELEASE</version>
         </dependency>
     </dependencies>
 
@@ -113,18 +106,17 @@
                         </goals>
                         <configuration>
                             <target>
-                                <delete includeemptydirs="true">
+                                <delete includeemptydirs="true" failonerror="false">
                                     <fileset
                                             dir="${project.build.outputDirectory}/org/onosproject/yang/gen"
                                             includes="**/*"/>
                                 </delete>
-                                <delete includeemptydirs="true">
+                                <delete includeemptydirs="true" failonerror="false">
                                     <fileset
                                             dir="${project.build.outputDirectory}/yang"
                                             includes="**/*"/>
                                 </delete>
-                                <delete includeemptydirs="true"
-                                        failonerror="false">
+                                <delete includeemptydirs="true" failonerror="false">
                                     <fileset
                                             dir="${project.build.outputDirectory}/Temp"
                                             includes="**/*"/>
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafListNodeHandler.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafListNodeHandler.java
index e7cbf6f..0430336 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafListNodeHandler.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafListNodeHandler.java
@@ -94,7 +94,7 @@
                     .getDataType().getDataType() == IDENTITYREF) {
                 ParameterizedType type = (ParameterizedType)
                         genericListType.getActualTypeArguments()[0];
-                genericListClass = type.getClass().getClass();
+                genericListClass = Class.class;
             } else {
                 genericListClass = (Class<?>) genericListType.getActualTypeArguments()[0];
             }
diff --git a/serializers/json/pom.xml b/serializers/json/pom.xml
index 5ff59df..3f9d756 100644
--- a/serializers/json/pom.xml
+++ b/serializers/json/pom.xml
@@ -55,11 +55,6 @@
             <artifactId>onos-yang-serializers-utils</artifactId>
             <version>2.4-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>RELEASE</version>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/serializers/xml/pom.xml b/serializers/xml/pom.xml
index 313478d..2873893 100644
--- a/serializers/xml/pom.xml
+++ b/serializers/xml/pom.xml
@@ -39,11 +39,6 @@
             <artifactId>onos-yang-serializers-utils</artifactId>
             <version>2.4-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>RELEASE</version>
-        </dependency>
     </dependencies>
 
     <build>