Adding publish to gradle

Change-Id: Iaf14fb99001ce99fa788da3f69af3fa2a4ef62e2
diff --git a/bakutoolkit/build.gradle b/bakutoolkit/build.gradle
index 492104f..c686764 100644
--- a/bakutoolkit/build.gradle
+++ b/bakutoolkit/build.gradle
@@ -1,4 +1,10 @@
+// You should change this after releasing a new version of the Baku Toolkit. See the
+// list of published versions at https://repo1.maven.org/maven2/io/v/baku-toolkit.
+def releaseVersion = '0.1'
+
 apply plugin: 'com.android.library'
+apply plugin: 'com.jfrog.bintray'
+apply plugin: 'maven-publish'
 /*
 You might have to download JDK8 and set JAVA8_HOME (or set the jdk to Java 8 via Project Structure).
 For detailed instructions, see https://github.com/evant/gradle-retrolambda
@@ -49,7 +55,6 @@
     }
 
     compile(
-            //'com.android.support:appcompat-v7:23.1.0',
             'com.jakewharton.rxbinding:rxbinding:0.3.0',
             'io.reactivex:rxandroid:1.0.1',
             'io.reactivex:rxjava:1.0.16',
@@ -68,3 +73,43 @@
     apk ('org.slf4j:slf4j-android:1.7.12')
     */
 }
+
+task sourceJar(type: Jar) {
+    from android.sourceSets.main.java.srcDirs
+    classifier "source"
+}
+
+publishing {
+    publications {
+        androidLibrary(MavenPublication) {
+            groupId 'io.v'
+            artifactId 'baku-toolkit'
+            version releaseVersion
+            artifact sourceJar
+            artifact "$buildDir/outputs/aar/bakutoolkit-release.aar"
+        }
+    }
+}
+
+tasks.bintrayUpload.dependsOn(tasks.assemble)
+
+bintray {
+    user = project.properties.bintrayUsername
+    key = project.properties.bintrayApiKey
+    pkg {
+        desc = 'Java libraries for writing Vanadium Android applications with Baku'
+        websiteUrl = 'https://github.com/vanadium/java'
+        vcsUrl = 'https://github.com/vanadium/java.git'
+        repo = 'io.v'
+        name = 'baku-toolkit'
+        licenses = ['BSD New']
+        version {
+            name = releaseVersion
+            gpg {
+                sign = true
+            }
+        }
+        userOrg = 'vanadium'
+    }
+    publications = ['androidLibrary']
+}
diff --git a/build.gradle b/build.gradle
index 7975321..11d0a56 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,6 +7,7 @@
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:1.3.0'
+        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
         classpath 'me.tatarka:gradle-retrolambda:3.2.3'
 
         // NOTE: Do not place your application dependencies here; they belong
diff --git a/gradle.properties b/gradle.properties
index 1d3591c..89e0d99 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -15,4 +15,4 @@
 # When configured, Gradle will run in incubating parallel mode.
 # This option should only be used with decoupled projects. More details, visit
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# org.gradle.parallel=true