Java Code Examples for org.eclipse.xtext.ui.util.PluginProjectFactory#createProject()

The following examples show how to use org.eclipse.xtext.ui.util.PluginProjectFactory#createProject() . 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: Bug330096Test.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected IProject createPluginProject(String name) throws CoreException {
	Injector injector = TestlanguagesActivator.getInstance().getInjector("org.eclipse.xtext.testlanguages.backtracking.SimpleBeeLangTestLanguage");
	PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class);
	projectFactory.setProjectName(name);
	projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
	projectFactory.addFolders(Collections.singletonList("src"));
	projectFactory.addBuilderIds(
		JavaCore.BUILDER_ID, 
		"org.eclipse.pde.ManifestBuilder",
		"org.eclipse.pde.SchemaBuilder",
		XtextProjectHelper.BUILDER_ID);
	projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID);
	IProject result = projectFactory.createProject(new NullProgressMonitor(), null);
	JavaProjectSetupUtil.setUnixLineEndings(result);
	return result;
}
 
Example 2
Source File: XtextContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void doSetupProject() throws Exception{
	if(project == null){
		with(doGetSetup());
		PluginProjectFactory projectFactory = getInjector().getInstance(PluginProjectFactory.class);
		projectFactory.setProjectName(TEST_PROJECT);
		projectFactory.addFolders(Collections.singletonList("src"));
		projectFactory.addBuilderIds(XtextProjectHelper.BUILDER_ID, JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder",
				"org.eclipse.pde.SchemaBuilder");
		projectFactory.addProjectNatures(
				XtextProjectHelper.NATURE_ID, JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature");
		projectFactory.addRequiredBundles(Lists.newArrayList("org.eclipse.xtext"));
		project = projectFactory.createProject(new NullProgressMonitor(), null);
		get(SyncUtil.class).waitForBuild(new NullProgressMonitor());
	}
}
 
Example 3
Source File: DisabledBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private IProject createPluginProject(String name, boolean addBuilder, String dependency) throws CoreException {
	PluginProjectFactory projectFactory = projectFactoryProvider.get();
	projectFactory.setProjectName(name);
	projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
	projectFactory.addFolders(Collections.singletonList("src"));
	projectFactory.addBuilderIds(JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder",
			"org.eclipse.pde.SchemaBuilder");
	if (addBuilder) {
		projectFactory.addBuilderIds(XtextProjectHelper.BUILDER_ID);
	}
	projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature",
			XtextProjectHelper.NATURE_ID);
	projectFactory.addRequiredBundles(Collections.singletonList("org.eclipse.emf.ecore"));
	if(dependency != null)
		projectFactory.addRequiredBundles(Collections.singletonList(dependency));
	IProject result = projectFactory.createProject(new NullProgressMonitor(), null);
	return result;
}
 
Example 4
Source File: AbstractXbaseUITestCase.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static IProject createPluginProject(String name) throws CoreException {
	Injector injector = XbaseActivator.getInstance().getInjector("org.eclipse.xtext.xbase.Xbase");
	PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class);
	projectFactory.setProjectName(name);
	projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
	projectFactory.addFolders(Collections.singletonList("src"));
	projectFactory.addBuilderIds(
		JavaCore.BUILDER_ID, 
		"org.eclipse.pde.ManifestBuilder",
		"org.eclipse.pde.SchemaBuilder",
		XtextProjectHelper.BUILDER_ID);
	projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID);
	projectFactory.addRequiredBundles(Collections.singletonList("org.eclipse.xtext.xbase.lib"));
	IProject result = projectFactory.createProject(new NullProgressMonitor(), null);
	JavaProjectSetupUtil.makeJava8Compliant(JavaCore.create(result));
	JavaProjectSetupUtil.setUnixLineEndings(result);
	return result;
}
 
Example 5
Source File: WorkbenchTestHelper.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static IProject createPluginProject(String name, JavaVersion javaVersion, String... requiredBundles) throws CoreException {
	Injector injector = XtendActivator.getInstance().getInjector(XtendActivator.ORG_ECLIPSE_XTEND_CORE_XTEND);
	PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class);
	projectFactory.setProjectName(name);
	projectFactory.setProjectDefaultCharset(StandardCharsets.ISO_8859_1.name());
	projectFactory.setBreeToUse(getBree(javaVersion));
	projectFactory.addFolders(Collections.singletonList("src"));
	projectFactory.addBuilderIds(XtextProjectHelper.BUILDER_ID, JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder",
			"org.eclipse.pde.SchemaBuilder");
	projectFactory.addProjectNatures(
			XtextProjectHelper.NATURE_ID, JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature");
	projectFactory.addRequiredBundles(newArrayList(requiredBundles));
	IProject result = projectFactory.createProject(new NullProgressMonitor(), null);
	IJavaProject javaProject = JavaCore.create(result);
	if (javaVersion == null)
		JavaProjectSetupUtil.makeJava8Compliant(javaProject);
	else
		makeCompliantFor(javaProject, javaVersion);
	JavaProjectSetupUtil.addJreClasspathEntry(javaProject);
	return result;
}
 
Example 6
Source File: ContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static IProject createPluginProject(String name) throws CoreException {
	Injector injector = XtendActivator.getInstance().getInjector("org.eclipse.xtend.core.Xtend");
	PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class);
	projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
	projectFactory.setProjectName(name);
	projectFactory.setProjectDefaultCharset(StandardCharsets.ISO_8859_1.name());
	projectFactory.addFolders(Collections.singletonList("src"));
	projectFactory.addBuilderIds(
		JavaCore.BUILDER_ID, 
		"org.eclipse.pde.ManifestBuilder",
		"org.eclipse.pde.SchemaBuilder",
		XtextProjectHelper.BUILDER_ID);
	projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID);
	projectFactory.addRequiredBundles(Lists.newArrayList(
			"org.eclipse.xtext.xbase.lib",
			"org.eclipse.xtend.lib"));
	IProject result = projectFactory.createProject(new NullProgressMonitor(), null);
	JavaProjectSetupUtil.makeJava8Compliant(JavaCore.create(result));
	return result;
}
 
Example 7
Source File: SameClassNamesTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public IProject createPluginProject(final String name, final String... requiredBundles) throws CoreException {
  final PluginProjectFactory projectFactory = this.projectFactoryProvider.get();
  projectFactory.setProjectName(name);
  projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
  projectFactory.addFolders(Collections.<String>singletonList("src"));
  projectFactory.addBuilderIds(
    XtextProjectHelper.BUILDER_ID, 
    JavaCore.BUILDER_ID, 
    "org.eclipse.pde.ManifestBuilder", 
    "org.eclipse.pde.SchemaBuilder");
  projectFactory.addProjectNatures(
    XtextProjectHelper.NATURE_ID, JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature");
  projectFactory.addRequiredBundles(((List<String>)Conversions.doWrapArray(requiredBundles)));
  projectFactory.addExportedPackages(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("com.acme")));
  NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
  final IProject result = projectFactory.createProject(_nullProgressMonitor, null);
  final IJavaProject javaProject = JavaCore.create(result);
  WorkbenchTestHelper.makeCompliantFor(javaProject, JavaVersion.JAVA8);
  JavaProjectSetupUtil.addJreClasspathEntry(javaProject);
  return result;
}
 
Example 8
Source File: AutoEditTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected IProject createPluginProject(String name) throws CoreException {
	Injector injector = org.eclipse.xtext.ui.tests.internal.TestsActivator.getInstance().getInjector("org.eclipse.xtext.ui.tests.editor.bracketmatching.BmTestLanguage");
	PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class);
	projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
	projectFactory.setProjectName(name);
	projectFactory.addFolders(Collections.singletonList("src"));
	projectFactory.addBuilderIds(XtextProjectHelper.BUILDER_ID);
	projectFactory.addProjectNatures(XtextProjectHelper.NATURE_ID);
	IProject result = projectFactory.createProject(new NullProgressMonitor(), null);
	JavaProjectSetupUtil.setUnixLineEndings(result);
	return result;
}
 
Example 9
Source File: Bug369087Test.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected static IProject createPluginProject(String name) throws CoreException {
	Injector injector = TestlanguagesActivator.getInstance().getInjector(TestlanguagesActivator.ORG_ECLIPSE_XTEXT_TESTLANGUAGES_XTEXTGRAMMAR_XTEXTGRAMMARTESTLANGUAGE);
	PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class);
	projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
	projectFactory.setProjectName(name);
	projectFactory.addFolders(Collections.singletonList("src"));
	projectFactory.addBuilderIds(XtextProjectHelper.BUILDER_ID);
	projectFactory.addProjectNatures(XtextProjectHelper.NATURE_ID);
	IProject result = projectFactory.createProject(new NullProgressMonitor(), null);
	JavaProjectSetupUtil.setUnixLineEndings(result);
	return result;
}
 
Example 10
Source File: XtextProjectCreator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private IProject createPluginProject(ProjectDescriptor descriptor, SubMonitor monitor) {
	PluginProjectFactory factory = pluginProjectProvider.get();
	configureJavaProject(descriptor, factory);
	factory.addProjectNatures("org.eclipse.pde.PluginNature");
	factory.addBuilderIds("org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder");
	factory.addDevelopmentTimeBundles(Lists.newArrayList(descriptor.getDevelopmentBundles()));
	factory.addImportedPackages(Lists.newArrayList(descriptor.getImportedPackages()));
	factory.addRequiredBundles(Lists.newArrayList(descriptor.getRequiredBundles()));
	factory.setBreeToUse(descriptor.getBree());
	return factory.createProject(monitor, null);
}
 
Example 11
Source File: Bug334456Test.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private IProject createPluginProject(String name) throws CoreException {
	PluginProjectFactory projectFactory = projectFactoryProvider.get();
	projectFactory.setProjectName(name);
	projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
	projectFactory.addFolders(Collections.singletonList("src"));
	projectFactory.addBuilderIds(
		JavaCore.BUILDER_ID, 
		"org.eclipse.pde.ManifestBuilder",
		"org.eclipse.pde.SchemaBuilder",
		XtextProjectHelper.BUILDER_ID);
	projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID);
	projectFactory.addRequiredBundles(Collections.singletonList("org.eclipse.xtext"));
	IProject result = projectFactory.createProject(new NullProgressMonitor(), null);
	return result;
}
 
Example 12
Source File: AutoEditTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected IProject createPluginProject(String name) throws CoreException {
	final IProject[] result = new IProject[1];
	IWorkspaceRunnable creatorTask = new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			Injector injector = XtendActivator.getInstance().getInjector("org.eclipse.xtend.core.Xtend");
			PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class);
			projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE);
			projectFactory.setProjectName(name);
			projectFactory.setProjectDefaultCharset(StandardCharsets.ISO_8859_1.name());
			projectFactory.addFolders(Collections.singletonList("src"));
			projectFactory.addBuilderIds(
				JavaCore.BUILDER_ID, 
				"org.eclipse.pde.ManifestBuilder",
				"org.eclipse.pde.SchemaBuilder",
				XtextProjectHelper.BUILDER_ID);
			projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID);
			projectFactory.addRequiredBundles(newArrayList("org.eclipse.xtext.xbase.lib"));
			IProject project = projectFactory.createProject(new NullProgressMonitor(), null);
			JavaProjectSetupUtil.setUnixLineEndings(project);
			
			result[0] = project;
		}
	};
	ResourcesPlugin.getWorkspace().run(creatorTask, new NullProgressMonitor());
	return result[0];
}