Some build updates for latest jacoco

Bug: 36792868
Test: m -j
Change-Id: I817d12994bc795be3faa33ad7e63675e3072a88e
diff --git a/Android.mk b/Android.mk
index b55fb27..1804e6d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -15,16 +15,6 @@
 #
 LOCAL_PATH := $(call my-dir)
 
-# Build jacoco from sources for the platform
-#
-# Note: this is only intended to be used for the platform development. This is *not* intended
-# to be used in the SDK where apps can use the official jacoco release.
-include $(CLEAR_VARS)
-
-jacoco_src_files := $(call all-java-files-under,org.jacoco.core/src)
-jacoco_src_files += $(call all-java-files-under,org.jacoco.agent/src)
-jacoco_src_files += $(call all-java-files-under,org.jacoco.agent.rt/src)
-
 # Some Jacoco source files depend on classes that do not exist in Android. While these classes are
 # not executed at runtime (because we use offline instrumentation), they will cause issues when
 # compiling them with ART during dex pre-opting. Therefore, it would prevent from applying code
@@ -36,7 +26,18 @@
   %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java \
   %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java
 
-LOCAL_SRC_FILES := $(filter-out $(jacoco_android_exclude_list),$(jacoco_src_files))
+
+# Build jacoco-agent from sources for the platform
+#
+# Note: this is only intended to be used for the platform development. This is *not* intended
+# to be used in the SDK where apps can use the official jacoco release.
+include $(CLEAR_VARS)
+
+jacocoagent_src_files := $(call all-java-files-under,org.jacoco.core/src)
+jacocoagent_src_files += $(call all-java-files-under,org.jacoco.agent/src)
+jacocoagent_src_files += $(call all-java-files-under,org.jacoco.agent.rt/src)
+
+LOCAL_SRC_FILES := $(filter-out $(jacoco_android_exclude_list),$(jacocoagent_src_files))
 
 # In order to include Jacoco in core libraries, we cannot depend on anything in the
 # bootclasspath (or we would create dependency cycle). Therefore we compile against
@@ -48,8 +49,28 @@
 LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
+
+# Build jacoco-cli from sources for the platform
+include $(CLEAR_VARS)
+
+# TODO(jeffrygaston) it'd be nice to keep the build process and/or list of source files in sync with
+# what is defined in the pom.xml files, although it's probably much more trouble than it's worth
+jacococli_src_files += $(call all-java-files-under,org.jacoco.core/src)
+jacococli_src_files += $(call all-java-files-under,org.jacoco.report/src)
+jacococli_src_files += $(call all-java-files-under,org.jacoco.cli/src)
+LOCAL_JAVA_RESOURCE_DIRS := org.jacoco.core/src org.jacoco.report/src
+LOCAL_JAR_MANIFEST := org.jacoco.cli/src/MANIFEST.MF
+
+LOCAL_SRC_FILES := $(jacococli_src_files)
+
+LOCAL_MODULE := jacoco-cli
+LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm-host args4j-2.0.28
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+
 #
-# Build asm-5.0.1 as a static library.
+# Build asm-5.0.1 as a static library for the device
 #
 include $(CLEAR_VARS)
 
@@ -62,3 +83,16 @@
 LOCAL_UNINSTALLABLE_MODULE := true
 
 include $(BUILD_PREBUILT)
+
+
+#
+# Build asm-5.0.1 as a static library for the host
+#
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := jacoco-asm-host
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_SRC_FILES := asm-debug-all-5.0.1$(COMMON_JAVA_PACKAGE_SUFFIX)
+
+include $(BUILD_PREBUILT)
diff --git a/README.android b/README.android
index 1e6118a..21adf4d 100644
--- a/README.android
+++ b/README.android
@@ -15,3 +15,4 @@
 1) Remove the creation of JmxRegistration in org.jacoco.agent.rt.internal.Agent.
 2) Change default OutputMode to none in org.jacoco.core.runtime.AgentOptions
 3) Merge https://github.com/jacoco/jacoco/pull/525
+4) Update the build process to match #3: evaluate jacoco.properties, and add MANIFEST.MF
diff --git a/org.jacoco.cli/src/MANIFEST.MF b/org.jacoco.cli/src/MANIFEST.MF
new file mode 100644
index 0000000..bae94d5
--- /dev/null
+++ b/org.jacoco.cli/src/MANIFEST.MF
@@ -0,0 +1,2 @@
+Main-Class: org.jacoco.cli.internal.Main

+

diff --git a/org.jacoco.core/src/org/jacoco/core/jacoco.properties b/org.jacoco.core/src/org/jacoco/core/jacoco.properties
index 0949337..e2f9aca 100644
--- a/org.jacoco.core/src/org/jacoco/core/jacoco.properties
+++ b/org.jacoco.core/src/org/jacoco/core/jacoco.properties
@@ -1,3 +1,6 @@
-VERSION=$qualified.bundle.version$
-HOMEURL=$jacoco.home.url$
-RUNTIMEPACKAGE=$jacoco.runtime.package.name$
\ No newline at end of file
+#This file is supposed to be processed by Maven, but Android doesn't run Maven
+#So in Android we've filled in the resulting values below
+VERSION=0.7.10.201704181138.android
+HOMEURL=http://www.jacoco.org/jacoco
+RUNTIMEPACKAGE=org.jacoco.agent.rt.internal
+