public static ResName qualifyFromFilePath(@NotNull final String packageName, @NotNull final String filePath) { final FileFsFile filePathFile = new FileFsFile(new File(filePath)); final String type = filePathFile.getParent().getName().split("-")[0]; final String name = filePathFile.getBaseName(); return new ResName(packageName, type, name); }
@Override public FsFile[] listFiles(final Filter filter) { return asFsFiles(file.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return filter.accept(new FileFsFile(pathname)); } })); }
@Override public void call(File file) { if (file.isDirectory() && file.getName().equals("assets")) { try { FileUtils.copyDirectory(file, assets.getFile()); } catch (IOException e) { // ignore } } } });
if (FileFsFile.from(BUILD_OUTPUT, "res", "merged").exists()) { res = FileFsFile.from(BUILD_OUTPUT, "res", "merged", flavor, type); } else if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) { res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type); } else { res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res"); if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) { assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type); } else { assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets"); if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) { if(FileFsFile.from(BUILD_OUTPUT, "manifests", "full").exists()){ manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", flavor, type, "AndroidManifest.xml"); } else { manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "aapt", flavor, type, "AndroidManifest.xml"); manifest = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "AndroidManifest.xml"); Logger.debug("Robolectric assets directory: " + assets.getPath()); Logger.debug(" Robolectric res directory: " + res.getPath()); Logger.debug(" Robolectric manifest path: " + manifest.getPath()); Logger.debug(" Robolectric package name: " + packageName); return new AndroidManifest(manifest, res, assets, packageName);
if (FileFsFile.from(buildOutputDir, "res", "merged").exists()) { res = FileFsFile.from(buildOutputDir, "res", "merged", flavor, type); } else if (FileFsFile.from(buildOutputDir, "res").exists()) { res = FileFsFile.from(buildOutputDir, "res", flavor, type); } else { res = FileFsFile.from(buildOutputDir, "bundles", flavor, type, "res"); if (FileFsFile.from(buildOutputDir, "assets").exists()) { assets = FileFsFile.from(buildOutputDir, "assets", flavor, type); } else { assets = FileFsFile.from(buildOutputDir, "bundles", flavor, type, "assets"); if (FileFsFile.from(buildOutputDir, "manifests", "full").exists()) { manifest = FileFsFile.from(buildOutputDir, "manifests", "full", flavor, type, "AndroidManifest.xml"); } else if (FileFsFile.from(buildOutputDir, "manifests", "aapt").exists()) { manifest = FileFsFile.from(buildOutputDir, "manifests", "aapt", flavor, type, "AndroidManifest.xml"); } else { manifest = FileFsFile.from(buildOutputDir, "bundles", flavor, type, "AndroidManifest.xml"); if (FileFsFile.from(projectDir, "src", "test", "assets").exists()) { FileFsFile testAssets = FileFsFile.from(projectDir, "src", "test", "assets"); try { FileUtils.copyDirectory(testAssets.getFile(), assets.getFile()); } catch (IOException e) { File explodedAar = FileFsFile.from(buildOutputDir, "exploded-aar").getFile(); if (explodedAar.exists()) { forEachFile(explodedAar, new Action1<File>() {
protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); if (androidManifestFile.exists()) { return appManifest; } else { androidManifestFile = FileFsFile.from(MODULE_ROOT, "src/main/AndroidManifest.xml"); FsFile resDirectory = FileFsFile.from(MODULE_ROOT, "src/main/res"); FsFile assetsDirectory = FileFsFile.from(MODULE_ROOT, "src/main/assets"); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); } } }
public static FsFile newFile(File file) { return new FileFsFile(file); }
@Override public String getBaseName() { String name = getName(); int dotIndex = name.indexOf("."); return dotIndex >= 0 ? name.substring(0, dotIndex) : name; }
@Override public FsFile[] listFiles() { return asFsFiles(file.listFiles()); }
final FileFsFile manifest; if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) { res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type); } else { res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res"); if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) { assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type); } else { assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets"); if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) { manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "aapt", flavor, type, "AndroidManifest.xml"); } else { manifest = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "AndroidManifest.xml"); Logger.debug("Robolectric assets directory: " + assets.getPath()); Logger.debug(" Robolectric res directory: " + res.getPath()); Logger.debug(" Robolectric manifest path: " + manifest.getPath()); Logger.debug(" Robolectric package name: " + packageName); return new AndroidManifest(manifest, res, assets, packageName);
if (FileFsFile.from(buildOutputDir, "res", "merged").exists()) { res = FileFsFile.from(buildOutputDir, "res", "merged", flavor, type); } else if (FileFsFile.from(buildOutputDir, "res").exists()) { res = FileFsFile.from(buildOutputDir, "res", flavor, type); } else { res = FileFsFile.from(buildOutputDir, "bundles", flavor, type, "res"); if (FileFsFile.from(buildOutputDir, "assets").exists()) { assets = FileFsFile.from(buildOutputDir, "assets", flavor, type); } else { assets = FileFsFile.from(buildOutputDir, "bundles", flavor, type, "assets"); if (FileFsFile.from(buildOutputDir, "manifests", "full").exists()) { manifest = FileFsFile.from(buildOutputDir, "manifests", "full", flavor, type, "AndroidManifest.xml"); } else if (FileFsFile.from(buildOutputDir, "manifests", "aapt").exists()) { manifest = FileFsFile.from(buildOutputDir, "manifests", "aapt", flavor, type, "AndroidManifest.xml"); } else { manifest = FileFsFile.from(buildOutputDir, "bundles", flavor, type, "AndroidManifest.xml"); if (FileFsFile.from(projectDir, "src", "test", "assets").exists()) { FileFsFile testAssets = FileFsFile.from(projectDir, "src", "test", "assets"); try { FileUtils.copyDirectory(testAssets.getFile(), assets.getFile()); } catch (IOException e) { File explodedAar = FileFsFile.from(buildOutputDir, "exploded-aar").getFile(); if (explodedAar.exists()) { forEachFile(explodedAar, new Action1<File>() {
protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); if (androidManifestFile.exists()) { return appManifest; } else { String moduleRoot = getModuleRootPath(config); androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("bundles", "manifests/full")); FsFile resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath().replace("/res", "").replace("bundles", "res")); FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath().replace("/assets", "").replace("bundles", "assets")); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); } }
public static FsFile newFile(String filePath) { return new FileFsFile(filePath); }
@Override public String getBaseName() { String name = getName(); int dotIndex = name.indexOf("."); return dotIndex >= 0 ? name.substring(0, dotIndex) : name; }
@Override public FsFile[] listFiles() { return asFsFiles(file.listFiles()); }
protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); if (androidManifestFile.exists()) { return appManifest; } else { String moduleRoot = getModuleRootPath(config); final String build_test_out = "build" + File.separator + "out"; androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath() .replace("bundles", "manifests" + File.separator + "full") .replace("build", build_test_out)); FsFile resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath() .replace("" + File.separator + "res", "") .replace("bundles", "res") .replace("build", build_test_out)); FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath() .replace("" + File.separator + "assets", "") .replace("bundles", "assets") .replace("build", build_test_out)); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); } }
public static ResName qualifyFromFilePath(@Nonnull final String packageName, @Nonnull final String filePath) { final FileFsFile filePathFile = new FileFsFile(new File(filePath)); final String type = filePathFile.getParent().getName().split("-", 0)[0]; final String name = filePathFile.getBaseName(); return new ResName(packageName, type, name); }
public static FsFile newFile(File file) { return new FileFsFile(file); }
@Override public FsFile[] listFiles(final Filter filter) { return asFsFiles(file.listFiles(pathname -> filter.accept(new FileFsFile(pathname)))); }
@Override public void call(File file) { if (file.isDirectory() && file.getName().equals("assets")) { try { FileUtils.copyDirectory(file, assets.getFile()); } catch (IOException e) { // ignore } } } });