From ee4780f1de04e7c87b3fe172a4b1510bd4c7e9bf Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Mon, 6 Aug 2012 07:39:03 -0700 Subject: Allow lint cli --sources to specify a path, and use from ant lint First, this changeset allows the arguments passed to --sources and --classpath (renamed from --classes) to specify not just a directory, but to specify a path as well. This might make it easier to invoke lint from scripts if you have a path variable, so you don't have to split it into multiple arguments. Second, it makes the lint task in ant use these, such that any build.xml customizations to the source paths or class paths are automatically used rather than relying on lint's default structure check. Change-Id: Id8e4caf0010d7fd7245844b3099b5dc0607f0aba --- anttasks/src/com/android/ant/LintExecTask.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'anttasks') diff --git a/anttasks/src/com/android/ant/LintExecTask.java b/anttasks/src/com/android/ant/LintExecTask.java index 64a6c00..3d687cb 100644 --- a/anttasks/src/com/android/ant/LintExecTask.java +++ b/anttasks/src/com/android/ant/LintExecTask.java @@ -28,6 +28,8 @@ public class LintExecTask extends ExecTask { private String mExecutable; private String mHtml; private String mXml; + private Path mSourcePath; + private Path mClassPath; /** * Sets the value of the "executable" attribute. @@ -37,6 +39,16 @@ public class LintExecTask extends ExecTask { mExecutable = TaskHelper.checkSinglePath("executable", executable); } + /** Sets the path where Java source code should be found */ + public void setSrc(Path path) { + mSourcePath = path; + } + + /** Sets the path where class files should be found */ + public void setClasspath(Path path) { + mClassPath = path; + } + /** * Sets the value of the "html" attribute: a path to a file or directory name * where the HTML report should be written. @@ -80,6 +92,16 @@ public class LintExecTask extends ExecTask { task.createArg().setValue(mXml); } + if (mSourcePath != null) { + task.createArg().setValue("--sources"); + task.createArg().setValue(mSourcePath.toString()); + } + + if (mClassPath != null) { + task.createArg().setValue("--classpath"); + task.createArg().setValue(mClassPath.toString()); + } + task.createArg().setValue(getProject().getBaseDir().getAbsolutePath()); task.execute(); } -- cgit v1.1