Revision: 285
Author:
e...@google.com
Date: Mon Dec 3 16:21:40 2012
Log: Automatically add libcore resource directories to the runtime
classpath.
Note that I added a new flavor of classpath. You might think I could have
just reused the existing --classpath, but that's supplied at compile time
as well as run time, and there might be all kinds of confusing files in
the resource tree that shouldn't be shown to the compiler. (This is
certainly
the case with libcore. You can't build with the resource directories on the
compile time classpath.)
http://code.google.com/p/vogar/source/detail?r=285
Modified:
/trunk/src/vogar/Run.java
/trunk/src/vogar/Vogar.java
/trunk/src/vogar/android/AndroidSdk.java
/trunk/src/vogar/tasks/RunActionTask.java
=======================================
--- /trunk/src/vogar/Run.java Tue Dec 20 12:57:24 2011
+++ /trunk/src/vogar/Run.java Mon Dec 3 16:21:40 2012
@@ -56,6 +56,7 @@
public final Log log;
public final Classpath classpath;
public final Classpath buildClasspath;
+ public final Classpath resourceClasspath;
public final List<File> sourcepath;
public final Mkdir mkdir;
public final Rm rm;
@@ -137,6 +138,7 @@
this.timeoutSeconds = vogar.timeoutSeconds;
this.smallTimeoutSeconds = vogar.timeoutSeconds;
this.sourcepath = vogar.sourcepath;
+ this.resourceClasspath = Classpath.of(vogar.resourceClasspath);
this.useBootClasspath = vogar.useBootClasspath;
this.targetArgs = vogar.targetArgs;
this.xmlReportsDirectory = vogar.xmlReportsDirectory;
=======================================
--- /trunk/src/vogar/Vogar.java Wed Apr 18 16:03:58 2012
+++ /trunk/src/vogar/Vogar.java Mon Dec 3 16:21:40 2012
@@ -121,6 +121,12 @@
@Option(names = { "--classpath", "-cp" })
List<File> classpath = new ArrayList<File>();
+
+ @Option(names = { "--resource-classpath" })
+ List<File> resourceClasspath = new ArrayList<File>();
+ {
+ resourceClasspath.addAll(AndroidSdk.defaultResourceClassPath());
+ }
@Option(names = { "--sourcepath" })
List<File> sourcepath = new ArrayList<File>();
=======================================
--- /trunk/src/vogar/android/AndroidSdk.java Mon Dec 3 12:06:44 2012
+++ /trunk/src/vogar/android/AndroidSdk.java Mon Dec 3 16:21:40 2012
@@ -150,17 +150,28 @@
}
public static Collection<File> defaultSourcePath() {
+ return filterNonExistentPathsFrom("libcore/support/src/test/java",
+ "external/mockwebserver/src/main/java/");
+ }
+
+ public static Collection<File> defaultResourceClassPath() {
+ return filterNonExistentPathsFrom("libcore/dom/src/test/resources",
+ "libcore/support/src/test/java/tests/resources",
+ "libcore/luni/src/test/etc/loading-test-jar/resources",
+ "libcore/luni/src/test/etc/loading-test2-jar/resources",
+ "libcore/luni/src/test/resources");
+ }
+
+ private static Collection<File> filterNonExistentPathsFrom(String...
paths) {
+ ArrayList<File> result = new ArrayList<File>();
String buildRoot = System.getenv("ANDROID_BUILD_TOP");
- File supportSrc = new
File(buildRoot, "libcore/support/src/test/java");
- File mockWebServerSrc = new
File(buildRoot, "external/mockwebserver/src/main/java/");
- ArrayList<File> sourcePath = new ArrayList<File>();
- if (supportSrc.exists()) {
- sourcePath.add(supportSrc);
- }
- if (mockWebServerSrc.exists()) {
- sourcePath.add(mockWebServerSrc);
+ for (String path : paths) {
+ File file = new File(buildRoot, path);
+ if (file.exists()) {
+ result.add(file);
+ }
}
- return sourcePath;
+ return result;
}
public File[] getAndroidClasses() {
=======================================
--- /trunk/src/vogar/tasks/RunActionTask.java Tue Dec 20 12:57:24 2011
+++ /trunk/src/vogar/tasks/RunActionTask.java Mon Dec 3 16:21:40 2012
@@ -143,6 +143,8 @@
} else {
vmCommandBuilder.classpath(run.mode.getRuntimeClasspath(action));
}
+
+ vmCommandBuilder.classpath(run.resourceClasspath);
if (monitorPort != -1) {
vmCommandBuilder.args("--monitorPort",
Integer.toString(monitorPort));