diff options
author | Tor Norbye <tnorbye@google.com> | 2012-08-06 07:37:25 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-08-06 08:25:13 -0700 |
commit | 726ce505cb26f4375591729d41ea1395280d244d (patch) | |
tree | e4da517dc797338a1cb27ed19aa7c1e3712cb7b2 /lint/libs/lint_api | |
parent | 384cf815c32a864267dae339e23108379d4ab957 (diff) | |
download | sdk-726ce505cb26f4375591729d41ea1395280d244d.zip sdk-726ce505cb26f4375591729d41ea1395280d244d.tar.gz sdk-726ce505cb26f4375591729d41ea1395280d244d.tar.bz2 |
Improve Maven defaults in lint
Change-Id: I3c7c13437403fb1392343af079afab9434695566
Diffstat (limited to 'lint/libs/lint_api')
-rw-r--r-- | lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java index ec0ab7f..f168d7a 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java @@ -423,31 +423,57 @@ public abstract class LintClient { } } - // Fallback, in case there is no Eclipse project metadata here - if (sources.size() == 0) { - File src = new File(projectDir, SRC_FOLDER); - if (src.exists()) { - sources.add(src); - } - File gen = new File(projectDir, GEN_FOLDER); - if (gen.exists()) { - sources.add(gen); - } - } if (classes.size() == 0) { File folder = new File(projectDir, CLASS_FOLDER); if (folder.exists()) { classes.add(folder); } else { - // Maven perhaps? + // Maven checks folder = new File(projectDir, "target" + File.separator + "classes"); //$NON-NLS-1$ //$NON-NLS-2$ if (folder.exists()) { classes.add(folder); + + // If it's maven, also correct the source path, "src" works but + // it's in a more specific subfolder + if (sources.size() == 0) { + File src = new File(projectDir, + "src" + File.separator //$NON-NLS-1$ + + "main" + File.separator //$NON-NLS-1$ + + "java"); //$NON-NLS-1$ + if (src.exists()) { + sources.add(src); + } else { + src = new File(projectDir, SRC_FOLDER); + if (src.exists()) { + sources.add(src); + } + } + + File gen = new File(projectDir, + "target" + File.separator //$NON-NLS-1$ + + "generated-sources" + File.separator //$NON-NLS-1$ + + "r"); //$NON-NLS-1$ + if (gen.exists()) { + sources.add(gen); + } + } } } } + // Fallback, in case there is no Eclipse project metadata here + if (sources.size() == 0) { + File src = new File(projectDir, SRC_FOLDER); + if (src.exists()) { + sources.add(src); + } + File gen = new File(projectDir, GEN_FOLDER); + if (gen.exists()) { + sources.add(gen); + } + } + info = new ClassPathInfo(sources, classes, libraries); mProjectInfo.put(project, info); } |