@Override protected AndroidManifest getAppManifest(Config config) { if (config.constants() == Void.class) { Logger.error("Field 'constants' not specified in @Config annotation"); Logger.error("This is required when using RobolectricGradleTestRunner!"); throw new RuntimeException("No 'constants' field in @Config annotation!"); } final String type = getType(config); final String flavor = getFlavor(config); final String applicationId = getApplicationId(config); final FileFsFile res; if (FileFsFile.from(BUILD_OUTPUT, "res", flavor, type).exists()) { res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type); } else { // Use res/merged if the output directory doesn't exist for Data Binding compatibility res = FileFsFile.from(BUILD_OUTPUT, "res/merged", flavor, type); } final FileFsFile assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type); final FileFsFile manifest; if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) { manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", flavor, type, "AndroidManifest.xml"); } else { // Fallback to the location for library manifests 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: " + applicationId); return new AndroidManifest(manifest, res, assets, applicationId); }
@Override protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); if (androidManifestFile.exists()) { return appManifest; } else { androidManifestFile = FileFsFile.from(appManifest.getAndroidManifestFile().getPath() .replace("manifests/full", "manifests/aapt")); return new AndroidManifest(androidManifestFile, appManifest.getResDirectory(), appManifest.getAssetsDirectory()); } }
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()); FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath()); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); } }
@Override protected AndroidManifest getAppManifest(Config config) { if (config.constants() == Void.class) { Logger.error("Field 'constants' not specified in @Config annotation"); Logger.error("This is required when using RobolectricGradleTestRunner!"); throw new RuntimeException("No 'constants' field in @Config annotation!"); } final String type = getType(config); final String flavor = getFlavor(config); final String packageName = getPackageName(config); final FileFsFile res; final FileFsFile assets; 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", "androidTest", 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); }
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 File createFile(AndroidManifest manifest, String fileName, String contents) throws Exception { File assetBase = ((FileFsFile) manifest.getAssetsDirectory()).getFile(); File file = new File(assetBase, fileName); file.getParentFile().mkdirs(); FileWriter fileWriter = new FileWriter(file); try { fileWriter.write(contents); } finally { fileWriter.close(); } assetsToDelete.add(file); return 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); } }
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()); FsFile resDirectory = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("AndroidManifest.xml", "res")); FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("AndroidManifest.xml", "assets")); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); } }
protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); FsFile resDirectory; FsFile assetsDirectory; String moduleRoot = getModuleRootPath(config); androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("bundles", "manifests/aapt")); if(appManifest.getResDirectory().getPath().contains("release")) { resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath().replace("release", "default")); assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath().replace("release", "default")); }else{ resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath().replace("bundles/debug/res", "res/merged/debug")); assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath()); } System.out.print(androidManifestFile.getPath() + '\n'); System.out.print(resDirectory.getPath() + '\n'); System.out.print(assetsDirectory.getPath() + '\n'); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); }
protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); FsFile resDirectory; FsFile assetsDirectory; String moduleRoot = getModuleRootPath(config); androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("bundles", "manifests/aapt")); if(appManifest.getResDirectory().getPath().contains("release")) { resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath().replace("release", "default")); assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath().replace("release", "default")); }else{ resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath()); assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath()); } System.out.print(androidManifestFile.getPath() + '\n'); System.out.print(resDirectory.getPath() + '\n'); System.out.print(assetsDirectory.getPath() + '\n'); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); }
@Override protected AndroidManifest getAppManifest(Config config) { if (config.constants() == Void.class) { Logger.error("Field 'constants' not specified in @Config annotation"); Logger.error("This is required when using RobolectricGradleTestRunner!"); throw new RuntimeException("No 'constants' field in @Config annotation!"); } final String type = getType(config); final String flavor = getFlavor(config); final String packageName = getPackageName(config); final FileFsFile res; final FileFsFile assets; final FileFsFile manifest; // res/merged added in Android Gradle plugin 1.3-beta1 // Recognize new name for data binding layouts until later plugin version if (FileFsFile.from(BUILD_OUTPUT, "data-binding-layout-out").exists()) { res = FileFsFile.from(BUILD_OUTPUT, "data-binding-layout-out", flavor, type); } else 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()) { manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", 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); }
@Override protected AndroidManifest getAppManifest(final Config config) { if (config.constants() == Void.class) { Logger.error("Field 'constants' not specified in @Config annotation"); Logger.error("This is required when using RobolectricGradleTestRunner!"); throw new RuntimeException("No 'constants' field in @Config annotation!"); } final String type = getType(config); final String flavor = getFlavor(config); final String packageName = getPackageName(config); final FileFsFile res; final FileFsFile assets; final FileFsFile manifest; // res/merged added in Android Gradle plugin 1.3-beta1 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()) { manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", 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) { @Override public String getRClassName() throws Exception { return com.kickstarter.R.class.getName(); } }; }
@Override protected AndroidManifest getAppManifest(Config config) { if (config.constants() == Void.class) { Logger.error("Field 'constants' not specified in @Config annotation"); Logger.error("This is required when using RobolectricGradleTestRunner!"); throw new RuntimeException("No 'constants' field in @Config annotation!"); } final String type = getType(config); final String flavor = getFlavor(config); final String packageName = getPackageName(config); final FileFsFile res; final FileFsFile assets; final FileFsFile manifest; // res/merged added in Android Gradle plugin 1.3-beta1 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", "test", flavor, type, "AndroidManifest.xml").exists()) { manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "test", flavor, type, "AndroidManifest.xml"); } else if (FileFsFile.from(BUILD_OUTPUT, "manifests", "full", flavor, type, "AndroidManifest.xml").exists()) { manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", 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); }
@Override protected AndroidManifest getAppManifest(Config config) { if (config.constants() == Void.class) { Logger.error("Field 'constants' not specified in @Config annotation"); Logger.error("This is required when using RobolectricGradleTestRunner!"); throw new RuntimeException("No 'constants' field in @Config annotation!"); } final String type = getType(config); final String flavor = getFlavor(config); final String packageName = getPackageName(config); final FileFsFile res; final FileFsFile assets; final FileFsFile manifest; if (FileFsFile.from(BUILD_OUTPUT, "data-binding-layout-out").exists()) { // Android gradle plugin 1.5.0+ puts the merged layouts in data-binding-layout-out. // https://github.com/robolectric/robolectric/issues/2143 res = FileFsFile.from(BUILD_OUTPUT, "data-binding-layout-out", flavor, type); } else if (FileFsFile.from(BUILD_OUTPUT, "res", "merged").exists()) { // res/merged added in Android Gradle plugin 1.3-beta1 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()) { manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "full", 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); }
@Override protected AndroidManifest getAppManifest(Config config) { final String cwd = System.getProperty("user.dir"); Logger.debug("Current working directory: " + cwd); if (config.constants() == Void.class) { Logger.error("Field 'constants' not specified in @Config annotation"); Logger.error("This is required when using RobolectricGradleTestRunner!"); throw new RuntimeException("No 'constants' field in @Config annotation!"); } final String type = getType(config); final String flavor = getFlavor(config); final String packageName = getPackageName(config); final FileFsFile res; final FileFsFile assets; 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()) { // [CUSTOMIZED] The default implementation uses `full` instead of `aapt`. 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); }