Java Code Examples for com.android.utils.SdkUtils#urlToFile()

The following examples show how to use com.android.utils.SdkUtils#urlToFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LintDetectorTest.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the Android source tree root dir.
 * @return the root dir or null if it couldn't be computed.
 */
protected File getRootDir() {
    CodeSource source = getClass().getProtectionDomain().getCodeSource();
    if (source != null) {
        URL location = source.getLocation();
        try {
            File dir = SdkUtils.urlToFile(location);
            assertTrue(dir.getPath(), dir.exists());
            while (dir != null) {
                File settingsGradle = new File(dir, "settings.gradle"); //$NON-NLS-1$
                if (settingsGradle.exists()) {
                    return dir.getParentFile().getParentFile();
                }
                File lint = new File(dir, "lint");  //$NON-NLS-1$
                if (lint.exists() && new File(lint, "cli").exists()) { //$NON-NLS-1$
                    return dir.getParentFile().getParentFile();
                }
                dir = dir.getParentFile();
            }

            return null;
        } catch (MalformedURLException e) {
            fail(e.getLocalizedMessage());
        }
    }

    return null;
}
 
Example 2
Source File: MTLintDetectorTest.java    From MeituanLintDemo with Apache License 2.0 5 votes vote down vote up
private File getTestDataRootDir() {
    CodeSource source = getClass().getProtectionDomain().getCodeSource();
    if (source != null) {
        URL location = source.getLocation();
        try {
            File classesDir = SdkUtils.urlToFile(location);
            return classesDir.getParentFile().getAbsoluteFile().getParentFile().getParentFile();
        } catch (MalformedURLException e) {
            fail(e.getLocalizedMessage());
        }
    }
    return null;
}
 
Example 3
Source File: AbstractDetectorTest.java    From Android-Lint-Checks with Apache License 2.0 5 votes vote down vote up
private File getTestDataRootDir() {
    CodeSource source = getClass().getProtectionDomain().getCodeSource();
    if (source != null) {
        URL location = source.getLocation();
        try {
            File classesDir = SdkUtils.urlToFile(location);
            return classesDir.getParentFile().getAbsoluteFile().getParentFile().getParentFile();
        } catch (MalformedURLException e) {
            fail(e.getLocalizedMessage());
        }
    }
    return null;
}
 
Example 4
Source File: AbstractDetectorTest.java    From Android-Lint-Checks with Apache License 2.0 5 votes vote down vote up
private File getTestDataRootDir() {
    CodeSource source = getClass().getProtectionDomain().getCodeSource();
    if (source != null) {
        URL location = source.getLocation();
        try {
            File classesDir = SdkUtils.urlToFile(location);
            return classesDir.getParentFile().getAbsoluteFile().getParentFile().getParentFile();
        } catch (MalformedURLException e) {
            fail(e.getLocalizedMessage());
        }
    }
    return null;
}
 
Example 5
Source File: AbstractDetectorTest.java    From linette with Apache License 2.0 5 votes vote down vote up
private File getTestDataRootDir() {
    CodeSource source = getClass().getProtectionDomain().getCodeSource();
    if (source != null) {
        URL location = source.getLocation();
        try {
            File classesDir = SdkUtils.urlToFile(location);
            return classesDir.getParentFile().getAbsoluteFile().getParentFile().getParentFile();
        } catch (MalformedURLException e) {
            fail(e.getLocalizedMessage());
        }
    }
    return null;
}