List of usage examples for org.eclipse.jdt.core IJavaProject getRawClasspath
IClasspathEntry[] getRawClasspath() throws JavaModelException;
From source file:me.gladwell.eclipse.m2e.android.test.AndroidMavenPluginTest.java
License:Open Source License
public void testConfigureNonAndroidProject() throws Exception { deleteProject(SIMPLE_PROJECT_NAME);/* ww w .j a v a2s .co m*/ IProject project = importAndroidProject(SIMPLE_PROJECT_NAME); assertFalse("configurer added android nature", project.hasNature(AdtConstants.NATURE_DEFAULT)); IJavaProject javaProject = JavaCore.create(project); assertFalse("output location set to android value for non-android project", javaProject.getOutputLocation() .toString().equals("/" + SIMPLE_PROJECT_NAME + "/target/android-classes")); for (IClasspathEntry entry : javaProject.getRawClasspath()) { assertFalse("classpath contains reference to gen directory", entry.getPath().toOSString().contains("gen")); } }
From source file:me.gladwell.eclipse.m2e.android.test.AndroidMavenPluginTestCase.java
License:Open Source License
protected void assertClasspathContains(IJavaProject javaProject, String path) throws JavaModelException { for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getPath().toOSString().contains(path)) { return; } else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), javaProject); for (IClasspathEntry e : container.getClasspathEntries()) { if (e.getPath().toOSString().contains(path)) { return; }/*from w w w . ja va 2s.c o m*/ } } } fail(path + " should be in classpath"); }
From source file:me.gladwell.eclipse.m2e.android.test.AndroidMavenPluginTestCase.java
License:Open Source License
protected void assertClasspathDoesNotContain(IJavaProject javaProject, String path) throws JavaModelException { for (IClasspathEntry entry : javaProject.getRawClasspath()) { assertFalse(entry.getPath().toOSString().contains(path)); if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), javaProject); for (IClasspathEntry e : container.getClasspathEntries()) { assertFalse(path + " should not be in classpath", e.getPath().toOSString().contains(path)); }//from ww w . j ava2 s. c om } } }
From source file:me.gladwell.eclipse.m2e.android.test.AndroidMavenPluginTestCase.java
License:Open Source License
protected IClasspathEntry getClasspathContainer(IJavaProject javaProject, String id) throws JavaModelException { for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (entry.getPath().toOSString().equals(id)) { return entry; }/*from w ww .j a v a 2s. co m*/ } } return null; }
From source file:monolipse.core.internal.BooNature.java
License:Open Source License
private void addExclusionPatternsToSourceFoldersOf(IJavaProject javaProject) throws JavaModelException { IClasspathEntry[] classpath = javaProject.getRawClasspath(); Map<IClasspathEntry, IClasspathEntry> modified = addExclusionPatternsTo(classpath); if (modified.isEmpty()) return;/*from www . ja v a 2 s . co m*/ javaProject.setRawClasspath(replaceModifiedClasspathEntries(classpath, modified), null); }
From source file:net.harawata.mybatipse.mybatis.MybatipseXmlUtil.java
License:Open Source License
public static String getJavaMapperFqn(IJavaProject project, IResource resource) { IPath path = null;//from ww w. j av a 2 s. c o m if (resource != null) { path = resource.getFullPath(); } else { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow window = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = window.getActivePage(); IEditorPart editor = page.getActiveEditor(); IEditorInput input = editor.getEditorInput(); path = ((FileEditorInput) input).getFile().getFullPath(); } try { for (IClasspathEntry entry : project.getRawClasspath()) { if (entry.getPath().isPrefixOf(path)) { IPath relativePath = path.makeRelativeTo(entry.getPath()); return relativePath.removeFileExtension().toString().replace('/', '.'); } } } catch (JavaModelException e) { Activator.log(Status.ERROR, "Failed to get raw classpath for project: " + project.getElementName(), e); } return null; }
From source file:net.harawata.mybatipse.wizard.NewXmlMapperWizard.java
License:Open Source License
private String guessNamespace(IFile file) { IProject project = file.getProject(); IJavaProject javaProject = JavaCore.create(project); if (javaProject != null) { IPath fullPath = file.getFullPath(); try {/*from w w w.ja v a 2 s. co m*/ for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getPath().isPrefixOf(fullPath)) { IPath relativePath = fullPath.makeRelativeTo(entry.getPath()); return relativePath.removeFileExtension().toString().replace('/', '.'); } } } catch (JavaModelException e) { Activator.log(Status.ERROR, "Failed to get raw classpath for project: " + javaProject.getElementName(), e); } } // empty string to raise warning return ""; }
From source file:net.kbserve.pyjdt.properties.models.CPEAbstractContainer.java
License:Open Source License
/** * Gets the classpath./*from w w w .ja v a2s.c o m*/ * * @param project * the project * @return the classpath * @see net.kbserve.pyjdt.properties.models.ICPEType#getClasspath(org.eclipse.core.resources.IProject) */ @Override public IClasspathEntry getClasspath(IProject project) { IJavaProject javaProject = JavaCore.create(project); try { for (IClasspathEntry icp : javaProject.getRawClasspath()) { if (makeStringPath(icp).equals(getPath())) { return icp; } } } catch (JavaModelException e) { e.printStackTrace(); } return null; }
From source file:net.kbserve.pyjdt.properties.models.RootContainer.java
License:Open Source License
/** * Update the classpaths of this project. *///w w w. j a va 2s .c o m public synchronized void update() { IProject project = reverseRoots.get(this); IJavaProject javaProject = JavaCore.create(project); try { for (IClasspathEntry icp : javaProject.getRawClasspath()) { this.updateChild(icp, project).update(icp, project); } } catch (JavaModelException e) { e.printStackTrace(); } }
From source file:net.revelc.code.formatter.tests.BuildhelperTest.java
License:Apache License
public void test_p001_simple() throws Exception { IProject project = importBuildHelperProject("buildhelper-001"); IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] classpath = javaProject.getRawClasspath(); ClasspathHelpers.assertClasspath(new String[] { "/buildhelper-001/src/main/java", // "/buildhelper-001/src/custom/java", // "/buildhelper-001/src/test/java", // "org.eclipse.jdt.launching.JRE_CONTAINER/.*", // "org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER", // }, classpath);/* ww w . jav a2 s . c o m*/ }