in plugin/src/main/java/com/uber/okbuck/core/model/android/ExoPackageScope.java [40:89]
public String getAppClass() {
if (manifest == null) {
return null;
}
@Var String appClass = null;
File manifestFile = project.file(manifest);
Document manifestXml = XmlUtil.loadXml(manifestFile);
try {
NodeList nodeList = manifestXml.getElementsByTagName("application");
Preconditions.checkArgument(nodeList.getLength() == 1);
Element application = (Element) nodeList.item(0);
appClass =
application.getAttribute("android:name").replaceAll("\\.", "/").replaceAll("^/", "");
} catch (Exception ignored) {
}
String finalAppClass = appClass;
if (appClass != null && !appClass.isEmpty()) {
Optional<String> optionalAppClass =
base.getSources()
.stream()
.map(
sourceDir -> {
FileTree found =
project.fileTree(
ImmutableMap.of(
"dir",
sourceDir,
"includes",
ImmutableList.of("**/" + finalAppClass + ".java")));
try {
return FileUtil.getRelativePath(
project.getProjectDir(), found.getSingleFile());
} catch (IllegalStateException ignored) {
return null;
}
})
.filter(Objects::nonNull)
.findFirst();
if (optionalAppClass.isPresent()) {
return optionalAppClass.get();
}
}
return finalAppClass;
}