coverage.sh: Adapt to new source directories and plugins

Copy the source files to where they are expected.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I4b514a71b65515f8287d19472a16c367e8955306
diff --git a/tools/coverage.sh b/tools/coverage.sh
index 7c491fa..11e50e6 100755
--- a/tools/coverage.sh
+++ b/tools/coverage.sh
@@ -29,8 +29,20 @@
 # limitation by running genhtml in a directory with the files in the
 # right place. Also -inexplicably- genhtml wants to have the source
 # files relative to the output directory.
-mkdir -p ${destdir}/
-cp -a */src/{main,test}/java/* ${destdir}/
+mkdir -p ${destdir}/java
+cp -r {java,javatests}/* ${destdir}/java
+
+mkdir -p ${destdir}/plugins
+for plugin in `find plugins/ -type d` -maxdepth 1
+do
+  mkdir -p ${destdir}/${plugin}/java
+  cp -r plugins/*/{java,javatests}/* ${destdir}/${plugin}/java
+
+  # for backwards compatibility support plugins with old file structure
+  mkdir -p ${destdir}/${plugin}/src/{main,test}/java
+  cp -r plugins/*/src/main/java/* ${destdir}/${plugin}/src/main/java
+  cp -r plugins/*/src/test/java/* ${destdir}/${plugin}/src/test/java
+done
 
 base=$(bazel info bazel-testlogs)
 for f in $(find ${base}  -name 'coverage.dat') ; do