aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs/lint_api
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-01-03 16:53:56 -0800
committerTor Norbye <tnorbye@google.com>2013-01-04 10:22:48 -0800
commit6050e51438c29d5f5f6413dd842fa2d019d954db (patch)
treea5df515ba1831f3466e16c7e661914f6f4169b2d /lint/libs/lint_api
parentcf7f3984edfb23ce6bb85ebd101c165c7c0cafa6 (diff)
downloadsdk-6050e51438c29d5f5f6413dd842fa2d019d954db.zip
sdk-6050e51438c29d5f5f6413dd842fa2d019d954db.tar.gz
sdk-6050e51438c29d5f5f6413dd842fa2d019d954db.tar.bz2
Make resource folders customizeable
Until now, lint has hardcoded where the project resources are to be found: in $project/res. With the new build system this will no longer necessarily be the case; there can be multiple resource folders, and the locations might not be just res/. Therefore, this CL generalizes lint's handling of resource folders: it is now provided by the LintClient, and the command line lint tool uses this to offer a new --resources flag which can be used to set the resource directory/directories for a project. Change-Id: I3717c6474141776ee5541d476f9bad5bb8e1a9c7
Diffstat (limited to 'lint/libs/lint_api')
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java14
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java14
-rw-r--r--lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java14
3 files changed, 22 insertions, 20 deletions
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java
index 9afef42..6c4b202 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintClient.java
@@ -52,6 +52,7 @@ import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -236,20 +237,19 @@ public abstract class LintClient {
}
/**
- * Returns the resource folder.
+ * Returns the resource folders.
*
* @param project the project to look up the resource folder for
- * @return a file pointing to the resource folder, or null if the project
- * does not contain any resources
+ * @return a list of files pointing to the resource folders, possibly empty
*/
- @Nullable
- public File getResourceFolder(@NonNull Project project) {
+ @NonNull
+ public List<File> getResourceFolders(@NonNull Project project) {
File res = new File(project.getDir(), RES_FOLDER);
if (res.exists()) {
- return res;
+ return Collections.singletonList(res);
}
- return null;
+ return Collections.emptyList();
}
/**
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java
index dd268a5..28168a6 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/client/api/LintDriver.java
@@ -841,9 +841,11 @@ public class LintDriver {
if (files != null) {
checkIndividualResources(project, main, xmlDetectors, files);
} else {
- File res = project.getResourceFolder();
- if (res != null && !xmlDetectors.isEmpty()) {
- checkResFolder(project, main, res, xmlDetectors);
+ List<File> resourceFolders = project.getResourceFolders();
+ if (!resourceFolders.isEmpty() && !xmlDetectors.isEmpty()) {
+ for (File res : resourceFolders) {
+ checkResFolder(project, main, res, xmlDetectors);
+ }
}
}
}
@@ -1686,9 +1688,9 @@ public class LintDriver {
}
@Override
- @Nullable
- public File getResourceFolder(@NonNull Project project) {
- return mDelegate.getResourceFolder(project);
+ @NonNull
+ public List<File> getResourceFolders(@NonNull Project project) {
+ return mDelegate.getResourceFolders(project);
}
@Override
diff --git a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java
index df27b2f..67c3b16 100644
--- a/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java
+++ b/lint/libs/lint_api/src/main/java/com/android/tools/lint/detector/api/Project.java
@@ -353,20 +353,20 @@ public class Project {
* @return a file pointing to the resource folder, or null if the project
* does not contain any resources
*/
- @Nullable
- public File getResourceFolder() {
- File folder = mClient.getResourceFolder(this);
+ @NonNull
+ public List<File> getResourceFolders() {
+ List<File> folders = mClient.getResourceFolders(this);
- if (folder != null && isAospFrameworksProject(mDir)) {
+ if (folders.size() == 1 && isAospFrameworksProject(mDir)) {
// No manifest file for this project: just init the manifest values here
mMinSdk = mTargetSdk = SdkConstants.HIGHEST_KNOWN_API;
- folder = new File(folder, RES_FOLDER);
+ File folder = new File(folders.get(0), RES_FOLDER);
if (!folder.exists()) {
- folder = null;
+ folders = Collections.emptyList();
}
}
- return folder;
+ return folders;
}
/**