Search in sources :

Example 6 with ICommand

use of org.eclipse.core.resources.ICommand in project xtext-xtend by eclipse.

the class PerformanceTestProjectSetup method createJavaProject.

public static IJavaProject createJavaProject(final String projectName, String[] projectNatures) {
    IProject project = null;
    IJavaProject javaProject = null;
    try {
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        project = workspace.getRoot().getProject(projectName);
        deleteProject(project);
        javaProject = JavaCore.create(project);
        IProjectDescription projectDescription = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
        project.create(projectDescription, null);
        List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
        projectDescription.setNatureIds(projectNatures);
        final ICommand java = projectDescription.newCommand();
        java.setBuilderName(JavaCore.BUILDER_ID);
        final ICommand manifest = projectDescription.newCommand();
        manifest.setBuilderName("org.eclipse.pde.ManifestBuilder");
        final ICommand schema = projectDescription.newCommand();
        schema.setBuilderName("org.eclipse.pde.SchemaBuilder");
        projectDescription.setBuildSpec(new ICommand[] { java, manifest, schema });
        project.open(null);
        project.setDescription(projectDescription, null);
        classpathEntries.add(JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5")));
        classpathEntries.add(JavaCore.newContainerEntry(new Path("org.eclipse.pde.core.requiredPlugins")));
        javaProject.setRawClasspath(classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]), null);
        makeJava5Compliant(javaProject);
        javaProject.setOutputLocation(new Path("/" + projectName + "/bin"), null);
        createManifest(projectName, project);
        // project.build(IncrementalProjectBuilder.FULL_BUILD, null);
        refreshExternalArchives(javaProject);
        refresh(javaProject);
    } catch (final Exception exception) {
        throw new RuntimeException(exception);
    }
    return javaProject;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IJavaProject(org.eclipse.jdt.core.IJavaProject) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ICommand(org.eclipse.core.resources.ICommand) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) JavaModelException(org.eclipse.jdt.core.JavaModelException) CoreException(org.eclipse.core.runtime.CoreException)

Example 7 with ICommand

use of org.eclipse.core.resources.ICommand in project linuxtools by eclipse.

the class RpmlintNature method deconfigure.

@Override
public void deconfigure() throws CoreException {
    IProjectDescription description = getProject().getDescription();
    ICommand[] commands = description.getBuildSpec();
    for (int i = 0; i < commands.length; ++i) {
        if (commands[i].getBuilderName().equals(RpmlintBuilder.BUILDER_ID)) {
            ICommand[] newCommands = new ICommand[commands.length - 1];
            System.arraycopy(commands, 0, newCommands, 0, i);
            System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
            description.setBuildSpec(newCommands);
            // Remove rpmlint marks on all specfiles into the project.
            project.accept(new RpmlintMarkerRemoveVisitor());
            return;
        }
    }
}
Also used : ICommand(org.eclipse.core.resources.ICommand) IProjectDescription(org.eclipse.core.resources.IProjectDescription)

Example 8 with ICommand

use of org.eclipse.core.resources.ICommand in project eclipse-pmd by acanda.

the class PMDNature method configure.

@Override
public void configure() throws CoreException {
    final IProjectDescription desc = project.getDescription();
    final ICommand[] commands = desc.getBuildSpec();
    for (int i = 0; i < commands.length; ++i) {
        if (commands[i].getBuilderName().equals(PMDBuilder.ID)) {
            return;
        }
    }
    final ICommand[] newCommands = new ICommand[commands.length + 1];
    System.arraycopy(commands, 0, newCommands, 0, commands.length);
    final ICommand command = desc.newCommand();
    command.setBuilderName(PMDBuilder.ID);
    newCommands[newCommands.length - 1] = command;
    desc.setBuildSpec(newCommands);
    project.setDescription(desc, null);
}
Also used : ICommand(org.eclipse.core.resources.ICommand) IProjectDescription(org.eclipse.core.resources.IProjectDescription)

Example 9 with ICommand

use of org.eclipse.core.resources.ICommand in project jop by jop-devel.

the class JOPNature method deconfigure.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.core.resources.IProjectNature#deconfigure()
     */
public void deconfigure() throws CoreException {
    IProjectDescription description = getProject().getDescription();
    ICommand[] commands = description.getBuildSpec();
    for (int i = 0; i < commands.length; ++i) {
        if (commands[i].getBuilderName().equals(JOPizer.BUILDER_ID)) {
            ICommand[] newCommands = new ICommand[commands.length - 1];
            System.arraycopy(commands, 0, newCommands, 0, i);
            System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
            description.setBuildSpec(newCommands);
            return;
        }
    }
}
Also used : ICommand(org.eclipse.core.resources.ICommand) IProjectDescription(org.eclipse.core.resources.IProjectDescription)

Example 10 with ICommand

use of org.eclipse.core.resources.ICommand in project jop by jop-devel.

the class JOPNature method configure.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.core.resources.IProjectNature#configure()
     */
public void configure() throws CoreException {
    IProjectDescription desc = project.getDescription();
    ICommand[] commands = desc.getBuildSpec();
    for (int i = 0; i < commands.length; ++i) {
        if (commands[i].getBuilderName().equals(JOPizer.BUILDER_ID)) {
            return;
        }
    }
    ICommand[] newCommands = new ICommand[commands.length + 1];
    System.arraycopy(commands, 0, newCommands, 0, commands.length);
    ICommand command = desc.newCommand();
    command.setBuilderName(JOPizer.BUILDER_ID);
    newCommands[newCommands.length - 1] = command;
    desc.setBuildSpec(newCommands);
    project.setDescription(desc, null);
}
Also used : ICommand(org.eclipse.core.resources.ICommand) IProjectDescription(org.eclipse.core.resources.IProjectDescription)

Aggregations

ICommand (org.eclipse.core.resources.ICommand)15 IProjectDescription (org.eclipse.core.resources.IProjectDescription)12 ArrayList (java.util.ArrayList)2 IProject (org.eclipse.core.resources.IProject)2 IPath (org.eclipse.core.runtime.IPath)2 URI (java.net.URI)1 List (java.util.List)1 RegisteredProject (org.eclipse.che.api.project.server.RegisteredProject)1 IBuildConfiguration (org.eclipse.core.resources.IBuildConfiguration)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 Status (org.eclipse.core.runtime.Status)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1