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:x10dt.ui.launch.core.builder.AbstractX10Builder.java

License:Open Source License

/**
 * Returns the main generated file for the X10 file provided, i.e. for C++ back-end this should return the C++ file
 * corresponding to the X10 file in question.
 * /*w  w w . j  av a 2s .  c  o m*/
 * @param project
 *          The project containing the X10 file in question.
 * @param x10File
 *          The x10 file to consider.
 * @return A non-null file if we found one, otherwise <b>null</b>.
 * @throws CoreException
 *           Occurs if we could not access some project information or get the local file for the location identified.
 */
public File getMainGeneratedFile(final IJavaProject project, final IFile x10File) throws CoreException {
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    for (final IClasspathEntry cpEntry : project.getRawClasspath()) {
        if (cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE
                && cpEntry.getPath().isPrefixOf(x10File.getFullPath())
                && !BuildPathUtils.isExcluded(x10File.getFullPath(), cpEntry)) {
            final IPath outputLocation;
            if (cpEntry.getOutputLocation() == null) {
                outputLocation = project.getOutputLocation();
            } else {
                outputLocation = cpEntry.getOutputLocation();
            }
            final StringBuilder sb = new StringBuilder();
            sb.append(File.separatorChar)
                    .append(x10File.getProjectRelativePath().removeFileExtension().toString())
                    .append(getFileExtension());
            final IPath projectRelativeFilePath = new Path(sb.toString());
            final int srcPathCount = cpEntry.getPath().removeFirstSegments(1).segmentCount();
            final IPath generatedFilePath = outputLocation
                    .append(projectRelativeFilePath.removeFirstSegments(srcPathCount));
            final IFileStore fileStore = EFS.getLocalFileSystem()
                    .getStore(URIUtils.getExpectedURI(root.getFile(generatedFilePath).getLocationURI()));
            if (fileStore.fetchInfo().exists()) {
                return fileStore.toLocalFile(EFS.NONE, null);
            }
        }
    }
    return null;
}

From source file:x10dt.ui.launch.core.builder.AbstractX10Builder.java

License:Open Source License

public static Collection<IPath> getProjectDependencies(IJavaProject project) throws JavaModelException {
    Collection<IPath> ret = new ArrayList<IPath>();
    if (project == null)
        return ret;
    for (final IClasspathEntry cpEntry : project.getRawClasspath()) {
        if (cpEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
            final IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
            IJavaProject javaProject = JavaCore.create(wsRoot.getProject(cpEntry.getPath().toOSString()));
            ret.add(wsRoot.getLocation().append(javaProject.getOutputLocation()));
            for (final IClasspathEntry pEntry : javaProject.getRawClasspath()) {
                if (pEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                    if (pEntry.getOutputLocation() != null) {
                        ret.add(wsRoot.getLocation().append(pEntry.getOutputLocation()));
                    }/*w  w  w .  j  av  a  2 s  .c om*/
                }
            }
        }
    }
    return ret;
}

From source file:x10dt.ui.launch.core.utils.ProjectUtils.java

License:Open Source License

/**
 * Returns the path to the project main output directory.
 * /*from  w  ww . j a v  a 2s .  c  o  m*/
 * @param project The project of interest.
 * @return A non-null string identifying the project output directory.
 * @throws CoreException Occurs if we could not access the output directory for the project transmitted.
 */
public static String getProjectOutputDirPath(final IProject project) throws CoreException {
    final IJavaProject javaProject = JavaCore.create(project);
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    final URI outputFolderURI = URIUtils
            .getExpectedURI(root.getFolder(javaProject.getOutputLocation()).getLocationURI());
    return EFS.getStore(outputFolderURI).toLocalFile(EFS.NONE, new NullProgressMonitor()).getAbsolutePath();
}

From source file:x10dt.ui.launch.core.utils.ProjectUtils.java

License:Open Source License

private static IPath getOutputLocation(IClasspathEntry cpEntry, IJavaProject project)
        throws JavaModelException {
    IPath specificPath = cpEntry.getOutputLocation();
    if (specificPath != null) {
        return specificPath;
    } else {//from  w w w.j a v  a2 s.  c  om
        return project.getOutputLocation();
    }
}

From source file:x10dt.ui.launch.java.launching.X10LaunchConfigurationDelegate.java

License:Open Source License

private File getWorkingDir(final ILaunchConfiguration configuration, final IJavaProject javaProject,
        final String mainTypeName) throws CoreException {
    final IPath workDirPath = this.fLocalConfDelegate.getWorkingDirectoryPath(configuration);
    final String mainTypeFileName = mainTypeName.replace('.', File.separatorChar).concat(Constants.CLASS_EXT);
    if (workDirPath == null) {
        for (final IClasspathEntry cpEntry : javaProject.getRawClasspath()) {
            if ((cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE)
                    && (cpEntry.getOutputLocation() != null)) {
                final File dir = getWorkindDir(mainTypeFileName, cpEntry.getOutputLocation(), false);
                if (dir != null) {
                    return dir;
                }//w  w  w  .  j  a v  a2s  . c o  m
            }
        }
        return getWorkindDir(mainTypeFileName, javaProject.getOutputLocation(), true);
    } else {
        return getWorkindDir(mainTypeFileName, workDirPath, true);
    }
}