Added androidJavadoc task to generate JavaDocs

Change-Id: I63ea84184f3d9f9f9b739e5a96bcd5724ec31e70
diff --git a/espresso/espresso-contrib-tests/build.gradle b/espresso/espresso-contrib-tests/build.gradle
index e41b8aa..9328119 100644
--- a/espresso/espresso-contrib-tests/build.gradle
+++ b/espresso/espresso-contrib-tests/build.gradle
@@ -52,3 +52,5 @@
 
     androidTestCompile project(':espresso-contrib')
 }
+
+apply from: "$rootDir/javadoc.gradle"
diff --git a/espresso/espresso-contrib/build.gradle b/espresso/espresso-contrib/build.gradle
index 5a4d4eb..24e8c03 100644
--- a/espresso/espresso-contrib/build.gradle
+++ b/espresso/espresso-contrib/build.gradle
@@ -41,3 +41,5 @@
     compile project(':espresso-lib')
     compile 'com.android.support:support-v4:19.1.+'
 }
+
+apply from: "$rootDir/javadoc.gradle"
\ No newline at end of file
diff --git a/espresso/espresso-lib-tests/build.gradle b/espresso/espresso-lib-tests/build.gradle
index 4b0b2e2..aaff806 100644
--- a/espresso/espresso-lib-tests/build.gradle
+++ b/espresso/espresso-lib-tests/build.gradle
@@ -56,3 +56,5 @@
     androidTestCompile 'org.mockito:mockito-core:1.9.5'
     androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
 }
+
+apply from: "$rootDir/javadoc.gradle"
diff --git a/espresso/espresso-lib/build.gradle b/espresso/espresso-lib/build.gradle
index b02908f..31b54be 100644
--- a/espresso/espresso-lib/build.gradle
+++ b/espresso/espresso-lib/build.gradle
@@ -109,4 +109,5 @@
     variant.packageLibrary.dependsOn "$jarJarTaskName"
 }
 
-apply from: '../publishLocal.gradle'
+apply from: "$rootDir/javadoc.gradle"
+apply from: "$rootDir/publishLocal.gradle"
diff --git a/espresso/espresso-sample/build.gradle b/espresso/espresso-sample/build.gradle
index 908bc25..b2ff8ec 100644
--- a/espresso/espresso-sample/build.gradle
+++ b/espresso/espresso-sample/build.gradle
@@ -45,3 +45,5 @@
     compile project(':idling-resource-interface')
     androidTestCompile project(':espresso-contrib')
 }
+
+apply from: "$rootDir/javadoc.gradle"
diff --git a/espresso/idling-resource-interface/build.gradle b/espresso/idling-resource-interface/build.gradle
index 24781e3..5952351 100644
--- a/espresso/idling-resource-interface/build.gradle
+++ b/espresso/idling-resource-interface/build.gradle
@@ -14,4 +14,13 @@
  * limitations under the License.
  */
 
-apply plugin: 'java'
\ No newline at end of file
+apply plugin: 'java'
+
+task androidJavadocs(type: Javadoc) {
+    source = sourceSets.main.allJava
+}
+
+task androidSourcesJar(type: Jar) {
+    classifier = 'sources'
+    from sourceSets.main.allSource
+}
diff --git a/espresso/javadoc.gradle b/espresso/javadoc.gradle
new file mode 100644
index 0000000..e947fb8
--- /dev/null
+++ b/espresso/javadoc.gradle
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * 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.
+ */
+
+task androidJavadocs(type: Javadoc) {
+    source = android.sourceSets.main.allJava
+}
+
+task androidSourcesJar(type: Jar) {
+    classifier = 'sources'
+    from android.sourceSets.main.allSource
+}