fix(tooling-api): misleading log message while initializing project

This commit fixes a misleading log message that shows 'Project XXXX is not an Android project' message for root projects
This commit is contained in:
Akash Yadav
2023-07-08 23:15:29 +05:30
parent 8116cee4a7
commit 430c15836d
@@ -206,8 +206,7 @@ public class ProjectReader {
try {
final var info = createAndroidModelInfo(gradle, controller);
if (info == null) {
throw new UnknownModelException(
"Project " + gradle.getName() + " is not an AndroidProject");
throw new NotAnAndroidProjectException(gradle.getName());
}
outIssues.put(gradle.getPath(), info.getSyncIssues());
@@ -215,6 +214,12 @@ public class ProjectReader {
} catch (Throwable error) {
if (androidOnly) {
if (error instanceof NotAnAndroidProjectException && gradle.getParent() == null) {
// A root project is not an Android project in most cases
// do not emit misleading logs
return null;
}
log(error.getMessage());
return null;
}
@@ -539,4 +544,11 @@ public class ProjectReader {
}
}
}
private static class NotAnAndroidProjectException extends UnknownModelException {
public NotAnAndroidProjectException(String projectName) {
super("Project " + projectName + " is not an Android project");
}
}
}