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

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

Introduction

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

Prototype

IPath getOutputLocation() throws JavaModelException;

Source Link

Document

Returns the default output location for this project as a workspace- relative absolute path.

Usage

From source file:org.jerry.felinx.plugin.builder.BundleBuilder.java

License:Open Source License

private File getClassesFolder(IJavaProject javaProject) throws JavaModelException {
    IPath classesFolder = javaProject.getOutputLocation();
    return new File(getProjectRoot(javaProject).getParent(), classesFolder.toOSString());
}

From source file:org.jetbrains.kotlin.core.utils.ProjectUtils.java

License:Apache License

public static IFolder getOutputFolder(@NotNull IJavaProject javaProject) {
    try {/*from   w ww  . j  a  va  2s. c o m*/
        return (IFolder) ResourcesPlugin.getWorkspace().getRoot().findMember(javaProject.getOutputLocation());
    } catch (JavaModelException e) {
        KotlinLogger.logAndThrow(e);
        throw new IllegalStateException(e);
    }
}

From source file:org.libreoffice.ide.eclipse.java.JavaProjectHandler.java

License:LGPL

/**
 * {@inheritDoc}//ww  w.  ja  v a2 s  .  co  m
 */
@Override
public IFolder[] getBinFolders(IUnoidlProject pUnoidlProject) {
    ArrayList<IFolder> folders = new ArrayList<IFolder>();

    IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
    IProject prj = workspace.getProject(pUnoidlProject.getName());
    IJavaProject javaPrj = JavaCore.create(prj);
    try {
        folders.add(workspace.getFolder(javaPrj.getOutputLocation()));

        IClasspathEntry[] entries = javaPrj.getRawClasspath();
        for (IClasspathEntry entry : entries) {
            if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getOutputLocation() != null) {
                folders.add(workspace.getFolder(entry.getOutputLocation()));
            }
        }
    } catch (JavaModelException e) {
    }

    return folders.toArray(new IFolder[folders.size()]);
}

From source file:org.maven.ide.eclipse.tests.BuildPathManagerTest.java

License:Apache License

public void _testResourceFiltering() throws Exception {
    deleteProject("MNGECLIPSE-343");
    ResolverConfiguration configuration = new ResolverConfiguration();
    IProject project = importProject("projects/MNGECLIPSE-343/pom.xml", configuration);
    project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());

    IJavaProject javaProject = JavaCore.create(project);
    IPath outputLocation = javaProject.getOutputLocation();
    Properties properties = new Properties();
    InputStream contents = workspace.getRoot().getFile(outputLocation.append("application.properties"))
            .getContents();/*from   ww w  .  j ava 2  s  . c o  m*/
    try {
        properties.load(contents);
    } finally {
        contents.close();
    }
    assertEquals("MNGECLIPSE-343 Test 001", properties.getProperty("application.name"));
    assertEquals("0.0.1-SNAPSHOT", properties.getProperty("application.version"));
}

From source file:org.mybatis.generator.eclipse.ui.actions.RunGeneratorThread.java

License:Apache License

private void setClassLoader() {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IJavaProject javaProject = getJavaProject();

    try {//from  w w w.j av  a2  s. co  m
        if (javaProject != null) {
            List<URL> entries = new ArrayList<URL>();
            IPath path = javaProject.getOutputLocation();
            IResource iResource = root.findMember(path);
            path = iResource.getLocation();
            path = path.addTrailingSeparator();
            entries.add(path.toFile().toURI().toURL());

            IClasspathEntry[] cpEntries = javaProject.getRawClasspath();
            for (IClasspathEntry cpEntry : cpEntries) {
                switch (cpEntry.getEntryKind()) {
                case IClasspathEntry.CPE_SOURCE:
                    path = cpEntry.getOutputLocation();
                    if (path != null) {
                        iResource = root.findMember(path);
                        path = iResource.getLocation();
                        path = path.addTrailingSeparator();
                        entries.add(path.toFile().toURI().toURL());
                    }
                    break;

                case IClasspathEntry.CPE_LIBRARY:
                    iResource = root.findMember(cpEntry.getPath());
                    if (iResource == null) {
                        // resource is not in workspace, must be an external JAR
                        path = cpEntry.getPath();
                    } else {
                        path = iResource.getLocation();
                    }
                    entries.add(path.toFile().toURI().toURL());
                    break;
                }
            }

            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            URL[] entryArray = new URL[entries.size()];
            entries.toArray(entryArray);
            ClassLoader newCl = new URLClassLoader(entryArray, oldCl);
            Thread.currentThread().setContextClassLoader(newCl);
            oldClassLoader = oldCl;
        }
    } catch (Exception e) {
        // ignore - something too complex is wrong
        ;
    }

}

From source file:org.neuro4j.studio.core.util.ClassloaderHelper.java

License:Apache License

/**
 * Return the location of the binary output files for the JavaProject.
 * // w  ww .  j av a 2  s.c  om
 * @param p
 *        project
 * @return path to binary output folder or <code>null</code> if not java project or other problem.
 * 
 * @since 1.0.0
 */
public static IPath getJavaProjectOutputLocation(IProject p) {
    try {
        IJavaProject javaProj = getJavaProject(p);
        if (javaProj == null)
            return null;
        if (!javaProj.isOpen())
            javaProj.open(null);
        return javaProj.getOutputLocation();
    } catch (JavaModelException e) {
        return null;
    }
}

From source file:org.nuxeo.ide.sdk.deploy.Deployment.java

License:Open Source License

protected IFolder nxdataFolder(IJavaProject project) throws JavaModelException {
    IPath outputPath = project.getOutputLocation().removeFirstSegments(1).removeLastSegments(1)
            .append("nxdata");
    return project.getProject().getFolder(outputPath);
}

From source file:org.nuxeo.ide.sdk.deploy.Deployment.java

License:Open Source License

protected void copyCompilationUnit(Set<String> commands, IPackageFragmentRoot root, ICompilationUnit unit)
        throws JavaModelException, CoreException {
    IJavaProject java = (IJavaProject) root.getParent();
    String type = unitOutput(unit);
    IFolder nxdataFolder = nxdataFolder(java).getFolder(type);
    IProject project = java.getProject();
    IPath outputLocation = java.getOutputLocation();
    IPath path = unit.getPath().removeFirstSegments(root.getPath().segmentCount()).removeLastSegments(1);
    path = path.append(/* w ww.  ja  va 2 s  . com*/
            org.eclipse.jdt.internal.core.util.Util.getNameWithoutJavaLikeExtension(unit.getElementName())
                    + ".class"); //$NON-NLS-1$
    IContainer container = (IContainer) project.getWorkspace().getRoot().findMember(outputLocation);
    IResource dotClassMember = container.findMember(path);
    if (dotClassMember == null) {
        SDKPlugin.log(IStatus.ERROR,
                "Cannot find binary class " + path + " in project " + java.getElementName());
        return;
    }

    IFile outputFile = nxdataFolder.getFile(path);
    mkdirs((IFolder) outputFile.getParent(), new NullProgressMonitor());
    dotClassMember.copy(outputFile.getFullPath(), IResource.HIDDEN | IResource.DERIVED,
            new NullProgressMonitor());
    commands.add(type + ":" + nxdataFolder.getLocation().toOSString());
}

From source file:org.nuxeo.ide.sdk.java.ProjectDeployer.java

License:Open Source License

protected IFolder devbundleFolder(IJavaProject project) throws JavaModelException {
    IFolder targetFolder = (IFolder) findMember(project.getOutputLocation().removeLastSegments(1));
    return targetFolder.getFolder("devbundle");
}

From source file:org.objectstyle.wolips.builder.internal.BuildVisitor.java

License:Open Source License

public void reinitForNextBuild(IProject project) {
    super.reinitForNextBuild(project);
    try {// ww w.  j a v a2s  .  c  o m
        IJavaProject jp = this.getJavaProject();
        outputPath = jp.getOutputLocation();
        _checkJavaOutputPath = !outputPath.equals(jp.getPath());
    } catch (CoreException up) {
        outputPath = new Path("/dummy");
    }
    count = 0;
    _destinations.clear();
}