Example usage for org.eclipse.jdt.core JavaCore newVariableEntry

List of usage examples for org.eclipse.jdt.core JavaCore newVariableEntry

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaCore newVariableEntry.

Prototype

public static IClasspathEntry newVariableEntry(IPath variablePath, IPath variableSourceAttachmentPath,
        IPath variableSourceAttachmentRootPath, boolean isExported) 

Source Link

Document

Creates and returns a new classpath entry of kind CPE_VARIABLE for the given path.

Usage

From source file:com.google.gwt.eclipse.core.compile.GWTCompileRunnerTest.java

License:Open Source License

/**
 * Tests variable support when computing classpaths. 
 *//*from w  w w  .  j  a v  a  2s  .c  om*/
public void testComputeClasspathForVariables() throws CoreException, IOException {
    // Create the classpath variable
    Random rand = new Random();
    String varName = null;
    while (varName == null) {
        String curVarName = this.getName() + rand.nextInt();
        if (JavaCore.getClasspathVariable(curVarName) == null) {
            varName = curVarName;
        }
    }

    File systemTempFile = File.createTempFile(this.getName(), ".temp");
    JavaCore.setClasspathVariable(varName, Path.fromOSString(systemTempFile.getAbsolutePath()),
            new NullProgressMonitor());

    try {
        // Create a variable entry and add it to the raw classpath
        JavaProjectUtilities.addRawClassPathEntry(javaProjectA,
                JavaCore.newVariableEntry(new Path(varName), null, null, true));

        // Get the computed classpath
        List<File> actualCp = getListOfFiles(GWTCompileRunner.computeClasspath(javaProjectA));

        // Ensure the paths and ordering are all the same
        List<File> expectedCp = new ArrayList<File>();
        expectedCp.add(systemTempFile);

        assertEquals(expectedCp, actualCp);
    } finally {
        JavaCore.removeClasspathVariable(varName, new NullProgressMonitor());
    }
}

From source file:org.eclim.plugin.jdt.project.JavaProjectManager.java

License:Open Source License

/**
 * Creates the classpath entry./*from ww w  . j a v  a  2  s  .com*/
 *
 * @param root The workspace root.
 * @param project The project to create the dependency in.
 * @param dependency The dependency to create the entry for.
 * @return The classpath entry.
 */
protected IClasspathEntry createEntry(IWorkspaceRoot root, IJavaProject project, Dependency dependency)
        throws Exception {
    if (dependency.isVariable()) {
        return JavaCore.newVariableEntry(dependency.getPath(), null, null, true);
    }

    return JavaCore.newLibraryEntry(dependency.getPath(), null, null, true);
}

From source file:org.eclipse.jem.internal.beaninfo.core.BeaninfoEntry.java

License:Open Source License

/**
 * Return the appropriate kind of entry when we know it is a classpath entry.
 *///from  w  ww. ja v a 2 s.  c  o  m
public static IClasspathEntry createEntry(int kind, IPath path, IProject project, boolean isExported) {
    switch (kind) {

    case IClasspathEntry.CPE_LIBRARY:
        if (path.isAbsolute())
            return JavaCore.newLibraryEntry(path, null, null, isExported);
        break;

    case IClasspathEntry.CPE_SOURCE:
        if (path.isAbsolute()) {
            // must be an entry in this project or specify another project
            String projSegment = path.segment(0);
            if (project != null && projSegment != null && projSegment.equals(project.getName())) {
                // this project
                return JavaCore.newSourceEntry(path);
            } else {
                // another project
                return JavaCore.newProjectEntry(path, isExported);
            }
        }
        break;

    case IClasspathEntry.CPE_VARIABLE:
        return JavaCore.newVariableEntry(path, null, null, isExported);

    case IClasspathEntry.CPE_CONTAINER:
        return JavaCore.newContainerEntry(path, isExported);

    }

    return null;
}

From source file:org.wso2.developerstudio.eclipse.utils.jdt.JavaUtils.java

License:Open Source License

public static IClasspathEntry createClassPathEntry(IPath path) {
    IClasspathEntry newLibraryEntry;//from w w w .ja v a2 s . c o  m
    if (path.toFile().exists()) {
        newLibraryEntry = JavaCore.newLibraryEntry(path, null, null, true);
    } else {
        //Assume it is a variable contained entry
        newLibraryEntry = JavaCore.newVariableEntry(path, null, null, true);
    }
    return newLibraryEntry;
}