public static Path resourceFile(String... pathParts) { return Fs.join(resourcesBaseDir(), pathParts); }
private static Path resourceFile(String... pathParts) { return Fs.join(resourcesBaseDir(), pathParts); }
private static Path resourceFile(String... pathParts) { return Fs.join(resourcesBaseDir(), pathParts); }
@Nonnull private ResourcePath createRuntimeSdkResourcePath(DependencyResolver dependencyResolver) { try { Fs systemResFs = Fs.fromJar(dependencyResolver.getLocalArtifactUrl(sdkConfig.getAndroidSdkDependency())); Class<?> androidRClass = getRobolectricClassLoader().loadClass("android.R"); Class<?> androidInternalRClass = getRobolectricClassLoader().loadClass("com.android.internal.R"); // TODO: verify these can be loaded via raw-res path return new ResourcePath(androidRClass, systemResFs.join("raw-res/res"), systemResFs.join("raw-res/assets"), androidInternalRClass); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
public static FsFile fileFromPath(String urlString) { if (urlString.startsWith("jar:")) { String[] parts = urlString.replaceFirst("jar:", "").split("!"); Fs fs = new JarFs(new File(parts[0])); return fs.join(parts[1].substring(1)); } else { return new FileFsFile(new File(urlString)); } }
/** * @deprecated Use {@link #fromURL(URL)} instead. */ @Deprecated public static FsFile fileFromPath(String urlString) { if (urlString.startsWith("jar:")) { String[] parts = urlString.replaceFirst("jar:", "").split("!", 0); Fs fs = new JarFs(new File(parts[0])); return fs.join(parts[1].substring(1)); } else { return new FileFsFile(new File(urlString)); } }
public static FsFile fromURL(URL url) { switch (url.getProtocol()) { case "file": return new FileFsFile(new File(url.getPath())); case "jar": String[] parts = url.getPath().split("!", 0); try { Fs fs = fromJar(new URL(parts[0])); return fs.join(parts[1].substring(1)); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } default: throw new IllegalArgumentException("unsupported fs type for '" + url + "'"); } }