AndroidManifestFinder { File findManifestInKnownPathsStartingFromGenFolder(String sourcesGenerationFolder) { Iterable<AndroidManifestFinderStrategy> strategies = Arrays.asList(new GradleAndroidManifestFinderStrategy(environment, sourcesGenerationFolder), new LegacyGradleAndroidManifestFinderStrategy(environment, sourcesGenerationFolder), new MavenAndroidManifestFinderStrategy(sourcesGenerationFolder), new EclipseAndroidManifestFinderStrategy(sourcesGenerationFolder)); AndroidManifestFinderStrategy applyingStrategy = null; for (AndroidManifestFinderStrategy strategy : strategies) { if (strategy.applies()) { applyingStrategy = strategy; break; } } File androidManifestFile = null; if (applyingStrategy != null) { androidManifestFile = applyingStrategy.findAndroidManifestFile(); } if (androidManifestFile != null) { LOGGER.debug("{} AndroidManifest.xml file found using generation folder {}: {}", applyingStrategy.name, sourcesGenerationFolder, androidManifestFile.toString()); } else { LOGGER.error("Could not find the AndroidManifest.xml file, using generation folder [{}])", sourcesGenerationFolder); } return androidManifestFile; } AndroidManifestFinder(AndroidAnnotationsEnvironment environment); AndroidManifest extractAndroidManifest(); static final Option OPTION_MANIFEST; static final Option OPTION_LIBRARY; static final Option OPTION_INSTANT_FEATURE; }
@Test public void testFindManifestInKnownPathsStartingFromGenFolder() throws IOException { AndroidAnnotationsEnvironment mockEnvironment = Mockito.mock(AndroidAnnotationsEnvironment.class); Mockito.when(mockEnvironment.getOptionBooleanValue(AndroidManifestFinder.OPTION_INSTANT_FEATURE)).thenReturn(false); AndroidManifestFinder finder = new AndroidManifestFinder(mockEnvironment); tempDirectory = Files.createTempDirectory("AA"); File genFolder = createGenFolder(genFolderPath); File manifestFolder = new File(tempDirectory.toString(), manifestFolderPath); createFolder(manifestFolder); File expectedManifest = new File(manifestFolder, "AndroidManifest.xml"); createFile(expectedManifest); File foundManifest = finder.findManifestInKnownPathsStartingFromGenFolder(genFolder.getAbsolutePath()); assertEquals(shouldFind, Objects.equals(expectedManifest, foundManifest)); }