List of usage examples for org.eclipse.jdt.core IClasspathEntry getPath
IPath getPath();
From source file:me.gladwell.eclipse.m2e.android.test.AndroidMavenPluginTest.java
License:Open Source License
public void testConfigureNonAndroidProject() throws Exception { deleteProject(SIMPLE_PROJECT_NAME);/*from ww w .j ava 2s . 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; }/*ww w .jav a2s.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)); }/*w w w . j a va 2 s . c o m*/ } } }
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; }/* w ww .j a va 2 s. co m*/ } } return null; }
From source file:me.gladwell.eclipse.m2e.android.test.ApplicationAndroidMavenPluginTest.java
License:Open Source License
public void testConfigureDoesNotAddTargetDirectoryToClasspath() throws Exception { for (IClasspathEntry entry : javaProject.getRawClasspath()) { assertFalse(//from w ww . j av a 2 s . co m "classpath contains reference to target directory: cause infinite build loops and build conflicts", entry.getPath().toOSString().contains("target")); } }
From source file:me.gladwell.eclipse.m2e.android.test.Classpaths.java
License:Open Source License
public static IClasspathEntry findEntry(IClasspathEntry[] classpath, final String path) { for (IClasspathEntry entry : classpath) { if (entry.getPath().toOSString().endsWith(path)) { return entry; }/*from www .j av a 2s . c om*/ } return null; }
From source file:me.gladwell.eclipse.m2e.android.test.Classpaths.java
License:Open Source License
public static IClasspathEntry findSourceEntry(IClasspathEntry[] classpath, final String path) { for (IClasspathEntry entry : classpath) { if (entry.getEntryKind() == CPE_SOURCE && entry.getPath().toOSString().endsWith(path)) { return entry; }/*from ww w .j a v a2s .c o m*/ } return null; }
From source file:monolipse.core.internal.BooNature.java
License:Open Source License
private Map<IClasspathEntry, IClasspathEntry> addExclusionPatternsTo(IClasspathEntry[] classpath) { Map<IClasspathEntry, IClasspathEntry> modified = new HashMap<IClasspathEntry, IClasspathEntry>(); for (int i = 0; i < classpath.length; i++) { IClasspathEntry entry = classpath[i]; if (entry.getEntryKind() != IClasspathEntry.CPE_SOURCE) continue; IPath[] exclusionPatterns = entry.getExclusionPatterns(); IPath[] newExclusionPatterns = addExclusionPatternsTo(exclusionPatterns); if (exclusionPatterns == newExclusionPatterns) continue; IClasspathEntry newSourceEntry = JavaCore.newSourceEntry(entry.getPath(), entry.getInclusionPatterns(), newExclusionPatterns, entry.getOutputLocation(), entry.getExtraAttributes()); modified.put(entry, newSourceEntry); }//from w w w .j a v a 2 s .co m return modified; }
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 w ww . j ava 2 s.co 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 {//w w w.j a v a2 s .c o 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 ""; }