diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/BazelPluginActivator.java b/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/BazelPluginActivator.java index 0838e18d..b04cff89 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/BazelPluginActivator.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/BazelPluginActivator.java @@ -352,7 +352,6 @@ public void closeBazelWorkspace() { // now forget about the workspace bazelWorkspace = null; bazelWorkspaceCommandRunner = null; - configurationManager.setBazelWorkspacePath(null); } // TEST ONLY diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/projectimport/flow/LoadAspectsFlow.java b/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/projectimport/flow/LoadAspectsFlow.java index 1bcb61ef..ed39e909 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/projectimport/flow/LoadAspectsFlow.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/projectimport/flow/LoadAspectsFlow.java @@ -86,11 +86,23 @@ public void run(ImportContext ctx, SubMonitor progressMonitor) { try { Map> targetInfos = bazelWorkspaceCmdRunner.getAspectTargetInfos(labels, "importWorkspace"); + + if (targetInfos.isEmpty()) { + BazelPluginActivator.getInstance().closeBazelWorkspace(); + throw new IllegalStateException( + "Bazel could not provide any information about the selected project(s). " + + "This usually means there is a Bazel build error in the underlying packages being imported.\n\n" + + "Please run a command line build for these packages to verify they build correctly."); + } + List allTargetInfos = new ArrayList<>(); for (Set targetTargetInfos : targetInfos.values()) { allTargetInfos.addAll(targetTargetInfos); } ctx.setAspectTargetInfos(new AspectTargetInfos(allTargetInfos)); + } catch (RuntimeException e) { + // the error dialog looks better if we dont wrap the exception, so dont do it unless we have to + throw e; } catch (Exception e) { throw new RuntimeException(e); } diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/runtime/impl/EclipseResourceHelper.java b/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/runtime/impl/EclipseResourceHelper.java index 0d53b8f8..29cef84a 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/runtime/impl/EclipseResourceHelper.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/main/java/com/salesforce/bazel/eclipse/runtime/impl/EclipseResourceHelper.java @@ -44,6 +44,7 @@ import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IProcess; import org.eclipse.jface.preference.IPreferenceStore; +import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; import com.salesforce.bazel.eclipse.BazelPluginActivator; @@ -138,6 +139,12 @@ public Preferences getProjectBazelPreferences(IProject project) { LOG.error("Could not find the Preferences node for the Bazel plugin for project [{}]", project.getName()); } + try { + eclipseProjectPrefs.sync(); + } catch (BackingStoreException bse) { + LOG.error("Could not read Eclipse preferences for project [{}]", project.getName(), bse); + } + return eclipseProjectPrefs; } @@ -279,7 +286,7 @@ public void createFolderLink(IFolder thisFolder, IPath bazelWorkspaceLocation, i IProgressMonitor monitor) { try { LOG.debug("createFolderLink: thisFolder=" + thisFolder.getLocation().toOSString() - + " bazelWorkspaceLocation=" + bazelWorkspaceLocation.toOSString()); + + " bazelWorkspaceLocation=" + bazelWorkspaceLocation.toOSString()); thisFolder.createLink(bazelWorkspaceLocation, updateFlags, monitor); } catch (Exception anyE) { throw new IllegalArgumentException(anyE);