Skip to content

Commit

Permalink
Show a warning to the user rather than crashing if there's no android…
Browse files Browse the repository at this point in the history
… facet when the workspace_type is android.

PiperOrigin-RevId: 578110015
  • Loading branch information
Googler authored and copybara-github committed Oct 31, 2023
1 parent 36f4007 commit 9f8c8ff
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.idea.blaze.base.sync.projectview.LanguageSupport;
import com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings;
import com.google.idea.blaze.common.Context;
import com.google.idea.blaze.common.PrintOutput;
import com.google.idea.blaze.java.projectview.JavaLanguageLevelSection;
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider;
import com.intellij.openapi.module.Module;
Expand All @@ -56,6 +57,7 @@

/** ASwB sync plugin. */
public class BlazeAndroidQuerySyncPlugin implements BlazeQuerySyncPlugin {

@Override
public void updateProjectSettingsForQuerySync(
Project project, Context<?> context, ProjectViewSet projectViewSet) {
Expand Down Expand Up @@ -96,6 +98,17 @@ public void updateProjectStructureForQuerySync(

// Add all source resource directories to this AndroidFacet
AndroidFacet workspaceFacet = AndroidFacet.getInstance(workspaceModule);
if (workspaceFacet == null) {
context.output(
PrintOutput.error(
"workspace_type is android, but no android facet present; not configuring android"
+ " resources"));
context.output(
PrintOutput.output(
"Consider adding \"workspace_type: java\" or similar to your .blazeproject file, or"
+ " add the android facet in project settings if this is an android project."));
return;
}
ImmutableSet<File> androidResourceDirectoryFiles =
androidResourceDirectories.stream()
.map(dir -> new File(workspaceRoot.directory(), dir).getAbsoluteFile())
Expand Down

0 comments on commit 9f8c8ff

Please sign in to comment.