org.eclipse.core.runtime.jobs.ISchedulingRule Java Examples

The following examples show how to use org.eclipse.core.runtime.jobs.ISchedulingRule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Retrieves a combined rule for modifying the resources
 * @param resources set of resources
 * @return a combined rule
 */
public static ISchedulingRule getModifyRule(IResource[] resources)
{
    if (resources == null)
    {
        return null;
    }
    ISchedulingRule combinedRule = null;
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    for (int i = 0; i < resources.length; i++)
    {
        // if one of the resources does not exist
        // something is screwed up
        if (resources[i] == null || !resources[i].exists())
        {
            return null;
        }
        ISchedulingRule rule = ruleFactory.modifyRule(resources[i]);
        combinedRule = MultiRule.combine(rule, combinedRule);
    }
    return combinedRule;
}
 
Example #2
Source File: LibraryClasspathContainerResolverService.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
public IClasspathEntry[] resolveLibrariesAttachSources(String... libraryIds)
    throws CoreException {
  ISchedulingRule currentRule = Job.getJobManager().currentRule();
  Preconditions.checkState(
      currentRule == null || currentRule.contains(getSchedulingRule()),
      "current scheduling rule is insufficient: " + currentRule);

  LinkedHashSet<IClasspathEntry> resolvedEntries = new LinkedHashSet<>();
  for (String libraryId : libraryIds) {
    Library library = CloudLibraries.getLibrary(libraryId);
    if (library == null) {
      String message = Messages.getString("InvalidLibraryId", libraryId); // $NON-NLS-1$
      throw new CoreException(StatusUtil.error(this, message));
    }
    for (LibraryFile libraryFile : library.getAllDependencies()) {
      resolvedEntries.add(resolveLibraryFileAttachSourceSync(libraryFile));
    }
  }
  return resolvedEntries.toArray(new IClasspathEntry[0]);
}
 
Example #3
Source File: CreateAppEngineStandardWtpProjectTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testAppEngineLibrariesAdded() throws InvocationTargetException, CoreException {
  Library library = CloudLibraries.getLibrary("appengine-api");
  List<Library> libraries = new ArrayList<>();
  libraries.add(library);
  config.setLibraries(libraries);
  CreateAppEngineWtpProject creator = newCreateAppEngineWtpProject();
  
  // CreateAppEngineWtpProject/WorkspaceModificationOperation normally acquires the
  // workspace lock in `run()`
  ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
  Job.getJobManager().beginRule(rule, null);
  try {
    creator.execute(monitor);
  } finally {
    Job.getJobManager().endRule(rule);
  }
  ProjectUtils.waitForProjects(project);

  assertTrue(project.hasNature(JavaCore.NATURE_ID));
  assertAppEngineApiSdkOnClasspath();
}
 
Example #4
Source File: XtextBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public ISchedulingRule getRule(int kind, Map<String, String> args) {
	switch (preferences.schedulingOption) {
		case NULL: return null;
		case WORKSPACE: return getProject().getWorkspace().getRoot();
		case PROJECT: return getProject();
		case ALL_XTEXT_PROJECTS: return new MultiRule(Arrays.stream(
				getProject().getWorkspace().getRoot().getProjects())
				.filter(XtextProjectHelper::hasNature)
				.toArray(ISchedulingRule[]::new));
		case ALL_XTEXT_PROJECTS_AND_JDTEXTFOLDER: return new MultiRule(Arrays.stream(
				getProject().getWorkspace().getRoot().getProjects())
				.filter(p->
					XtextProjectHelper.hasNature(p)
					|| EXTERNAL_PROJECT_NAME.equals(p.getName())
				)
				.toArray(ISchedulingRule[]::new));
		default: throw new IllegalArgumentException();
	}
}
 
Example #5
Source File: Activator.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private void visit(IJavaElementDelta delta) {
  switch (delta.getElement().getElementType()) {
    case IJavaElement.JAVA_PROJECT:
      if ((delta.getFlags() & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0) {
        final IJavaProject javaProject = (IJavaProject) delta.getElement();
        Job updateContainerStateJob = new WorkspaceJob("Updating Google Cloud libraries") {
          @Override
          public IStatus runInWorkspace(IProgressMonitor monitor) {
            BuildPath.checkLibraryList(javaProject, null);
            return Status.OK_STATUS;
          }
        };
        IWorkspace workspace = javaProject.getProject().getWorkspace();
        ISchedulingRule buildRule = workspace.getRuleFactory().buildRule();
        updateContainerStateJob.setRule(buildRule);
        updateContainerStateJob.setSystem(true);
        updateContainerStateJob.schedule();
      }
      break;
    case IJavaElement.JAVA_MODEL:
      visitChildren(delta);
      break;
    default:
      break;
  }
}
 
Example #6
Source File: LibraryManager.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private IStatus runWithWorkspaceLock(Supplier<IStatus> operation) {
	if (Platform.isRunning()) {
		ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
		try {
			Job.getJobManager().beginRule(rule, null);
			return operation.get();
		} catch (final OperationCanceledException e) {
			LOGGER.info("User cancelled operation.");
			return statusHelper.createCancel("User cancelled operation.");
		} finally {
			Job.getJobManager().endRule(rule);
		}
	} else {
		// locking not available/required in headless case
		return operation.get();
	}
}
 
Example #7
Source File: ResourceHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Retrieves a combined rule for deleting resource
 * @param resource
 * @return
 */
public static ISchedulingRule getDeleteRule(IResource[] resources)
{
    if (resources == null)
    {
        return null;
    }
    ISchedulingRule combinedRule = null;
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    for (int i = 0; i < resources.length; i++)
    {
        ISchedulingRule rule = ruleFactory.deleteRule(resources[i]);
        combinedRule = MultiRule.combine(rule, combinedRule);
    }
    return combinedRule;
}
 
Example #8
Source File: ResourceHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Retrieves a combined rule for creating resource
 * @param resource
 * @return
 */
public static ISchedulingRule getCreateRule(IResource[] resources)
{
    if (resources == null)
    {
        return null;
    }
    ISchedulingRule combinedRule = null;
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    for (int i = 0; i < resources.length; i++)
    {
        ISchedulingRule rule = ruleFactory.createRule(resources[i]);
        combinedRule = MultiRule.combine(rule, combinedRule);
    }
    return combinedRule;
}
 
Example #9
Source File: CrossflowDocumentProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected ISchedulingRule getSaveRule(Object element) {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null) {
				rules.add(computeSchedulingRule(file));
			}
		}
		return new MultiRule((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]));
	}
	return null;
}
 
Example #10
Source File: CrossflowDocumentProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) {
	if (toCreateOrModify.exists())
		return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify);

	IResource parent = toCreateOrModify;
	do {
		/*
		 * XXX This is a workaround for
		 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601
		 * IResourceRuleFactory.createRule should iterate the hierarchy
		 * itself.
		 */
		toCreateOrModify = parent;
		parent = toCreateOrModify.getParent();
	} while (parent != null && !parent.exists());

	return ResourcesPlugin.getWorkspace().getRuleFactory().createRule(toCreateOrModify);
}
 
Example #11
Source File: CrossflowDocumentProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected ISchedulingRule getValidateStateRule(Object element) {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		LinkedList<ISchedulingRule> files = new LinkedList<ISchedulingRule>();
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null) {
				files.add(file);
			}
		}
		return ResourcesPlugin.getWorkspace().getRuleFactory()
				.validateEditRule((IFile[]) files.toArray(new IFile[files.size()]));
	}
	return null;
}
 
Example #12
Source File: BaseDocumentLifeCycleHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
protected void triggerValidation(ICompilationUnit cu, long delay) throws JavaModelException {
	synchronized (toReconcile) {
		toReconcile.add(cu);
		if (!cu.equals(sharedASTProvider.getActiveJavaElement())) {
			sharedASTProvider.disposeAST();
		}
		sharedASTProvider.setActiveJavaElement(cu);
	}
	if (validationTimer != null) {
		validationTimer.cancel();
		ISchedulingRule rule = getRule(toReconcile);
		if (publishDiagnosticsJob != null) {
			publishDiagnosticsJob.cancel();
			publishDiagnosticsJob.setRule(rule);
		}
		validationTimer.setRule(rule);
		validationTimer.schedule(delay);
	} else {
		performValidation(new NullProgressMonitor());
	}
}
 
Example #13
Source File: BuildPathTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolvingRule() {
  ISchedulingRule rule = BuildPath.resolvingRule(project);
  assertTrue(rule.contains(MavenPlugin.getProjectConfigurationManager().getRule()));
  assertTrue(rule.isConflicting(MavenPlugin.getProjectConfigurationManager().getRule()));
  assertTrue(rule.contains(project.getProject()));
}
 
Example #14
Source File: ExternalLibrariesReloadHelper.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Reloads the external libraries by re-indexing all registered external projects that are do not exist in the
 * workspace.
 *
 * @param refreshNpmDefinitions
 *            if {@code true}, then the type definition files will be reloaded/refreshed for all {@code npm}
 *            packages.
 * @param monitor
 *            the monitor for the process.
 * @throws InvocationTargetException
 *             if any unexpected error occurs during the refresh process.
 */
public void reloadLibraries(final boolean refreshNpmDefinitions, final IProgressMonitor monitor)
		throws InvocationTargetException {

	final ISchedulingRule rule = externalBuilder.getRule();
	try {
		Job.getJobManager().beginRule(rule, monitor);
		reloadLibrariesInternal(refreshNpmDefinitions, monitor);
	} catch (final OperationCanceledException e) {
		LOGGER.info("User abort.");
	} finally {
		Job.getJobManager().endRule(rule);
	}
}
 
Example #15
Source File: ResourceUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static void scheduleJob(final IBaseClosure<Void, CoreException> jobRunnable, ISchedulingRule rule, String jobCaption, boolean user) {
	Job job = new Job(jobCaption) {
		public IStatus run(IProgressMonitor monitor) {
			try {
				jobRunnable.execute(null);
			} catch (CoreException e) {
				LogHelper.logError(e);
			}
			return Status.OK_STATUS;
		}
	};
	job.setRule(rule);
	job.setUser(user);
	job.schedule();
}
 
Example #16
Source File: ResourceUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static Job scheduleWorkspaceRunnable(final IWorkspaceRunnable operation,
 		final ISchedulingRule rule, String jobCaption, final Object assignedFamily, boolean user) {
 	Job job = new Job(jobCaption) {
 		public IStatus run(IProgressMonitor monitor) {
 			try {
 				runWorkspaceRunnable(operation, rule);
 			} catch (CoreException e) {
 				LogHelper.logError(e);
 			}
 			return Status.OK_STATUS;
 		}

@Override
public boolean belongsTo(Object family) {
	if (assignedFamily != null){
		return assignedFamily == family;
	}
	else {
		return super.belongsTo(family);
	}
}
 	};
 	job.setRule(rule);
 	job.setUser(user);
 	job.schedule();
 	return job;
 }
 
Example #17
Source File: SourceAttacherJob.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public SourceAttacherJob(
    ISchedulingRule rule,
    IJavaProject javaProject,
    IPath containerPath,
    IPath libraryPath,
    Callable<IPath> sourceArtifactPathProvider) {
  super(Messages.getString("SourceAttachmentDownloaderJobName",
                           javaProject.getProject().getName()));
  this.javaProject = javaProject;
  this.containerPath = containerPath;
  this.libraryPath = libraryPath;
  this.sourceArtifactPathProvider = sourceArtifactPathProvider;
  serializer = new LibraryClasspathContainerSerializer();
  setRule(rule);
}
 
Example #18
Source File: BaseDocumentLifeCycleHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public void didSave(DidSaveTextDocumentParams params) {
	ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
	try {
		JobHelpers.waitForJobs(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, new NullProgressMonitor());
		ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
			@Override
			public void run(IProgressMonitor monitor) throws CoreException {
				handleSaved(params);
			}
		}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
	} catch (CoreException e) {
		JavaLanguageServerPlugin.logException("Handle document save ", e);
	}
}
 
Example #19
Source File: BaseDocumentLifeCycleHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public void didOpen(DidOpenTextDocumentParams params) {
	ISchedulingRule rule = JDTUtils.getRule(params.getTextDocument().getUri());
	try {
		ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
			@Override
			public void run(IProgressMonitor monitor) throws CoreException {
				handleOpen(params);
			}
		}, rule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
	} catch (CoreException e) {
		JavaLanguageServerPlugin.logException("Handle document open ", e);
	}
}
 
Example #20
Source File: LibraryClasspathContainerResolverJob.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public LibraryClasspathContainerResolverJob(
    ISchedulingRule rule,
    ILibraryClasspathContainerResolverService service,
    IJavaProject javaProject) {
  super(Messages.getString("AppEngineLibraryContainerResolverJobName"));
  // This job must be protected; our lower-level Maven classes actions do more verification
  Preconditions.checkNotNull(rule, "rule must be prvided");
  Preconditions.checkNotNull(javaProject, "javaProject is null");
  this.resolverService = service;
  this.javaProject = javaProject;
  setRule(rule);
}
 
Example #21
Source File: LibraryClasspathContainerResolverJobTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testBelongsTo() {
  ISchedulingRule rule = new MutexRule("LibraryClasspathContainerResolverJobTest");
  ILibraryClasspathContainerResolverService service =
      Mockito.mock(ILibraryClasspathContainerResolverService.class);
  IJavaProject javaProject = Mockito.mock(IJavaProject.class);
  LibraryClasspathContainerResolverJob fixture =
      new LibraryClasspathContainerResolverJob(rule, service, javaProject);

  assertTrue(fixture.belongsTo(ResourcesPlugin.FAMILY_MANUAL_BUILD));
}
 
Example #22
Source File: BuildPathTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckLibraries() throws CoreException {
  // Activator.listener monitors Java classpath changes and schedules concurrent jobs that call
  // "checkLibraryList()", which is the method being tested here. Prevent concurrent updates
  // to avoid flakiness: https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/2758
  ISchedulingRule buildRule = project.getProject().getWorkspace().getRuleFactory().buildRule();
  Job.getJobManager().beginRule(buildRule, null);

  try {
    IPath librariesIdPath =
        new Path(".settings").append(LibraryClasspathContainer.CONTAINER_PATH_PREFIX)
            .append("_libraries.container");

    // original classpath without our master-library container
    IClasspathEntry[] originalClasspath = project.getRawClasspath();

    Library library = new Library("libraryId");
    List<Library> libraries = new ArrayList<>();
    libraries.add(library);

    BuildPath.addNativeLibrary(project, libraries, monitor);
    assertEquals(initialClasspathSize + 1, project.getRawClasspath().length);
    assertNotNull(BuildPath.findMasterContainer(project));
    assertTrue(project.getProject().exists(librariesIdPath));

    // master-library container exists, so checkLibraryList should make no change
    BuildPath.checkLibraryList(project, null);
    assertEquals(initialClasspathSize + 1, project.getRawClasspath().length);
    assertNotNull(BuildPath.findMasterContainer(project));
    assertTrue(project.getProject().exists(librariesIdPath));

    // remove the master-library container, so checkLibraryList should remove the library ids file
    project.setRawClasspath(originalClasspath, null);
    BuildPath.checkLibraryList(project, null);
    assertFalse(librariesIdPath + " not removed", project.getProject().exists(librariesIdPath));
  } finally {
    Job.getJobManager().endRule(buildRule);
  }
}
 
Example #23
Source File: ProjectCommand.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Gets the classpaths and modulepaths.
 *
 * @param uri
 *                    Uri of the source/class file that needs to be queried.
 * @param options
 *                    Query options.
 * @return <code>ClasspathResult</code> containing both classpaths and
 *         modulepaths.
 * @throws CoreException
 * @throws URISyntaxException
 */
public static ClasspathResult getClasspaths(String uri, ClasspathOptions options) throws CoreException, URISyntaxException {
	IJavaProject javaProject = getJavaProjectFromUri(uri);
	Optional<IBuildSupport> bs = JavaLanguageServerPlugin.getProjectsManager().getBuildSupport(javaProject.getProject());
	if (!bs.isPresent()) {
		throw new CoreException(new Status(IStatus.ERROR, IConstants.PLUGIN_ID, "No BuildSupport for the project: " + javaProject.getElementName()));
	}
	ILaunchConfiguration launchConfig = bs.get().getLaunchConfiguration(javaProject, options.scope);
	JavaLaunchDelegate delegate = new JavaLaunchDelegate();
	ClasspathResult[] result = new ClasspathResult[1];

	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	ISchedulingRule currentRule = Job.getJobManager().currentRule();
	ISchedulingRule schedulingRule;
	if (currentRule != null && currentRule.contains(javaProject.getSchedulingRule())) {
		schedulingRule = null;
	} else {
		schedulingRule = javaProject.getSchedulingRule();
	}
	workspace.run(new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			String[][] paths = delegate.getClasspathAndModulepath(launchConfig);
			result[0] = new ClasspathResult(javaProject.getProject().getLocationURI(), paths[0], paths[1]);
		}
	}, schedulingRule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());

	if (result[0] != null) {
		return result[0];
	}

	throw new CoreException(new Status(IStatus.ERROR, IConstants.PLUGIN_ID, "Failed to get the classpaths."));
}
 
Example #24
Source File: ResourceUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static ISchedulingRule createRule(Collection<? extends IResource> resources) {
      ISchedulingRule combinedRule = null;
      IResourceRuleFactory ruleFactory = 
            ResourcesPlugin.getWorkspace().getRuleFactory();
      
      for (IResource r : resources) {
      	ISchedulingRule rule = ruleFactory.createRule(r);
          combinedRule = MultiRule.combine(rule, combinedRule);
}
      
      return combinedRule;
   }
 
Example #25
Source File: LibraryClasspathContainerResolverService.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private SourceAttacherJob createSourceAttacherJob(
    IJavaProject javaProject,
    IPath containerPath,
    final LibraryFile libraryFile,
    final IProgressMonitor monitor,
    final Artifact artifact,
    IPath libraryPath) {

  ISchedulingRule rule = BuildPath.resolvingRule(javaProject);
  Callable<IPath> resolver =
      () -> repositoryService.resolveSourceArtifact(libraryFile, artifact.getVersion(), monitor);
  SourceAttacherJob job =
      new SourceAttacherJob(rule, javaProject, containerPath, libraryPath, resolver);
  return job;
}
 
Example #26
Source File: MavenUtils.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Perform some Maven-related action that may result in a change to the local Maven repositories,
 * ensuring that required {@link ISchedulingRule scheduling rules} are held.
 */
public static <T> T runOperation(IProgressMonitor monitor, MavenRepositoryOperation<T> operation)
    throws CoreException {
  SubMonitor progress = SubMonitor.convert(monitor, 10);
  ISchedulingRule rule = mavenResolvingRule();
  boolean acquireRule = Job.getJobManager().currentRule() == null;
  if (acquireRule) {
    Job.getJobManager().beginRule(rule, progress.split(2));
  }
  try {
    Verify.verify(
        Job.getJobManager().currentRule().contains(rule),
        "require holding superset of rule: " + rule);
    IMavenExecutionContext context = MavenPlugin.getMaven().createExecutionContext();
    return context.execute(
        (context2, monitor2) -> {
          // todo we'd prefer not to depend on m2e here
          RepositorySystem system = MavenPluginActivator.getDefault().getRepositorySystem();
          return operation.run(context2, system, SubMonitor.convert(monitor2));
        },
        progress.split(8));
  } finally {
    if (acquireRule) {
      Job.getJobManager().endRule(rule);
    }
  }
}
 
Example #27
Source File: SchedulingRuleFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean isConflicting(ISchedulingRule rule) {
	if (rule instanceof SerialPerObjectRule) {
		SerialPerObjectRule serialPerObjectRule = (SerialPerObjectRule) rule;
		return lockObject == serialPerObjectRule.lockObject;
	}
	return false;
}
 
Example #28
Source File: MutexSchedulingRule.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean isConflicting(ISchedulingRule rule) {
    if (!(rule instanceof MutexSchedulingRule)) {
        return false;
    }
    MutexSchedulingRule mRule = (MutexSchedulingRule) rule;
    if (resource == null || mRule.resource == null) {
        // we don't know the resource, so better to say we have conflict
        return true;
    }
    if (MULTICORE) {
        return resource.contains(mRule.resource);
    }
    return true;
}
 
Example #29
Source File: BuildPath.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a suitable {@link ISchedulingRule scheduling rule} when resolving libraries for a
 * project.
 */
public static ISchedulingRule resolvingRule(IJavaProject javaProject) {
  // Requires both the project modification rule and the Maven project configuration rule
  IWorkspace workspace = javaProject.getProject().getWorkspace();
  ISchedulingRule rule =
      MultiRule.combine(
          workspace.getRuleFactory().modifyRule(javaProject.getProject()),
          MavenUtils.mavenResolvingRule());
  return rule;
}
 
Example #30
Source File: FlexExistingDeployArtifactStagingDelegateTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchedulingRule_artifactInWorkspace() throws CoreException {
  IPath deployArtifact = createFileInProject("in-workspace.war");

  StagingDelegate delegate = new FlexExistingDeployArtifactStagingDelegate(
      deployArtifact, appEngineDirectory);

  ISchedulingRule rule = delegate.getSchedulingRule();
  assertTrue(rule instanceof IFile);
  IFile file = (IFile) rule;
  assertTrue(file.exists());
}