build: Switch to gradle build system

Change-Id: I0a11a49860a361684815dedd07e992d27d497523
diff --git a/.gitignore b/.gitignore
index 619d7e5..71af2c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,4 +31,46 @@
 .settings
 
 # Netbeans specific project files
-nbactions.xml
\ No newline at end of file
+nbactions.xml
+
+# generated files
+bin/
+gen/
+out/
+obj/
+build/
+app/src/*/libs/
+app/src/*/obj/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Eclipse project files
+.classpath
+.project
+
+# OSX files
+.DS_Store
+
+# Windows thumbnail db
+Thumbs.db
+
+# IDEA/Android Studio project files, because
+# the project can be imported from settings.gradle
+.idea
+*.iml
+gradle
+
+# Old-style IDEA project files
+*.ipr
+*.iws
+
+# Gradle cache
+.gradle
+gradle.properties
+
+# Sandbox stuff
+_sandbox
+
+# Emacs stuff
+prj.el
diff --git a/README-dev.md b/README-dev.md
new file mode 100644
index 0000000..fb45b39
--- /dev/null
+++ b/README-dev.md
@@ -0,0 +1,49 @@
+# Developer Notes
+
+## Prerequisites
+
+- [Gradle build system version 2.10 or later](http://gradle.org/)
+
+## Compile
+
+To compile:
+
+    gradle assemble
+
+To build documentation:
+
+    gradle javadoc
+
+To build all artifacts and publish to a local maven repository:
+
+    gradle install
+
+To publish to maven repository `signing.keyId`, `signing.password`, `signing.secretKeyRingFile`,
+`ossrhUsername`, and `ossrhPassword` variables need to be defined in project-specific or
+user-specific `gradle.properties` file.  After the variables defined, run the following command
+to build, sign, and upload archives to maven:
+
+    gradle uploadArchives
+
+To get list of other targets, use `gradle tasks`.
+
+## Tests
+
+The package contains two types of tests: unit and integration.  The integration tests require
+NFD instance to be running locally.
+
+### Unit Tests
+
+To run unit tests:
+
+    gradle test
+
+To run a specific test, use `-Dtest.single=<test-name>` command-line option. For example,
+
+    gradle -Dtest.single=ControlResponseTest test
+
+### Integration Tests
+
+To run integration tests
+
+    gradle integrationTest
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..4f16ee0
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,148 @@
+buildscript {
+  repositories {
+    jcenter()
+    mavenCentral()
+  }
+}
+
+apply plugin: 'java'
+apply plugin: 'maven'
+apply plugin: 'signing'
+
+group = 'net.named-data.jndn-extra'
+version = '1.0.1-SNAPSHOT'
+
+sourceCompatibility = JavaVersion.VERSION_1_7
+targetCompatibility = JavaVersion.VERSION_1_7
+compileJava.options.encoding = 'UTF-8'
+
+repositories {
+  jcenter()
+  mavenLocal()
+  mavenCentral()
+  maven {
+    url "https://oss.sonatype.org/content/repositories/snapshots/"
+  }
+}
+
+sourceSets {
+  integrationTest {
+    java {
+      compileClasspath += main.output + test.output
+      runtimeClasspath += main.output + test.output
+      srcDir file('src/integration-test/java')
+    }
+  }
+}
+
+configurations {
+    integrationTestCompile.extendsFrom testCompile
+    integrationTestRuntime.extendsFrom testRuntime
+}
+
+dependencies {
+  compile 'com.google.guava:guava:18.0'
+  compile 'net.named-data:jndn:0.7'
+
+  testCompile 'junit:junit:4.12'
+  testCompile 'com.intel.jndn.mock:jndn-mock:0.11.0'
+}
+
+task javadocJar(type: Jar) {
+  classifier = 'javadoc'
+  from javadoc
+}
+
+task sourcesJar(type: Jar) {
+  classifier = 'sources'
+  from sourceSets.main.allSource
+}
+
+task integrationTest(type: Test) {
+  description 'Compile and run integration tests'
+  testClassesDir = sourceSets.integrationTest.output.classesDir
+  classpath = sourceSets.integrationTest.runtimeClasspath
+}
+
+tasks.withType(Test) {
+  reports.html.destination = file("${reporting.baseDir}/${name}")
+  testLogging {
+    events "passed", "skipped", "failed"
+    showStandardStreams = true
+  }
+  outputs.upToDateWhen { false }
+}
+
+if (JavaVersion.current().isJava8Compatible()) {
+  allprojects {
+    tasks.withType(Javadoc) {
+      options.addStringOption('Xdoclint:none', '-quiet')
+    }
+  }
+}
+
+artifacts {
+  archives javadocJar, sourcesJar
+}
+
+signing {
+  required { gradle.taskGraph.hasTask("uploadArchives") }
+  sign configurations.archives
+}
+
+uploadArchives {
+  repositories {
+    mavenDeployer {
+      beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
+
+      repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
+        try {
+          authentication(userName: ossrhUsername, password: ossrhPassword)
+        }
+        catch (Exception e) {
+        }
+      }
+
+      snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
+        try {
+          authentication(userName: ossrhUsername, password: ossrhPassword)
+        }
+        catch (Exception e) {
+        }
+      }
+
+      pom.project {
+        name 'jndn-xx utilities'
+        packaging 'jar'
+        description 'Collection of tools to simplify synchronous and asynchronous data transfer over the NDN network'
+        url 'https://github.com/cawka/jndn-utils'
+
+        scm {
+          connection 'scm:git:https://github.com/cawka/jndn-utils'
+          developerConnection 'scm:git:https://github.com/cawka/jndn-utils'
+          url 'https://github.com/cawka/jndn-utils'
+        }
+
+        licenses {
+          license {
+            name 'GNU Lesser General Public License, Version 3.0+'
+            url 'http://www.gnu.org/licenses/lgpl.html'
+          }
+        }
+
+        developers {
+          developer {
+            id 'andrewbrown'
+            name 'Andrew Brown'
+            url 'https://github.com/andrewsbrown'
+          }
+          developer {
+            id 'cawka'
+            name 'Alexander Afanasyev'
+            email 'aa@cs.ucla.edu'
+          }
+        }
+      }
+    }
+  }
+}
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index ef45a8f..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,213 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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>com.intel.jndn.utils</groupId>
-	<artifactId>jndn-utils</artifactId>
-	<version>1.0.0</version>
-	<name>jndn-utils</name>
-	<description>Collection of tools to simplify synchronous and asynchronous data transfer over the NDN network</description>
-	<url>https://github.com/01org/jndn-utils</url>
-	<packaging>jar</packaging>
-	<licenses>
-		<license>
-			<name>LGPL v3</name>
-			<url>https://www.gnu.org/licenses/lgpl.html</url>
-		</license>
-	</licenses>
-	<developers>
-		<developer>
-			<name>Andrew Brown</name>
-			<url>http://github.com/andrewsbrown</url>
-		</developer>
-	</developers>
-	<distributionManagement>
-		<snapshotRepository>
-			<id>ossrh</id>
-			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
-		</snapshotRepository>
-	</distributionManagement>
-	<scm>
-		<url>https://github.com/01org/jndn-utils</url>
-		<connection>scm:git:git@github.com:01org/jndn-utils.git</connection>
-		<developerConnection>scm:git:git@github.com:01org/jndn-utils.git</developerConnection>
-	</scm>
-	<dependencies>
-		<dependency>
-			<groupId>net.named-data</groupId>
-			<artifactId>jndn</artifactId>
-			<version>0.7</version>
-		</dependency>
-		<!-- Test dependencies -->
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>4.10</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>com.intel.jndn.mock</groupId>
-			<artifactId>jndn-mock</artifactId>
-			<version>RELEASE</version>
-			<scope>test</scope>
-		</dependency>
-	</dependencies>
-	<properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<maven.compiler.source>1.7</maven.compiler.source>
-		<maven.compiler.target>1.7</maven.compiler.target>
-	</properties>
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.jacoco</groupId>
-				<artifactId>jacoco-maven-plugin</artifactId>
-				<version>0.7.4.201502262128</version>
-				<executions>
-					<execution>
-						<id>pre-unit-test</id>
-						<goals>
-							<goal>prepare-agent</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>post-unit-test</id>
-						<phase>test</phase>
-						<goals>
-							<goal>report</goal>
-						</goals>
-					</execution>
-				</executions>
-			</plugin>
-		</plugins>
-	</build>
-	<profiles>
-		
-		<!-- Use OSSRH-directed plugins (see http://central.sonatype.org/pages/apache-maven.html) 
-		for deployment to Maven central; e.g. `mvn deploy -P ossrh`-->
-		<profile>
-			<id>ossrh</id>
-			<build>
-				<plugins>
-					<plugin>
-						<groupId>org.apache.maven.plugins</groupId>
-						<artifactId>maven-source-plugin</artifactId>
-						<version>2.4</version>
-						<executions>
-							<execution>
-								<id>attach-sources</id>
-								<goals>
-									<goal>jar-no-fork</goal>
-								</goals>
-							</execution>
-						</executions>
-					</plugin>
-					<plugin>
-						<groupId>org.apache.maven.plugins</groupId>
-						<artifactId>maven-javadoc-plugin</artifactId>
-						<version>2.10.2</version>
-						<configuration>
-							<additionalparam>-Xdoclint:none</additionalparam>
-						</configuration>
-						<executions>
-							<execution>
-								<id>attach-javadocs</id>
-								<goals>
-									<goal>jar</goal>
-								</goals>
-							</execution>
-						</executions>
-					</plugin>
-					<plugin>
-						<groupId>org.sonatype.plugins</groupId>
-						<artifactId>nexus-staging-maven-plugin</artifactId>
-						<version>1.6.3</version>
-						<extensions>true</extensions>
-						<configuration>
-							<serverId>ossrh</serverId>
-							<stagingProfileId>a80137db01223a</stagingProfileId>
-							<nexusUrl>https://oss.sonatype.org/</nexusUrl>
-							<autoReleaseAfterClose>true</autoReleaseAfterClose>
-						</configuration>
-					</plugin>
-					<plugin>
-						<groupId>org.apache.maven.plugins</groupId>
-						<artifactId>maven-gpg-plugin</artifactId>
-						<version>1.5</version>
-						<executions>
-							<execution>
-								<id>sign-artifacts</id>
-								<phase>verify</phase>
-								<goals>
-									<goal>sign</goal>
-								</goals>
-							</execution>
-						</executions>
-					</plugin>
-				</plugins>
-			</build>
-		</profile>
-		
-		<!-- Use failsafe to run integration tests with an NFD instance; e.g.
-		`mvn verify -Pnfd-integration-tests -Dnfd.ip=10.0.0.1; these are not run by default
-		due to the external NFD dependency -->
-		<profile>
-			<id>nfd-integration-tests</id>
-			<build>
-				<plugins>
-					<plugin>
-						<groupId>org.apache.maven.plugins</groupId>
-						<artifactId>maven-failsafe-plugin</artifactId>
-						<version>2.18.1</version>
-						<executions>
-							<execution>
-								<id>runIntegrationTests</id>
-								<phase>integration-test</phase>
-								<goals>
-									<goal>integration-test</goal>
-								</goals>
-							</execution>
-							<execution>
-								<id>verifyIntegrationTests</id>
-								<phase>verify</phase>
-								<goals>
-									<goal>verify</goal>
-								</goals>
-							</execution>
-						</executions>
-					</plugin>
-				</plugins>
-			</build>	
-		</profile>
-
-		<!-- Run `mvn clean javadoc:javadoc scm-publish:publish-scm -P docs` to push
-		Javadoc to Github -->
-		<profile>
-			<id>docs</id>
-			<build>
-				<plugins>
-					<plugin>
-						<groupId>org.apache.maven.plugins</groupId>
-						<artifactId>maven-javadoc-plugin</artifactId>
-						<version>2.10.2</version>
-						<configuration>
-							<additionalparam>-Xdoclint:none</additionalparam>
-						</configuration>
-					</plugin>
-					<plugin>
-						<groupId>org.apache.maven.plugins</groupId>
-						<artifactId>maven-scm-publish-plugin</artifactId>
-						<version>1.1</version>
-						<configuration>
-							<checkoutDirectory>${project.build.directory}/scmpublish</checkoutDirectory>
-							<checkinComment>Publishing javadoc for ${project.artifactId}:${project.version}</checkinComment>
-							<content>${project.build.directory}/site/apidocs</content>
-							<skipDeletedFiles>true</skipDeletedFiles>
-							<pubScmUrl>scm:git:https://github.com/01org/jndn-utils.git</pubScmUrl>
-							<scmBranch>gh-pages</scmBranch>
-						</configuration>
-					</plugin>
-				</plugins>
-			</build>
-		</profile>
-	</profiles>
-</project>