Example usage for org.eclipse.jdt.core IJavaProject setOutputLocation

List of usage examples for org.eclipse.jdt.core IJavaProject setOutputLocation

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaProject setOutputLocation.

Prototype

void setOutputLocation(IPath path, IProgressMonitor monitor) throws JavaModelException;

Source Link

Document

Sets the default output location of this project to the location described by the given workspace-relative absolute path.

Usage

From source file:org.eclipse.mylyn.reviews.r4e.ui.tests.utils.TestUtils.java

License:Open Source License

private static IJavaProject setProjectAsJava(IProject aProject) throws CoreException, IOException {
    IJavaProject javaProject = JavaCore.create(aProject);

    IFolder binFolder = aProject.getFolder("bin");
    binFolder.create(false, true, null);

    IProjectDescription description = aProject.getDescription();
    description.setNatureIds(new String[] { JavaCore.NATURE_ID });
    aProject.setDescription(description, null);

    javaProject.setRawClasspath(new IClasspathEntry[0], null);
    IPath outputLocation = binFolder.getFullPath();
    javaProject.setOutputLocation(outputLocation, null);

    IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
    IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
    System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
    newEntries[oldEntries.length] = JavaRuntime.getDefaultJREContainerEntry();
    javaProject.setRawClasspath(newEntries, null);
    return javaProject;
}

From source file:org.eclipse.objectteams.otdt.ui.tests.util.JavaProjectHelper.java

License:Open Source License

/**
 * OT: new method: OT specific project creation.
 * Creates a IJavaProject.//from  w  w  w .  j  a va 2 s . com
 */
public static IJavaProject createOTJavaProject(String projectName, String binFolderName) throws CoreException {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = root.getProject(projectName);
    if (!project.exists()) {
        project.create(null);
    } else {
        project.refreshLocal(IResource.DEPTH_INFINITE, null);
    }

    if (!project.isOpen()) {
        project.open(null);
    }

    IPath outputLocation;
    if (binFolderName != null && binFolderName.length() > 0) {
        IFolder binFolder = project.getFolder(binFolderName);
        if (!binFolder.exists()) {
            CoreUtility.createFolder(binFolder, false, true, null);
        }
        outputLocation = binFolder.getFullPath();
    } else {
        outputLocation = project.getFullPath();
    }

    if (!project.hasNature(JavaCore.NATURE_ID) && !project.hasNature(JavaCore.OTJ_NATURE_ID)) {
        addNatureToProject(project, JavaCore.NATURE_ID, null);
        //add OT nature to project
        addNatureToProject(project, JavaCore.OTJ_NATURE_ID, null);
    }
    IProjectDescription description = project.getDescription();
    //add OT build spec to project
    description.setBuildSpec(OTDTPlugin.createProjectBuildCommands(description));
    project.setDescription(description, null);

    IJavaProject jproject = JavaCore.create(project);

    jproject.setOutputLocation(outputLocation, null);
    jproject.setRawClasspath(new IClasspathEntry[0], null);

    OTREContainer.initializeOTJProject(project);

    return jproject;
}

From source file:org.eclipse.pde.api.tools.tests.util.ProjectUtils.java

License:Open Source License

/**
 * creates a java project with the specified name and additional project
 * natures// w w w. j  av  a2  s .  com
 * 
 * @param projectName
 * @param additionalNatures
 * @return a new java project
 * @throws CoreException
 */
public static IJavaProject createJavaProject(String projectName, String[] additionalNatures)
        throws CoreException {
    IProgressMonitor monitor = new NullProgressMonitor();
    IProject project = createProject(projectName, monitor);
    if (!project.hasNature(JavaCore.NATURE_ID)) {
        addNatureToProject(project, JavaCore.NATURE_ID, monitor);
    }
    if (additionalNatures != null) {
        for (int i = 0; i < additionalNatures.length; i++) {
            addNatureToProject(project, additionalNatures[i], monitor);
        }
    }
    IJavaProject jproject = JavaCore.create(project);
    jproject.setOutputLocation(getDefaultProjectOutputLocation(project), monitor);
    jproject.setRawClasspath(new IClasspathEntry[0], monitor);
    addContainerEntry(jproject, JavaRuntime.newDefaultJREContainerPath());
    return jproject;
}

From source file:org.eclipse.pde.api.tools.util.tests.ApiBaselineManagerTests.java

License:Open Source License

/**
 * Tests that changing the output folder settings for a project cause the
 * class file containers to be updated/*from w w  w . j a  va2  s  .  c om*/
 */
public void testWPUpdateDefaultOutputFolderChanged() throws Exception {
    IJavaProject project = getTestingProject();
    assertNotNull("The testing project must exist", project); //$NON-NLS-1$
    IContainer container = ProjectUtils.addFolderToProject(project.getProject(), "bin2"); //$NON-NLS-1$
    assertNotNull("the new output folder cannot be null", container); //$NON-NLS-1$
    IApiComponent component = getWorkspaceBaseline().getApiComponent(project.getElementName());
    assertNotNull("the workspace component must exist", component); //$NON-NLS-1$
    int before = component.getApiTypeContainers().length;
    project.setOutputLocation(container.getFullPath(), new NullProgressMonitor());
    waitForAutoBuild();
    assertTrue("there must be the same number of containers after the change", //$NON-NLS-1$
            before == component.getApiTypeContainers().length);
    assertTrue("the new output location should be 'bin2'", //$NON-NLS-1$
            "bin2".equalsIgnoreCase(project.getOutputLocation().toFile().getName())); //$NON-NLS-1$
}

From source file:org.eclipse.pde.internal.core.project.ProjectModifyOperation.java

License:Open Source License

/**
 * Configures the build path and output location of the described Java project.
 * If the Java project existed before this operation, new build path entries are
 * added for the bundle class path, if required, but we don't change the exiting
 * build path.//from w  w  w. j  av  a2 s .  co m
 * 
 * @param description desired project description
 * @param before state before the operation
 * @param existed whether the Java project existed before the operation
 */
private void configureJavaProject(IBundleProjectDescription description, IBundleProjectDescription before,
        boolean existed) throws CoreException {
    IProject project = description.getProject();
    IJavaProject javaProject = JavaCore.create(project);
    // create source folders as required
    IBundleClasspathEntry[] bces = description.getBundleClasspath();
    if (bces != null && bces.length > 0) {
        for (int i = 0; i < bces.length; i++) {
            IPath folder = bces[i].getSourcePath();
            if (folder != null) {
                CoreUtility.createFolder(project.getFolder(folder));
            }
        }
    }
    // Set default output folder
    if (description.getDefaultOutputFolder() != null) {
        IPath path = project.getFullPath().append(description.getDefaultOutputFolder());
        javaProject.setOutputLocation(path, null);
    }

    // merge the class path if the project existed before
    IBundleClasspathEntry[] prev = before.getBundleClasspath();
    if (!isEqual(bces, prev)) {
        if (existed) {
            // add entries not already present
            IClasspathEntry[] entries = getSourceFolderEntries(javaProject, description);
            IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
            List<IClasspathEntry> add = new ArrayList<IClasspathEntry>();
            for (int i = 0; i < entries.length; i++) {
                IClasspathEntry entry = entries[i];
                boolean present = false;
                for (int j = 0; j < rawClasspath.length; j++) {
                    IClasspathEntry existingEntry = rawClasspath[j];
                    if (existingEntry.getEntryKind() == entry.getEntryKind()) {
                        if (existingEntry.getPath().equals(entry.getPath())) {
                            present = true;
                            break;
                        }
                    }
                }
                if (!present) {
                    add.add(entry);
                }
            }
            // check if the 'required plug-ins' container is present
            boolean addRequired = false;
            if (description.hasNature(IBundleProjectDescription.PLUGIN_NATURE)) {
                addRequired = true;
                for (int i = 0; i < rawClasspath.length; i++) {
                    IClasspathEntry cpe = rawClasspath[i];
                    if (cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
                        if (PDECore.REQUIRED_PLUGINS_CONTAINER_PATH.equals(cpe.getPath())) {
                            addRequired = false;
                            break;
                        }
                    }
                }
            }
            if (addRequired) {
                add.add(ClasspathComputer.createContainerEntry());
            }
            if (!add.isEmpty()) {
                List<IClasspathEntry> all = new ArrayList<IClasspathEntry>();
                for (int i = 0; i < rawClasspath.length; i++) {
                    all.add(rawClasspath[i]);
                }
                all.addAll(add);
                javaProject.setRawClasspath(all.toArray(new IClasspathEntry[all.size()]), null);
            }
        } else {
            IClasspathEntry[] entries = getClassPathEntries(javaProject, description);
            javaProject.setRawClasspath(entries, null);
        }
    }
}

From source file:org.eclipse.pde.internal.core.SearchablePluginsManager.java

License:Open Source License

public IProject createProxyProject(IProgressMonitor monitor) throws CoreException {
    IWorkspaceRoot root = PDECore.getWorkspace().getRoot();
    IProject project = root.getProject(SearchablePluginsManager.PROXY_PROJECT_NAME);
    if (project.exists()) {
        if (!project.isOpen()) {
            project.open(monitor);/*  ww w  .ja  v  a  2 s.  c om*/
        }
        return project;
    }

    monitor.beginTask(NLS.bind(PDECoreMessages.SearchablePluginsManager_createProjectTaskName,
            SearchablePluginsManager.PROXY_PROJECT_NAME), 5);
    project.create(new SubProgressMonitor(monitor, 1));
    project.open(new SubProgressMonitor(monitor, 1));
    CoreUtility.addNatureToProject(project, JavaCore.NATURE_ID, new SubProgressMonitor(monitor, 1));
    IJavaProject jProject = JavaCore.create(project);
    jProject.setOutputLocation(project.getFullPath(), new SubProgressMonitor(monitor, 1));
    computeClasspath(jProject, new SubProgressMonitor(monitor, 1));
    return project;
}

From source file:org.eclipse.pde.internal.ui.wizards.feature.AbstractCreateFeatureOperation.java

License:Open Source License

private void createProject(IProgressMonitor monitor) throws CoreException {
    CoreUtility.createProject(fProject, fLocation, monitor);
    fProject.open(monitor);//from  ww  w . ja  v  a  2s  .c  o m
    IProjectDescription desc = fProject.getWorkspace().newProjectDescription(fProject.getName());
    desc.setLocation(fLocation);
    if (!fProject.hasNature(PDE.FEATURE_NATURE))
        CoreUtility.addNatureToProject(fProject, PDE.FEATURE_NATURE, monitor);

    if (fFeatureData.hasCustomHandler()) {
        if (!fProject.hasNature(JavaCore.NATURE_ID))
            CoreUtility.addNatureToProject(fProject, JavaCore.NATURE_ID, monitor);

        if (fFeatureData.getSourceFolderName() != null
                && fFeatureData.getSourceFolderName().trim().length() > 0) {
            IFolder folder = fProject.getFolder(fFeatureData.getSourceFolderName());
            if (!folder.exists())
                CoreUtility.createFolder(folder);
        }

        IJavaProject jproject = JavaCore.create(fProject);
        jproject.setOutputLocation(fProject.getFullPath().append(fFeatureData.getJavaBuildFolderName()),
                monitor);
        jproject.setRawClasspath(new IClasspathEntry[] {
                JavaCore.newSourceEntry(fProject.getFullPath().append(fFeatureData.getSourceFolderName())),
                JavaCore.newContainerEntry(new Path(JavaRuntime.JRE_CONTAINER)) }, monitor);
    }
}

From source file:org.eclipse.pde.ui.tests.project.ProjectCreationTests.java

License:Open Source License

/**
 * Convert an existing Java project into a bundle project. Ensure it's build path
 * doesn't get toasted in the process.// w  ww .  j  a v  a  2 s  .  c o m
 * 
 * @throws CoreException
 */
public void testJavaToBundle() throws CoreException {
    // create a Java project
    String name = getName().toLowerCase().substring(4);
    name = "test." + name;
    IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
    assertFalse("Project should not exist", proj.exists());
    proj.create(null);
    proj.open(null);
    IProjectDescription pd = proj.getDescription();
    pd.setNatureIds(new String[] { JavaCore.NATURE_ID });
    proj.setDescription(pd, null);
    IFolder src = proj.getFolder("someSrc");
    src.create(false, true, null);
    IFolder output = proj.getFolder("someBin");
    output.create(false, true, null);
    IJavaProject javaProject = JavaCore.create(proj);
    javaProject.setOutputLocation(output.getFullPath(), null);
    IClasspathEntry entry1 = JavaCore.newSourceEntry(src.getFullPath());
    IClasspathEntry entry2 = JavaCore.newContainerEntry(JavaRuntime
            .newJREContainerPath(JavaRuntime.getExecutionEnvironmentsManager().getEnvironment("J2SE-1.4")));
    IClasspathEntry entry3 = JavaCore.newContainerEntry(ClasspathContainerInitializer.PATH);
    javaProject.setRawClasspath(new IClasspathEntry[] { entry1, entry2, entry3 }, null);

    // convert to a bundle
    IBundleProjectDescription description = getBundleProjectService().getDescription(proj);
    assertTrue("Missing Java Nature", description.hasNature(JavaCore.NATURE_ID));
    description.setSymbolicName(proj.getName());
    description.setNatureIds(new String[] { IBundleProjectDescription.PLUGIN_NATURE, JavaCore.NATURE_ID });
    IBundleClasspathEntry entry = getBundleProjectService()
            .newBundleClasspathEntry(src.getProjectRelativePath(), null, null);
    description.setBundleClasspath(new IBundleClasspathEntry[] { entry });
    description.apply(null);

    // validate
    IBundleProjectDescription d2 = getBundleProjectService().getDescription(proj);
    assertEquals("Wrong symbolic name", proj.getName(), d2.getSymbolicName());
    String[] natureIds = d2.getNatureIds();
    assertEquals("Wrong number of natures", 2, natureIds.length);
    assertEquals("Wrong nature", IBundleProjectDescription.PLUGIN_NATURE, natureIds[0]);
    assertTrue("Nature should be present", d2.hasNature(IBundleProjectDescription.PLUGIN_NATURE));
    assertEquals("Wrong nature", JavaCore.NATURE_ID, natureIds[1]);
    // execution environment should be that on the Java build path
    String[] ees = d2.getExecutionEnvironments();
    assertNotNull("Missing EEs", ees);
    assertEquals("Wrong number of EEs", 1, ees.length);
    assertEquals("Wrong EE", "J2SE-1.4", ees[0]);
    // version
    assertEquals("Wrong version", "1.0.0.qualifier", d2.getBundleVersion().toString());

    IBundleClasspathEntry[] classpath = d2.getBundleClasspath();
    assertEquals("Wrong number of Bundle-Classpath entries", 1, classpath.length);
    assertEquals("Wrong Bundle-Classpath entry", getBundleProjectService()
            .newBundleClasspathEntry(src.getProjectRelativePath(), null, new Path(".")), classpath[0]);

    // raw class path should still be intact
    IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
    assertEquals("Wrong number of entries", 4, rawClasspath.length);
    assertEquals("Wrong entry", entry1, rawClasspath[0]);
    assertEquals("Wrong entry", entry2, rawClasspath[1]);
    assertEquals("Wrong entry", entry3, rawClasspath[2]);
    assertEquals("Missing Required Plug-ins Container", ClasspathComputer.createContainerEntry(),
            rawClasspath[3]);
}

From source file:org.eclipse.titan.codegenerator.AstWalkerJava.java

License:Open Source License

public void run(IAction action) {

    /**///from ww w .j a  v a  2 s .co  m
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (IProject p : projects) {
        if (p.getName().equals("org.eclipse.titan.codegenerator.output"))
            try {
                p.delete(true, true, null);
            } catch (Exception e) {
                e.printStackTrace();
            }
    }
    IProject project = ResourcesPlugin.getWorkspace().getRoot()
            .getProject("org.eclipse.titan.codegenerator.output");
    try {
        project.create(null);
        project.open(null);
        IProjectDescription description = project.getDescription();
        description.setNatureIds(new String[] { JavaCore.NATURE_ID });
        project.setDescription(description, null);
        IJavaProject javaProject = JavaCore.create(project);
        IFolder binFolder = project.getFolder("bin");
        binFolder.create(false, true, null);
        javaProject.setOutputLocation(binFolder.getFullPath(), null);
        List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
        IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
        LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
        for (LibraryLocation element : locations) {
            entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
        }
        javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
        IFolder sourceFolder = project.getFolder("src");
        sourceFolder.create(false, true, null);
        IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(sourceFolder);
        IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
        IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
        System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
        newEntries[oldEntries.length] = JavaCore.newSourceEntry(root.getPath());
        javaProject.setRawClasspath(newEntries, null);
        javaProject.getPackageFragmentRoot(sourceFolder)
                .createPackageFragment("org.eclipse.titan.codegenerator.javagen", false, null);
        javaProject.getPackageFragmentRoot(sourceFolder)
                .createPackageFragment("org.eclipse.titan.codegenerator.TTCN3JavaAPI", false, null);
    } catch (Exception e) {
        e.printStackTrace();
    }

    String destpath = new String("");
    String wspath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString().replaceAll("/", "\\\\");
    destpath += wspath;
    destpath += "\\org.eclipse.titan.codegenerator.output\\src\\org\\eclipse\\titan\\codegenerator\\javagen\\";
    props.setProperty("javafile.path", destpath);
    /**/

    AstWalkerJava.files.clear();
    AstWalkerJava.fileNames.clear();
    AstWalkerJava.componentList.clear();
    AstWalkerJava.testCaseList.clear();
    AstWalkerJava.testCaseRunsOnList.clear();
    AstWalkerJava.functionList.clear();
    AstWalkerJava.functionRunsOnList.clear();

    AstWalkerJava.initOutputFolder();
    AstWalkerJava.getActiveProject();

    /*
     * // init console logger IConsole myConsole = findConsole("myLogger");
     * IWorkbenchPage page = window.getActivePage(); String id =
     * IConsoleConstants.ID_CONSOLE_VIEW; IConsoleView view; try { view =
     * (IConsoleView) page.showView(id); view.display(myConsole); } catch
     * (PartInitException e) { // TODO Auto-generated catch block
     * e.printStackTrace(); }
     */

    // initialize common files

    myASTVisitor.currentFileName = "TTCN_functions";

    myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
    myASTVisitor.visualizeNodeToJava("class TTCN_functions{\r\n}\r\n");

    Def_Template_Visit_Handler.isTemplate = false;

    final ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(selectedProject);
    sourceParser.analyzeAll();

    logToConsole("Version built on 2016.10.24");
    logToConsole("Starting to generate files into: " + props.getProperty("javafile.path"));

    myASTVisitor visitor = new myASTVisitor();
    for (Module module : sourceParser.getModules()) {
        // start AST processing
        walkChildren(visitor, module.getOutlineChildren());
    }
    visitor.finish();

    logToConsole("Files generated into: " + props.getProperty("javafile.path"));

    // write additional classes
    Additional_Class_Writer additional_class = new Additional_Class_Writer();
    myASTVisitor.currentFileName = "HC";

    myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
    myASTVisitor.visualizeNodeToJava(additional_class.writeHCClass());

    myASTVisitor.currentFileName = "HCType";
    myASTVisitor.visualizeNodeToJava(myASTVisitor.importListStrings);
    myASTVisitor.visualizeNodeToJava(additional_class.writeHCTypeClass());

    // clear lists

    logger.severe("analysis complete");

    /**/
    File fromdir = new File(wspath
            + "\\org.eclipse.titan.codegenerator\\src\\org\\eclipse\\titan\\codegenerator\\TTCN3JavaAPI\\");
    String toapidir = wspath
            + "\\org.eclipse.titan.codegenerator.output\\src\\org\\eclipse\\titan\\codegenerator\\TTCN3JavaAPI\\";
    File[] fromfiles = fromdir.listFiles();
    for (File f : fromfiles) {
        try {
            Files.copy(Paths.get(f.getAbsolutePath()), Paths.get(toapidir + f.getName()),
                    StandardCopyOption.REPLACE_EXISTING);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    String tppath = wspath + "\\" + selectedProject.getFullPath().toString().split("/")[1] + "\\src\\";
    File tp_cfg_dir = new File(tppath);
    String togendir = wspath
            + "\\org.eclipse.titan.codegenerator.output\\src\\org\\eclipse\\titan\\codegenerator\\javagen\\";
    File[] from_testports_cfg = tp_cfg_dir.listFiles();
    for (File f : from_testports_cfg) {
        if (f.getName().endsWith(".java")) {
            try {
                Files.copy(Paths.get(f.getAbsolutePath()), Paths.get(togendir + f.getName()),
                        StandardCopyOption.REPLACE_EXISTING);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (f.getName().endsWith(".cfg")) {
            try {
                Files.copy(Paths.get(f.getAbsolutePath()), Paths.get(toapidir + "cfg.cfg"),
                        StandardCopyOption.REPLACE_EXISTING);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    try {
        ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE,
                new NullProgressMonitor());
    } catch (Exception e) {
        e.printStackTrace();
    }
    /**/

}

From source file:org.eclipse.umlgen.gen.java.services.WorkspaceServices.java

License:Open Source License

/**
 * Creates a project from scratch in the workspace.
 *
 * @param eObject/*from w  ww.  j a v  a 2  s.  c  o  m*/
 *            The model element
 */
public void createDefaultProject(EObject eObject) {
    if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
        return;
    }

    IProgressMonitor monitor = new NullProgressMonitor();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    try {
        IWorkspaceRoot workspaceRoot = workspace.getRoot();

        String projectName = UML2JavaConfigurationHolder.getDefaultProjectName(eObject);
        IProject project = workspaceRoot.getProject(projectName);

        if (project.exists() && project.isAccessible()) {
            if (!project.isOpen()) {
                project.open(monitor);
            }
        } else {
            project.create(new NullProgressMonitor());
            project.open(new NullProgressMonitor());

            IContainer intputContainer = project;

            String sourceFolderName = UML2JavaConfigurationHolder.getSourceFolderPath(eObject);
            StringTokenizer stringTokenizer = new StringTokenizer(sourceFolderName, "/");
            while (stringTokenizer.hasMoreTokens()) {
                String token = stringTokenizer.nextToken();
                IFolder src = intputContainer.getFolder(new Path(token));
                if (!src.exists()) {
                    src.create(true, true, monitor);
                }

                intputContainer = src;
            }

            IContainer outputContainer = project;

            String outputFolderName = UML2JavaConfigurationHolder.getOutputFolderPath(eObject);
            stringTokenizer = new StringTokenizer(outputFolderName, "/");
            while (stringTokenizer.hasMoreTokens()) {
                String token = stringTokenizer.nextToken();
                IFolder out = outputContainer.getFolder(new Path(token));
                if (!out.exists()) {
                    out.create(true, true, monitor);
                }

                outputContainer = out;
            }

            IProjectDescription description = project.getDescription();
            String[] natures = new String[] {};
            if (IUML2JavaConstants.Default.DEFAULT_COMPONENT_ARTIFACTS_TYPE_OSGI
                    .equals(UML2JavaConfigurationHolder.getComponentBasedArchitecture(eObject))
                    || IUML2JavaConstants.Default.DEFAULT_COMPONENT_ARTIFACTS_TYPE_ECLIPSE
                            .equals(UML2JavaConfigurationHolder.getComponentBasedArchitecture(eObject))) {
                natures = new String[] { JavaCore.NATURE_ID, IUML2JavaConstants.PDE_PLUGIN_NATURE_ID };
            } else {
                natures = new String[] { JavaCore.NATURE_ID, };
            }
            description.setNatureIds(natures);
            project.setDescription(description, monitor);

            IJavaProject javaProject = JavaCore.create(project);

            List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
            IExecutionEnvironmentsManager executionEnvironmentsManager = JavaRuntime
                    .getExecutionEnvironmentsManager();
            IExecutionEnvironment[] executionEnvironments = executionEnvironmentsManager
                    .getExecutionEnvironments();

            String defaultJREExecutionEnvironment = UML2JavaConfigurationHolder
                    .getJREExecutionEnvironment(eObject);
            for (IExecutionEnvironment iExecutionEnvironment : executionEnvironments) {
                if (defaultJREExecutionEnvironment.equals(iExecutionEnvironment.getId())) {
                    entries.add(
                            JavaCore.newContainerEntry(JavaRuntime.newJREContainerPath(iExecutionEnvironment)));
                    break;
                }
            }

            javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);

            IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
            IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
            System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);

            javaProject.setOutputLocation(outputContainer.getFullPath(), monitor);

            IPackageFragmentRoot packageRoot = javaProject
                    .getPackageFragmentRoot(intputContainer.getFullPath().toString());
            newEntries[oldEntries.length] = JavaCore.newSourceEntry(packageRoot.getPath(), new Path[] {},
                    new Path[] {}, outputContainer.getFullPath());

            javaProject.setRawClasspath(newEntries, null);

            IFile buildPropertiesFile = project.getFile("build.properties");
            if (!buildPropertiesFile.exists()) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append(
                        "#################################################################################"
                                + System.getProperty(LINE_SEPARATOR));
                stringBuilder.append("## " + UML2JavaConfigurationHolder.getCopyrightAndLicense(eObject)
                        + System.getProperty(LINE_SEPARATOR));
                stringBuilder.append(
                        "#################################################################################"
                                + System.getProperty(LINE_SEPARATOR));
                stringBuilder.append("source.. = " + UML2JavaConfigurationHolder.getSourceFolderPath(eObject)
                        + System.getProperty(LINE_SEPARATOR));
                stringBuilder.append("output.. = " + UML2JavaConfigurationHolder.getOutputFolderPath(eObject)
                        + System.getProperty(LINE_SEPARATOR));
                stringBuilder.append("" + System.getProperty(LINE_SEPARATOR));
                buildPropertiesFile.create(new ByteArrayInputStream(stringBuilder.toString().getBytes()), true,
                        monitor);
            }
        }
    } catch (CoreException coreException) {
        AcceleoEnginePlugin.log(coreException, true);
    }
}