Add Checkstyle to enforce codestyle rules

Rules are based on Sun style with a few minor modifications

Change-Id: If9e772105053c67550e4f206024fea26b65e611b
diff --git a/build.gradle b/build.gradle
index aed58db..88287a6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@
 }
 
 plugins {
-  id "org.sonarqube" version "1.2"
+  id 'org.sonarqube' version '1.2'
   id 'net.saliman.cobertura' version '2.3.0'
 }
 
@@ -15,6 +15,7 @@
 apply plugin: 'maven'
 apply plugin: 'signing'
 apply plugin: 'maven-publish'
+apply plugin: 'checkstyle'
 
 group = 'com.intel.jndn.management'
 version = '1.0.1-SNAPSHOT'
@@ -49,8 +50,9 @@
 }
 
 configurations {
-    integrationTestCompile.extendsFrom testCompile
-    integrationTestRuntime.extendsFrom testRuntime
+  checkstyleConfig
+  integrationTestCompile.extendsFrom testCompile
+  integrationTestRuntime.extendsFrom testRuntime
 }
 
 dependencies {
@@ -59,6 +61,8 @@
   testCompile 'junit:junit:4.12'
   testCompile 'com.intel.jndn.mock:jndn-mock:1.0.1'
   testRuntime 'org.slf4j:slf4j-api:1.7.16'
+
+  checkstyleConfig "com.puppycrawl.tools:checkstyle:6.15"
 }
 
 task javadocJar(type: Jar) {
@@ -87,6 +91,19 @@
   outputs.upToDateWhen { false }
 }
 
+tasks.withType(Checkstyle) {
+  checkstyleClasspath = project.configurations.checkstyleConfig
+  checkstyleMain {
+    exclude 'com/intel/jndn/management/enums/NfdTlv.java'
+  }
+  checkstyleTest {
+    configFile file('config/checkstyle/checkstyle-test.xml')
+  }
+  checkstyleIntegrationTest {
+    configFile file('config/checkstyle/checkstyle-test.xml')
+  }
+}
+
 if (JavaVersion.current().isJava8Compatible()) {
   allprojects {
     tasks.withType(Javadoc) {