aboutsummaryrefslogtreecommitdiffstats
path: root/lint/cli
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-09-11 10:42:26 -0700
committerTor Norbye <tnorbye@google.com>2012-09-11 12:51:05 -0700
commit99e8e3dcaaee4621ec0eabd3ac32a243c919c424 (patch)
tree8663866a0053ebe503323755a238c847c8c59403 /lint/cli
parentb1fe0b62289fd3ed2fb51eace4325773fa7dd144 (diff)
downloadsdk-99e8e3dcaaee4621ec0eabd3ac32a243c919c424.zip
sdk-99e8e3dcaaee4621ec0eabd3ac32a243c919c424.tar.gz
sdk-99e8e3dcaaee4621ec0eabd3ac32a243c919c424.tar.bz2
Add lint flag for setting a custom library path
Change-Id: Ie36bcb31be87a7cd16ab1b958c0264ca8b51e385
Diffstat (limited to 'lint/cli')
-rw-r--r--lint/cli/src/com/android/tools/lint/Main.java39
1 files changed, 34 insertions, 5 deletions
diff --git a/lint/cli/src/com/android/tools/lint/Main.java b/lint/cli/src/com/android/tools/lint/Main.java
index e83601f..541ad4e 100644
--- a/lint/cli/src/com/android/tools/lint/Main.java
+++ b/lint/cli/src/com/android/tools/lint/Main.java
@@ -88,6 +88,7 @@ public class Main extends LintClient {
private static final String ARG_EXITCODE = "--exitcode"; //$NON-NLS-1$
private static final String ARG_CLASSES = "--classpath"; //$NON-NLS-1$
private static final String ARG_SOURCES = "--sources"; //$NON-NLS-1$
+ private static final String ARG_LIBRARIES = "--libraries"; //$NON-NLS-1$
private static final String ARG_NOWARN2 = "--nowarn"; //$NON-NLS-1$
// GCC style flag names for options
@@ -123,6 +124,7 @@ public class Main extends LintClient {
protected boolean mAllErrors;
protected List<File> mSources;
protected List<File> mClasses;
+ protected List<File> mLibraries;
protected Configuration mDefaultConfiguration;
protected IssueRegistry mRegistry;
@@ -495,6 +497,23 @@ public class Main extends LintClient {
}
mSources.add(input);
}
+ } else if (arg.equals(ARG_LIBRARIES)) {
+ if (index == args.length - 1) {
+ System.err.println("Missing library folder name");
+ System.exit(ERRNO_INVALIDARGS);
+ }
+ String paths = args[++index];
+ for (String path : LintUtils.splitPath(paths)) {
+ File input = getInArgumentPath(path);
+ if (!input.exists()) {
+ System.err.println("Library " + input + " does not exist.");
+ System.exit(ERRNO_INVALIDARGS);
+ }
+ if (mLibraries == null) {
+ mLibraries = new ArrayList<File>();
+ }
+ mLibraries.add(input);
+ }
} else if (arg.startsWith("--")) {
System.err.println("Invalid argument " + arg + "\n");
printUsage(System.err);
@@ -514,9 +533,10 @@ public class Main extends LintClient {
if (files.size() == 0) {
System.err.println("No files to analyze.");
System.exit(ERRNO_INVALIDARGS);
- } else if (files.size() > 1 && (mClasses != null || mSources != null)) {
- System.err.println("The " + ARG_SOURCES + " and " + ARG_CLASSES
- + " can only be used with a single project");
+ } else if (files.size() > 1
+ && (mClasses != null || mSources != null || mLibraries != null)) {
+ System.err.println("The " + ARG_SOURCES + ", " + ARG_CLASSES + " and "
+ + ARG_LIBRARIES + " arguments can only be used with a single project");
System.exit(ERRNO_INVALIDARGS);
}
@@ -953,6 +973,8 @@ public class Main extends LintClient {
"the project. Only valid when running lint on a single project.",
ARG_CLASSES + " <dir>", "Add the given folder (or jar file, or path) as a class " +
"directory for the project. Only valid when running lint on a single project.",
+ ARG_LIBRARIES + " <dir>", "Add the given folder (or jar file, or path) as a class " +
+ "library for the project. Only valid when running lint on a single project.",
"", "\nExit Status:",
"0", "Success.",
@@ -1185,7 +1207,7 @@ public class Main extends LintClient {
protected ClassPathInfo getClassPath(@NonNull Project project) {
ClassPathInfo classPath = super.getClassPath(project);
- if (mClasses == null && mSources == null) {
+ if (mClasses == null && mSources == null && mLibraries == null) {
return classPath;
}
@@ -1210,7 +1232,14 @@ public class Main extends LintClient {
} else {
classes = classPath.getClassFolders();
}
- info = new ClassPathInfo(sources, classes, classPath.getLibraries());
+ List<File> libraries;
+ if (mLibraries != null) {
+ libraries = mLibraries;
+ } else {
+ libraries = classPath.getLibraries();
+ }
+
+ info = new ClassPathInfo(sources, classes, libraries);
mProjectInfo.put(project, info);
}