diff options
author | Tor Norbye <tnorbye@google.com> | 2012-08-06 07:39:03 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-08-06 08:32:05 -0700 |
commit | ee4780f1de04e7c87b3fe172a4b1510bd4c7e9bf (patch) | |
tree | a05c31329f5a92bc0e8b2c0225aafa8265cd45ce /eclipse | |
parent | 726ce505cb26f4375591729d41ea1395280d244d (diff) | |
download | sdk-ee4780f1de04e7c87b3fe172a4b1510bd4c7e9bf.tar.gz |
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
Diffstat (limited to 'eclipse')
3 files changed, 2 insertions, 67 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java index b34e7ed41..d6ca12a10 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java @@ -30,8 +30,6 @@ import com.android.sdklib.AndroidVersion; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.repository.PkgProps; import com.android.util.XmlUtils; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; import com.google.common.io.ByteStreams; import com.google.common.io.Closeables; @@ -981,41 +979,6 @@ public class AdtUtils { } /** - * Splits the given path into its individual parts, attempting to be - * tolerant about path separators (: or ;). It can handle possibly ambiguous - * paths, such as {@code c:\foo\bar:\other}, though of course these are to - * be avoided if possible. - * - * @param path the path variable to split, which can use both : and ; as - * path separators. - * @return the individual path components as an iterable of strings - */ - public static Iterable<String> splitPath(String path) { - if (path.indexOf(';') != -1) { - return Splitter.on(';').omitEmptyStrings().trimResults().split(path); - } - - List<String> combined = new ArrayList<String>(); - Iterables.addAll(combined, Splitter.on(':').omitEmptyStrings().trimResults().split(path)); - for (int i = 0, n = combined.size(); i < n; i++) { - String p = combined.get(i); - if (p.length() == 1 && i < n - 1 && Character.isLetter(p.charAt(0)) - // Technically, Windows paths do not have to have a \ after the :, - // which means it would be using the current directory on that drive, - // but that's unlikely to be the case in a path since it would have - // unpredictable results - && !combined.get(i+1).isEmpty() && combined.get(i+1).charAt(0) == '\\') { - combined.set(i, p + ':' + combined.get(i+1)); - combined.remove(i+1); - n--; - continue; - } - } - - return combined; - } - - /** * Reads the contents of an {@link IFile} and return it as a byte array * * @param file the file to be read diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java index 467602fd5..022857e1a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java @@ -20,7 +20,6 @@ import static com.android.sdklib.internal.project.ProjectProperties.PROPERTY_SDK import com.android.ide.eclipse.adt.AdtConstants; import com.android.ide.eclipse.adt.AdtPlugin; -import com.android.ide.eclipse.adt.AdtUtils; import com.android.ide.eclipse.adt.AndroidPrintStream; import com.android.ide.eclipse.adt.internal.build.BuildHelper; import com.android.ide.eclipse.adt.internal.build.DexException; @@ -36,6 +35,7 @@ import com.android.sdklib.build.ApkCreationException; import com.android.sdklib.build.DuplicateFileException; import com.android.sdklib.internal.project.ProjectProperties; import com.android.sdklib.xml.AndroidManifest; +import com.android.tools.lint.detector.api.LintUtils; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -177,7 +177,7 @@ public final class ExportHelper { proguardConfig = proguardConfig.replace('/', File.separatorChar); } - Iterable<String> paths = AdtUtils.splitPath(proguardConfig); + Iterable<String> paths = LintUtils.splitPath(proguardConfig); for (String path : paths) { if (path.startsWith(SDK_PROPERTY_REF)) { path = AdtPrefs.getPrefs().getOsSdkFolder() + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java index b2b6787ec..e0ebdbc6b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java @@ -15,9 +15,6 @@ */ package com.android.ide.eclipse.adt; -import com.google.common.collect.Iterables; - -import java.util.Arrays; import java.util.Locale; import junit.framework.TestCase; @@ -148,31 +145,6 @@ public class AdtUtilsTest extends TestCase { assertEquals("Foo", AdtUtils.stripSuffix("Foo", "Bar")); } - public void testSplitPath() throws Exception { - assertTrue(Arrays.equals(new String[] { "/foo", "/bar", "/baz" }, - Iterables.toArray(AdtUtils.splitPath("/foo:/bar:/baz"), String.class))); - - assertTrue(Arrays.equals(new String[] { "/foo", "/bar" }, - Iterables.toArray(AdtUtils.splitPath("/foo;/bar"), String.class))); - - assertTrue(Arrays.equals(new String[] { "/foo", "/bar:baz" }, - Iterables.toArray(AdtUtils.splitPath("/foo;/bar:baz"), String.class))); - - assertTrue(Arrays.equals(new String[] { "\\foo\\bar", "\\bar\\foo" }, - Iterables.toArray(AdtUtils.splitPath("\\foo\\bar;\\bar\\foo"), String.class))); - - assertTrue(Arrays.equals(new String[] { "${sdk.dir}\\foo\\bar", "\\bar\\foo" }, - Iterables.toArray(AdtUtils.splitPath("${sdk.dir}\\foo\\bar;\\bar\\foo"), - String.class))); - - assertTrue(Arrays.equals(new String[] { "${sdk.dir}/foo/bar", "/bar/foo" }, - Iterables.toArray(AdtUtils.splitPath("${sdk.dir}/foo/bar:/bar/foo"), - String.class))); - - assertTrue(Arrays.equals(new String[] { "C:\\foo", "/bar" }, - Iterables.toArray(AdtUtils.splitPath("C:\\foo:/bar"), String.class))); - } - public void testFormatFloatValue() throws Exception { assertEquals("1", AdtUtils.formatFloatAttribute(1.0f)); assertEquals("2", AdtUtils.formatFloatAttribute(2.0f)); |