Java Code Examples for org.eclipse.core.resources.IBuildConfiguration

The following examples show how to use org.eclipse.core.resources.IBuildConfiguration. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: xtext-eclipse   Source File: IntegrationTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("restriction")
@Test public void testBuildOrderIsCorrect() throws Exception {
	foo_project = createJavaProjectWithRootSrc("foo");
	bar_project = createJavaProjectWithRootSrc("bar");

	org.eclipse.core.internal.resources.Workspace workspace =
			(org.eclipse.core.internal.resources.Workspace) ResourcesPlugin.getWorkspace();
	IBuildConfiguration[] buildOrder = workspace.getBuildOrder();
	assertEquals(bar_project.getProject(), buildOrder[0].getProject());
	assertEquals(foo_project.getProject(), buildOrder[1].getProject());
	// add a classpath entry and a project reference
	addProjectReference(bar_project, foo_project);
	
	buildOrder = workspace.getBuildOrder();
	assertEquals(foo_project.getProject(), buildOrder[0].getProject());
	assertEquals(bar_project.getProject(), buildOrder[1].getProject());
}
 
Example 2
Source Project: xtext-eclipse   Source File: IntegrationTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("restriction")
@Test public void testBuildOrderIsWrong() throws Exception {
	foo_project = createJavaProjectWithRootSrc("foo");
	bar_project = createJavaProjectWithRootSrc("bar");

	org.eclipse.core.internal.resources.Workspace workspace =
			(org.eclipse.core.internal.resources.Workspace) ResourcesPlugin.getWorkspace();
	IBuildConfiguration[] buildOrder = workspace.getBuildOrder();
	assertEquals(bar_project.getProject(), buildOrder[0].getProject());
	assertEquals(foo_project.getProject(), buildOrder[1].getProject());
	// here we do only add a classpath entry and no core.resources project reference
	JavaProjectSetupUtil.addProjectReference(bar_project, foo_project);
	
	buildOrder = workspace.getBuildOrder();
	assertEquals(bar_project.getProject(), buildOrder[0].getProject());
	assertEquals(foo_project.getProject(), buildOrder[1].getProject());
}
 
Example 3
Source Project: xtext-eclipse   Source File: BuildManagerAccess.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Obtain the configured Xtext builder for the given project, if any.
 */
public static XtextBuilder findBuilder(IProject project) {
	try {
		if (project.isAccessible()) {
			Project casted = (Project) project;
			IBuildConfiguration activeBuildConfig = casted.getActiveBuildConfig();
			for (ICommand command : casted.internalGetDescription().getBuildSpec(false)) {
				if (XtextBuilder.BUILDER_ID.equals(command.getBuilderName())) {
					IWorkspace workspace = ResourcesPlugin.getWorkspace();
					if (workspace instanceof Workspace) {
						BuildManager buildManager = ((Workspace) workspace).getBuildManager();
						XtextBuilder result = (XtextBuilder) getBuilder.invoke(buildManager, activeBuildConfig, command, -1,
								new MultiStatus(Activator.PLUGIN_ID, 0, null, null));
						return result;
					}
				}
			}
		}
		return null;
	} catch (IllegalAccessException | InvocationTargetException | CoreException e) {
		throw new RuntimeException(e);
	}
}
 
Example 4
Source Project: bonita-studio   Source File: ProjectAssert.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies that the actual IProject's activeBuildConfig is equal to the given one.
 *
 * @param activeBuildConfig the given activeBuildConfig to compare the actual IProject's activeBuildConfig to.
 * @return this assertion object.
 * @throws CoreException
 * @throws AssertionError - if the actual IProject's activeBuildConfig is not equal to the given one.
 */
public ProjectAssert hasActiveBuildConfig(final IBuildConfiguration activeBuildConfig) throws CoreException, AssertionError {
    // check that actual IProject we want to make assertions on is not null.
    isNotNull();

    // we overrides the default error message with a more explicit one
    final String errorMessage = format("\nExpected <%s> activeBuildConfig to be:\n  <%s>\n but was:\n  <%s>", actual, activeBuildConfig,
            actual.getActiveBuildConfig());

    // check
    if (!actual.getActiveBuildConfig().equals(activeBuildConfig)) {
        throw new AssertionError(errorMessage);
    }

    // return the current assertion for method chaining
    return this;
}
 
Example 5
Source Project: bonita-studio   Source File: ProjectAssert.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies that the actual IProject's buildConfigs contains the given IBuildConfiguration elements.
 *
 * @param buildConfigs the given elements that should be contained in actual IProject's buildConfigs.
 * @return this assertion object.
 * @throws CoreException
 * @throws AssertionError if the actual IProject's buildConfigs does not contain all given IBuildConfiguration elements.
 */
public ProjectAssert hasBuildConfigs(final IBuildConfiguration... buildConfigs) throws CoreException {
    // check that actual IProject we want to make assertions on is not null.
    isNotNull();

    // check that given IBuildConfiguration varargs is not null.
    if (buildConfigs == null) {
        throw new AssertionError("Expecting buildConfigs parameter not to be null.");
    }

    // check with standard error message (see commented below to set your own message).
    Assertions.assertThat(actual.getBuildConfigs()).contains(buildConfigs);

    // uncomment the 4 lines below if you want to build your own error message :
    // WritableAssertionInfo assertionInfo = new WritableAssertionInfo();
    // String errorMessage = "my error message";
    // assertionInfo.overridingErrorMessage(errorMessage);
    // Iterables.instance().assertContains(assertionInfo, actual.getTeamMates(), teamMates);

    // return the current assertion for method chaining
    return this;
}
 
Example 6
Source Project: n4js   Source File: ExternalProject.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Like {@link #getActiveBuildConfig()} but doesn't check accessibility. Project must be accessible.
 *
 * @see #getActiveBuildConfig()
 */
public IBuildConfiguration unsafeGetActiveBuildConfig() {
	String configName = internalGetDescription().getActiveBuildConfig();
	try {
		if (configName != null)
			return getBuildConfig(configName);
	} catch (CoreException e) {
		// Build configuration doesn't exist; treat the first as active.
	}
	return internalGetBuildConfigs(false)[0];
}
 
Example 7
Source Project: n4js   Source File: N4JSExternalProject.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IBuildConfiguration[] internalGetReferencedBuildConfigs(String configName, boolean includeMissing) {
	final IBuildConfiguration[] filteredConfigs = from(referencedBuildConfigs)
			.filter(config -> includeMissing ? true : config.getProject().exists())
			.toArray(IBuildConfiguration.class);
	return filteredConfigs;
}
 
Example 8
private void refreshAndFullBuild(IProgressMonitor monitor) throws InvocationTargetException {
	
	List<IProject> projects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
	boolean isAutoBuildEnabled = isAutoBuildEnabled();	
	 try
     {
		 if (isAutoBuildEnabled)
		 {
			 enableAutoBuild(false);
		 }
		
		// refresh all projects one by one  
		for (IProject project : projects)
		{
			if (project.isOpen())
			{
				project.refreshLocal(IResource.DEPTH_INFINITE, null);
			}
		}
		// do a full build
        ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
        IBuildConfiguration[] platformBuildConfig = { ResourcesPlugin.getWorkspace().newBuildConfig("platform","platform-build")};
        // build the platform first since other projects depend on it
        ResourcesPlugin.getWorkspace().build(platformBuildConfig, IncrementalProjectBuilder.FULL_BUILD, true, monitor);
        ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, monitor);
      }
      catch (CoreException e)
      {
    	Activator.logError("Failed to synchronize with the platform", e);
        throw new InvocationTargetException(e);
      }
	 if (isAutoBuildEnabled)
	 {
		 enableAutoBuild(true);
	 }
}
 
Example 9
Source Project: goclipse   Source File: LangProjectBuilder.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected boolean isFirstProjectOfKind() throws CoreException {
	for (IBuildConfiguration buildConfig : getContext().getAllReferencedBuildConfigs()) {
		if(buildConfig.getProject().hasNature(LangCore.NATURE_ID)) {
			return false;
		}
	}
	return true;
}
 
Example 10
Source Project: goclipse   Source File: LangProjectBuilder.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected boolean isLastProjectOfKind() throws CoreException {
	for (IBuildConfiguration buildConfig : getContext().getAllReferencingBuildConfigs()) {
		if(buildConfig.getProject().hasNature(LangCore.NATURE_ID)) {
			return false;
		}
	}
	return true;
}
 
Example 11
Source Project: n4js   Source File: ExternalProject.java    License: Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IBuildConfiguration getActiveBuildConfig() throws CoreException {
	return new BuildConfiguration(this);
}
 
Example 12
Source Project: Pydev   Source File: AbstractIProjectStub.java    License: Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void build(IBuildConfiguration config, int kind, IProgressMonitor monitor) throws CoreException {
    throw new RuntimeException("Not implemented");
}
 
Example 13
Source Project: Pydev   Source File: AbstractIProjectStub.java    License: Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IBuildConfiguration getActiveBuildConfig() throws CoreException {
    throw new RuntimeException("Not implemented");
}
 
Example 14
Source Project: Pydev   Source File: AbstractIProjectStub.java    License: Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IBuildConfiguration getBuildConfig(String configName) throws CoreException {
    throw new RuntimeException("Not implemented");
}
 
Example 15
Source Project: Pydev   Source File: AbstractIProjectStub.java    License: Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IBuildConfiguration[] getBuildConfigs() throws CoreException {
    throw new RuntimeException("Not implemented");
}
 
Example 16
Source Project: Pydev   Source File: AbstractIProjectStub.java    License: Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IBuildConfiguration[] getReferencedBuildConfigs(String configName, boolean includeMissing)
        throws CoreException {
    throw new RuntimeException("Not implemented");
}
 
Example 17
Source Project: n4js   Source File: N4JSExternalProject.java    License: Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Attach the argument as a referenced build configuration to the project.
 *
 * @param config
 *            the configuration to attach.
 * @return {@link Set#add(Object)}.
 */
boolean add(final IBuildConfiguration config) {
	return referencedBuildConfigs.add(config);
}