private Option<File> findManifestInParentsDirectories(){
  Option<FileHelper.FileHolder> projectRootHolderOption=fileHelper.findRootProjectHolder();
  if (projectRootHolderOption.isAbsent()) {
    return Option.absent();
  }
  FileHelper.FileHolder projectRootHolder=projectRootHolderOption.get();
  File projectRoot=projectRootHolder.projectRoot;
  File androidManifestFile=new File(projectRoot,"AndroidManifest.xml");
  for (int i=0; i < MAX_PARENTS_FROM_SOURCE_FOLDER; i++) {
    if (androidManifestFile.exists()) {
      break;
    }
    androidManifestFile=new File(projectRoot,"src" + File.separator + "main"+ File.separator+ "AndroidManifest.xml");
    if (androidManifestFile.exists()) {
      break;
    }
    if (projectRoot.getParentFile() != null) {
      projectRoot=projectRoot.getParentFile();
      androidManifestFile=new File(projectRoot,"AndroidManifest.xml");
    }
 else {
      break;
    }
  }
  if (!androidManifestFile.exists()) {
    return Option.absent();
  }
  return Option.of(androidManifestFile);
}

private Option < File > findManifestInParentsDirectories ( ) { Option < FileHelper . FileHolder > projectRootHolderOption = fileHelper . findRootProjectHolder ( ) ; if ( projectRootHolderOption . isAbsent ( ) ) { return Option . absent ( ) ; } FileHelper . FileHolder projectRootHolder = projectRootHolderOption . get ( ) ; File projectRoot = projectRootHolder . projectRoot ; File androidManifestFile = new File ( projectRoot , "AndroidManifest.xml" ) ; for ( int i = 0 ; i < MAX_PARENTS_FROM_SOURCE_FOLDER ; i ++ ) { if ( androidManifestFile . exists ( ) ) { break ; } androidManifestFile = new File ( projectRoot , "src" + File . separator + "main" + File . separator + "AndroidManifest.xml" ) ; if ( androidManifestFile . exists ( ) ) { break ; } if ( projectRoot . getParentFile ( ) != null ) { projectRoot = projectRoot . getParentFile ( ) ; androidManifestFile = new File ( projectRoot , "AndroidManifest.xml" ) ; } else { break ; } } if ( ! androidManifestFile . exists ( ) ) { return Option . absent ( ) ; } return Option . of ( androidManifestFile ) ; }
we use a dirty trick to find the androidmanifest . xml file , since it ' s not available in the classpath . the idea is quite simple : create a fake class file , retrieve its uri , and start going up in parent folders to find the androidmanifest . xml file . any better solution will be appreciated .
