reader: Changed the vdl->code generation scripts.

Change-Id: I54ec5f616b3817c71dae5c7fc613c23fee6cd0f2
diff --git a/.gitignore b/.gitignore
index 052563c..f398c60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,5 +14,4 @@
 # VDL generated stubs should be ignored
 web/browser/vanadium/v.io/*
 web/browser/vanadium/vdl/*
-android/src/main/java/io/v/*
-android/src/main/java/vdl/*
+generated-src
diff --git a/Makefile b/Makefile
index 1afa3bc..64f75fa 100644
--- a/Makefile
+++ b/Makefile
@@ -5,9 +5,6 @@
 .DEFAULT_GOAL := all
 .SUFFIXES:
 
-VDLPATH = $(JIRI_ROOT)/release/go/src:$(shell pwd)
-vdl_files = $(wildcard vdl/*.vdl)
-
 .PHONY:
 clean:
 	$(MAKE) -C web clean
@@ -16,24 +13,8 @@
 test:
 	$(MAKE) -C web test
 
-.PHONY:
-vdl: web/browser/vanadium/vdl/index.js
-	@true  # silence "make: Nothing to be done for `vdl'."
+.PHONY: vdl
+vdl:
+	$(MAKE) -C web vdl
+	gradle -p android vdl
 
-# TODO(jasoncampbell): Move this to web/Makefile so it can be used as a
-# dependency in tests etc.
-web/browser/vanadium/vdl/index.js: $(vdl_files)
-	VDLPATH=$(VDLPATH) vdl generate --lang javascript \
-		-js-out-dir ./web/browser/vanadium \
-		vdl
-
-# The vdl command will general mutliple Java files in the --java-out-dir + /vdl
-# directory. In order tie the $(vdl_files) dependencies to the building of the
-# Java files the mtime on the android/src/main/java/vdl is used. Note the @touch
-# at the end of this definition, this makes it so that the task only runs if the
-# dependencies have updated since the last run.
-android/src/main/java/vdl: $(vdl_files)
-	VDLPATH=$(VDLPATH) vdl generate --lang java \
-		--java-out-dir android/src/main/java \
-		vdl
-	@touch android/src/main/java/vdl
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 9750c0d..d387a0b 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -23,6 +23,9 @@
 // It's an Android application.
 apply plugin: 'com.android.application'
 
+// It's going to use VDL.
+apply plugin: 'io.v.vdl'
+
 repositories {
     mavenCentral()
     maven {
@@ -62,3 +65,9 @@
     compile 'io.v:vanadium:0.1-SNAPSHOT'
     compile 'io.v:vanadium-android:0.1-SNAPSHOT'
 }
+
+vdl {
+    inputPaths += System.getenv("JIRI_ROOT") + '/release/go/src'
+    inputPaths += '../..'
+    packageTranslations += 'vdl->io.v.android.apps.reader'
+}
diff --git a/web/Makefile b/web/Makefile
index 381f0ab..30eb4f0 100644
--- a/web/Makefile
+++ b/web/Makefile
@@ -3,6 +3,7 @@
 NODE_DIR := $(shell jiri v23-profile env --profile=nodejs V23_TARGET_INSTALLATION_DIR=)
 PATH := $(PATH):$(NODE_DIR)/bin
 SHELL := /bin/bash
+VDLPATH := $(JIRI_ROOT)/release/go/src:$(shell cd ..; pwd)
 
 .SHELLFLAGS := -eu -o pipefail -c
 .DEFAULT_GOAL := all
@@ -10,6 +11,7 @@
 
 js_files := $(shell find browser -name "*.js")
 css_files := $(shell find browser -name "*.css")
+vdl_files := $(wildcard ../vdl/*.vdl)
 
 host ?= 127.0.0.1
 port ?= 8080
@@ -53,6 +55,8 @@
 	@$(RM) -fr credentials
 	@$(RM) -f bin/principal
 	@$(RM) -f bin/syncbased
+	@$(RM) -fr browser/vanadium/v.io
+	@$(RM) -fr browser/vanadium/vdl
 
 .PHONY:
 lint: node_modules
@@ -120,3 +124,13 @@
 		--v23.tcp.address=":$(cloudsync_port)" \
 		--v23.credentials="credentials" \
 		--v23.permissions.literal='{"Admin":{"In":["..."]},"Write":{"In":["..."]},"Read":{"In":["..."]},"Resolve":{"In":["..."]},"Debug":{"In":["..."]}}'
+
+.PHONY:
+vdl: browser/vanadium/vdl/index.js
+	@true  # silence "make: Nothing to be done for `vdl'."
+
+browser/vanadium/vdl/index.js: $(vdl_files)
+	VDLPATH=$(VDLPATH) vdl generate --lang javascript \
+		-js-out-dir ./browser/vanadium \
+		vdl
+