List of usage examples for org.eclipse.jdt.core IClasspathEntry getPath
IPath getPath();
From source file:io.takari.m2e.lifecycle.test.LifecycleBasicTest.java
License:Open Source License
public void testTakariJar() throws Exception { IProject project = importProject("projects/takari-jar/pom.xml"); waitForJobsToComplete();//from w w w .j a v a 2 s. com project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); assertNoErrors(project); // assert java project configuration IJavaProject jproject = JavaCore.create(project); assertEquals("1.5", jproject.getOption(JavaCore.COMPILER_SOURCE, false)); assertEquals("1.5", jproject.getOption(JavaCore.COMPILER_COMPLIANCE, false)); assertEquals("1.5", jproject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, false)); // assert JRE classpath container IClasspathEntry cpe = getJREContainer(jproject); assertNotNull("JRE Container", cpe); assertEquals("J2SE-1.5", JavaRuntime.getExecutionEnvironmentId(cpe.getPath())); // XXX assert lifecycle mapping assertFile(project, "target/classes/main/MainClass.class"); assertFile(project, "target/classes/main.properties"); assertFile(project, "target/test-classes/test/TestClass.class"); assertFile(project, "target/test-classes/test.properties"); }
From source file:io.takari.m2e.lifecycle.test.LifecycleBasicTest.java
License:Open Source License
private IClasspathEntry getJREContainer(IJavaProject jproject) throws JavaModelException { for (IClasspathEntry cpe : jproject.getRawClasspath()) { if (JavaRuntime.JRE_CONTAINER.equals(cpe.getPath().segment(0))) { return cpe; }/*from ww w .j a v a 2 s .c o m*/ } return null; }
From source file:it.wallgren.android.platform.project.AndroidPlatformProject.java
License:Apache License
private IClasspathEntry[] mangleClasspath(IClasspathEntry[] rawClasspath, IProject project, IFolder repoLink) { LinkedList<IClasspathEntry> entries = new LinkedList<IClasspathEntry>(); // Filter out anything that is not framworks, packages, libcore or R IFile frameworks = project.getFile("frameworks"); IFile packages = project.getFile("packages"); IFile libcore = project.getFile("libcore"); for (IClasspathEntry entry : rawClasspath) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { // is frameworks source folder or R source folder if (frameworks.getFullPath().isPrefixOf(entry.getPath()) || libcore.getFullPath().isPrefixOf(entry.getPath()) || packages.getFullPath().isPrefixOf(entry.getPath()) || entry.getPath().lastSegment().equals("R")) { IPath path = entry.getPath().removeFirstSegments(1); IFolder entryFolder = repoLink.getFolder(path); if (!isBroken(entryFolder)) { entries.add(JavaCore.newSourceEntry(entryFolder.getFullPath())); }// w w w . j ava 2 s . com } } } // Add the special platform libs container entries.add(getAndroidDependenceis(repoPath)); return entries.toArray(new IClasspathEntry[0]); }
From source file:jasima_gui.EclipseProjectClassLoader.java
License:Open Source License
protected Resource findResource(final String name, IJavaProject proj, boolean onlyExported) throws CoreException { IClasspathEntry[] classpath = proj.getResolvedClasspath(true); byte[] content; content = readResource(proj.getOutputLocation().makeRelative(), name); if (content != null) { return new Resource(proj.getOutputLocation().makeRelative(), content); }//w w w .ja v a 2s . c om for (IClasspathEntry entry : classpath) { if (onlyExported && !entry.isExported()) continue; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { content = readResource(entry.getPath(), name); if (content != null) { return new Resource(entry.getPath(), content); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IProject projEntry = (IProject) ResourcesPlugin.getWorkspace().getRoot() .findMember(entry.getPath()); Resource result = findResource(name, JavaCore.create(projEntry), true); if (result != null) { return result; } } } return null; }
From source file:me.gladwell.eclipse.m2e.android.configuration.classpath.MarkAndroidClasspathContainerNotExportedConfigurer.java
License:Open Source License
public void configure(Project project) { IClasspathEntry oldEntry = findContainerMatching(project.getClasspath(), AdtConstants.CONTAINER_PRIVATE_LIBRARIES); if (oldEntry != null) { IClasspathEntry newEntry = JavaCore.newContainerEntry(oldEntry.getPath(), false); project.getClasspath().removeEntry(oldEntry.getPath()); project.getClasspath().addEntry(newEntry); } else {//w w w .ja v a2 s . c om // TODO log warning here } }
From source file:me.gladwell.eclipse.m2e.android.configuration.classpath.MarkMavenClasspathContianerExportedConfigurer.java
License:Open Source License
public void configure(Project project) { IClasspathEntry oldEntry = findContainerMatching(project.getClasspath(), IClasspathManager.CONTAINER_ID); IClasspathEntry newEntry = JavaCore.newContainerEntry(oldEntry.getPath(), true); project.getClasspath().removeEntry(oldEntry.getPath()); project.getClasspath().addEntry(newEntry); }
From source file:me.gladwell.eclipse.m2e.android.configuration.classpath.ModifySourceFolderOutputClasspathConfigurer.java
License:Open Source License
public void configure(Project project) { for (IClasspathEntry entry : project.getClasspath().getEntries()) { if (entry.getOutputLocation() != null && entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && !entry.getOutputLocation() .equals(project.getJavaProject().getPath().append(ANDROID_CLASSES_FOLDER))) { project.getClasspath().removeEntry(entry.getPath()); project.getClasspath().addSourceEntry(entry.getPath(), project.getJavaProject().getPath().append(ANDROID_CLASSES_FOLDER), true); }/* w w w.jav a2 s.c o m*/ } }
From source file:me.gladwell.eclipse.m2e.android.configuration.ClasspathAttacher.java
License:Open Source License
private Dependency findDependency(IClasspathEntry entry, List<Dependency> nonRuntimeDependencies) { for (Dependency dependency : nonRuntimeDependencies) { if (dependency.getPath().equals(entry.getPath().toOSString())) return dependency; }//from w w w . j ava2 s . c o m throw new ProjectConfigurationException("could not find dependency for entry=[" + entry.getPath() + "]"); }
From source file:me.gladwell.eclipse.m2e.android.configuration.Classpaths.java
License:Open Source License
public static IClasspathEntry findContainerMatching(final IClasspathDescriptor classpath, final String path) { return matchContainer(classpath, new Predicate<IClasspathEntry>() { public boolean apply(IClasspathEntry entry) { return entry.getPath().toOSString().equals(path); }// w w w .ja va2 s .co m }); }
From source file:me.gladwell.eclipse.m2e.android.configuration.Classpaths.java
License:Open Source License
public static IClasspathEntry findContainerContaining(final IClasspathDescriptor classpath, final String fragment) { return matchContainer(classpath, new Predicate<IClasspathEntry>() { public boolean apply(IClasspathEntry entry) { return entry.getPath().toOSString().contains(fragment); }//from w ww .j a v a 2 s. c om }); }