List of usage examples for org.eclipse.jdt.core IJavaProject findPackageFragmentRoots
IPackageFragmentRoot[] findPackageFragmentRoots(IClasspathEntry entry);
From source file:org.eclipse.edt.debug.core.java.filters.ClasspathEntryFilter.java
License:Open Source License
/** * Subclasses are free to override this to provide more specific caching. *//* w w w.jav a2 s. c om*/ protected void processContainerEntry(IClasspathEntry entry, IJavaProject project, Map<String, Object> classMap) { if (project == null) { // Can't calulate the entry without an IJavaProject. return; } IPackageFragmentRoot[] roots = project.findPackageFragmentRoots(entry); for (IPackageFragmentRoot root : roots) { try { for (IJavaElement element : root.getChildren()) { if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { try { IPackageFragment pkg = (IPackageFragment) element; StringBuilder pkgBuf = new StringBuilder(50); IJavaElement current = pkg; while (current != null && current.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { if (pkgBuf.length() > 0) { pkgBuf.insert(0, '.'); } pkgBuf.insert(0, current.getElementName()); current = current.getParent(); } String pkgString = pkgBuf.toString(); IClassFile[] classes = pkg.getClassFiles(); for (IClassFile file : classes) { String className = file.getElementName(); className = className.substring(0, className.length() - 6); // remove ".class" StringBuilder buf = new StringBuilder(pkgString.length() + className.length() + 1); buf.append(pkgString); if (pkgString.length() > 0) { buf.append('.'); } buf.append(className); classMap.put(buf.toString(), null); } } catch (JavaModelException jme) { EDTDebugCorePlugin.log(jme); } } } } catch (JavaModelException jme) { EDTDebugCorePlugin.log(jme); } } }
From source file:org.eclipse.jst.jsf.core.internal.tld.LoadBundleUtil.java
License:Open Source License
private static IStorage getResourceFromLibrary(IJavaProject javaProject, String baseName, IClasspathEntry entry) throws JavaModelException { IPackageFragmentRoot[] packageFragmentRoots = javaProject.findPackageFragmentRoots(entry); for (int j = 0; j < packageFragmentRoots.length; j++) { String packageName = getPackageName(baseName); Object[] resources = null; if (packageName.length() == 0) { resources = packageFragmentRoots[j].getNonJavaResources(); } else {/* ww w . j a v a 2s . co m*/ IPackageFragment fragment = packageFragmentRoots[j].getPackageFragment(getPackageName(baseName)); if (fragment != null && fragment.exists()) { resources = fragment.getNonJavaResources(); } } if (resources != null && resources.length > 0) { for (int k = 0; k < resources.length; k++) { if (resources[k] instanceof IStorage) { IStorage storage = (IStorage) resources[k]; if (getFileName(baseName).equalsIgnoreCase(storage.getName())) { return storage; } } } } } return null; }
From source file:org.eclipse.pde.internal.core.builders.SourceEntryErrorReporter.java
License:Open Source License
public void initialize(ArrayList<?> sourceEntries, ArrayList<?> outputEntries, IClasspathEntry[] cpes, IProject project) {/*from ww w.j a v a2 s .c o m*/ fProject = project; IPath defaultOutputLocation = null; IJavaProject javaProject = JavaCore.create(fProject); try { defaultOutputLocation = javaProject.getOutputLocation(); } catch (JavaModelException e) { } List<String> pluginLibraryNames = new ArrayList<String>(1); IPluginModelBase pluginModel = PluginRegistry.findModel(fProject); if (pluginModel != null) { IPluginLibrary[] pluginLibraries = pluginModel.getPluginBase().getLibraries(); for (int i = 0; i < pluginLibraries.length; i++) { pluginLibraryNames.add(pluginLibraries[i].getName()); } } if (!pluginLibraryNames.contains(".")) { //$NON-NLS-1$ pluginLibraryNames.add("."); //$NON-NLS-1$) } for (int i = 0; i < cpes.length; i++) { if (cpes[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath sourcePath = getPath(cpes[i]); if (sourcePath == null) continue; IPath outputLocation = cpes[i].getOutputLocation(); if (outputLocation == null) outputLocation = defaultOutputLocation; IPath outputPath = getPath(outputLocation); OutputFolder outputFolder = fOutputFolderMap.get(outputPath); if (outputFolder == null) { outputFolder = new OutputFolder(outputPath); } SourceFolder sourceFolder = fSourceFolderMap.get(sourcePath); if (sourceFolder == null) { sourceFolder = new SourceFolder(sourcePath, outputFolder); } outputFolder.addSourceFolder(sourceFolder); fOutputFolderMap.put(outputPath, outputFolder); fSourceFolderMap.put(sourcePath, sourceFolder); } else if (cpes[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IClasspathEntry entry = cpes[i]; IPackageFragmentRoot[] roots = javaProject.findPackageFragmentRoots(entry); IPath outputPath = null; if (roots.length == 1) { // should only be one entry for a library if (!roots[0].isArchive()) { outputPath = getPath(entry); OutputFolder outputFolder = new OutputFolder(outputPath, true); fOutputFolderMap.put(outputPath, outputFolder); } } } } for (Iterator<?> iterator = sourceEntries.iterator(); iterator.hasNext();) { IBuildEntry sourceEntry = (IBuildEntry) iterator.next(); String libName = sourceEntry.getName().substring(PROPERTY_SOURCE_PREFIX.length()); if (!pluginLibraryNames.contains(libName)) { prepareError(sourceEntry.getName(), null, NLS.bind(PDECoreMessages.SourceEntryErrorReporter_MissingLibrary, libName), PDEMarkerFactory.B_REMOVAL, fSrcLibSeverity, PDEMarkerFactory.CAT_OTHER); } String[] tokens = sourceEntry.getTokens(); for (int i = 0; i < tokens.length; i++) { IPath path = new Path(tokens[i]).addTrailingSeparator(); SourceFolder sourceFolder = fSourceFolderMap.get(path); if (sourceFolder == null) { sourceFolder = new SourceFolder(path, null); fSourceFolderMap.put(path, sourceFolder); } sourceFolder.setToken(tokens[i]); sourceFolder.addLib(libName); } } for (Iterator<?> iterator = outputEntries.iterator(); iterator.hasNext();) { IBuildEntry outputEntry = (IBuildEntry) iterator.next(); String libName = outputEntry.getName().substring(PROPERTY_OUTPUT_PREFIX.length()); if (!pluginLibraryNames.contains(libName)) { prepareError(outputEntry.getName(), null, NLS.bind(PDECoreMessages.SourceEntryErrorReporter_MissingLibrary, libName), PDEMarkerFactory.B_REMOVAL, fOututLibSeverity, PDEMarkerFactory.CAT_OTHER); } String[] tokens = outputEntry.getTokens(); for (int i = 0; i < tokens.length; i++) { IPath path = new Path(tokens[i]).addTrailingSeparator(); if (path.segmentCount() == 1 && path.segment(0).equals(".")) { //$NON-NLS-1$ // translate "." to root path path = Path.ROOT; } OutputFolder outputFolder = fOutputFolderMap.get(path); if (outputFolder == null) { outputFolder = new OutputFolder(path); fOutputFolderMap.put(path, outputFolder); } outputFolder.setToken(tokens[i]); outputFolder.addLib(libName); } } }
From source file:org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper.java
License:Open Source License
/** * Returns the path to the equinox launcher jar. If the launcher is available * in the workspace, the packageName will be used to determine the expected output * location./*from ww w .j a v a2 s.c om*/ * * @param packageName name of the launcher package, typically {@link IPDEBuildConstants#BUNDLE_EQUINOX_LAUNCHER} * @return the path to the equinox launcher jar or <code>null</code> * @throws CoreException */ private static String getEquinoxStartupPath(String packageName) throws CoreException { // See if PDE has the launcher in the workspace or target IPluginModelBase model = PluginRegistry.findModel(IPDEBuildConstants.BUNDLE_EQUINOX_LAUNCHER); if (model != null) { IResource resource = model.getUnderlyingResource(); if (resource == null) { // Found in the target String installLocation = model.getInstallLocation(); if (installLocation == null) { return null; } File bundleFile = new File(installLocation); if (!bundleFile.isDirectory()) { // The launcher bundle is usually jarred, just return the bundle root return installLocation; } // Unjarred bundle, search for the built jar at the root of the folder File[] files = bundleFile.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.indexOf(IPDEBuildConstants.BUNDLE_EQUINOX_LAUNCHER) >= 0; } }); for (int i = 0; i < files.length; i++) { if (files[i].isFile()) { return files[i].getPath(); } } // Source bundle from git://git.eclipse.org/gitroot/equinox/rt.equinox.framework.git File binFolder = new File(bundleFile, "bin"); //$NON-NLS-1$ if (binFolder.isDirectory()) { return binFolder.getPath(); } return null; } // Found in the workspace IProject project = resource.getProject(); if (project.hasNature(JavaCore.NATURE_ID)) { IJavaProject jProject = JavaCore.create(project); IClasspathEntry[] entries = jProject.getRawClasspath(); for (int i = 0; i < entries.length; i++) { int kind = entries[i].getEntryKind(); if (kind == IClasspathEntry.CPE_SOURCE || kind == IClasspathEntry.CPE_LIBRARY) { IPackageFragmentRoot[] roots = jProject.findPackageFragmentRoots(entries[i]); for (int j = 0; j < roots.length; j++) { if (roots[j].getPackageFragment(packageName).exists()) { // if source folder, find the output folder if (kind == IClasspathEntry.CPE_SOURCE) { IPath path = entries[i].getOutputLocation(); if (path == null) path = jProject.getOutputLocation(); path = path.removeFirstSegments(1); return project.getLocation().append(path).toOSString(); } // else if is a library jar, then get the location of the jar itself IResource jar = roots[j].getResource(); if (jar != null) { return jar.getLocation().toOSString(); } } } } } } } // No PDE model, see if the launcher bundle is installed Bundle bundle = Platform.getBundle(IPDEBuildConstants.BUNDLE_EQUINOX_LAUNCHER); if (bundle != null) { try { URL url = FileLocator.resolve(bundle.getEntry("/")); //$NON-NLS-1$ url = FileLocator.toFileURL(url); String path = url.getFile(); if (path.startsWith("file:")) //$NON-NLS-1$ path = path.substring(5); path = new File(path).getAbsolutePath(); if (path.endsWith("!")) //$NON-NLS-1$ path = path.substring(0, path.length() - 1); return path; } catch (IOException e) { } } return null; }
From source file:org.eclipse.pde.nls.internal.ui.model.ResourceBundleModel.java
License:Open Source License
/** * @param monitor//from ww w . j a v a 2 s . c o m * @throws CoreException */ private void populateFromWorkspace(IProgressMonitor monitor) throws CoreException { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); IProject[] projects = root.getProjects(); for (IProject project : projects) { try { if (!project.isOpen()) continue; IJavaProject javaProject = (IJavaProject) project.getNature(JAVA_NATURE); String pluginId = null; try { Class IFragmentModel = Class.forName("org.eclipse.pde.core.plugin.IFragmentModel"); Class IPluginModelBase = Class.forName("org.eclipse.pde.core.plugin.IPluginModelBase"); Class PluginRegistry = Class.forName("org.eclipse.pde.core.plugin.PluginRegistry"); Class IPluginBase = Class.forName("org.eclipse.pde.core.plugin.IPluginBase"); Class PluginFragmentModel = Class.forName("org.eclipse.core.runtime.model.PluginFragmentModel"); // Plugin and fragment projects Class pluginModel = (Class) PluginRegistry.getMethod("findModel", IProject.class).invoke(null, project); if (pluginModel != null) { // Get plugin id BundleDescription bd = (BundleDescription) IPluginModelBase .getMethod("getBundleDescription").invoke(pluginModel); pluginId = bd.getName(); // OSGi bundle name if (pluginId == null) { Object pluginBase = IPluginModelBase.getMethod("getPluginBase").invoke(pluginModel); pluginId = (String) IPluginBase.getMethod("getId").invoke(pluginBase); // non-OSGi // plug-in id } boolean isFragment = IFragmentModel.isInstance(pluginModel); if (isFragment) { Object pfm = IFragmentModel.getMethod("getFragment"); pluginId = (String) PluginFragmentModel.getMethod("getPluginId").invoke(pfm); } // Look for additional 'nl' resources IFolder nl = project.getFolder("nl"); //$NON-NLS-1$ if (isFragment && nl.exists()) { IResource[] members = nl.members(); for (IResource member : members) { if (member instanceof IFolder) { IFolder langFolder = (IFolder) member; String language = langFolder.getName(); // Collect property files IFile[] propertyFiles = collectPropertyFiles(langFolder); for (IFile file : propertyFiles) { // Compute path name IPath path = file.getProjectRelativePath(); String country = ""; //$NON-NLS-1$ String packageName = null; int segmentCount = path.segmentCount(); if (segmentCount > 1) { StringBuilder builder = new StringBuilder(); // Segment 0: 'nl' // Segment 1: language code // Segment 2: (country code) int begin = 2; if (segmentCount > 2 && isCountry(path.segment(2))) { begin = 3; country = path.segment(2); } for (int i = begin; i < segmentCount - 1; i++) { if (i > begin) builder.append('.'); builder.append(path.segment(i)); } packageName = builder.toString(); } String baseName = getBaseName(file.getName()); ResourceBundleFamily family = getOrCreateFamily(project.getName(), pluginId, packageName, baseName); addBundle(family, getLocale(language, country), file); } } } } // Collect property files if (isFragment || javaProject == null) { IFile[] propertyFiles = collectPropertyFiles(project); for (IFile file : propertyFiles) { IPath path = file.getProjectRelativePath(); int segmentCount = path.segmentCount(); if (segmentCount > 0 && path.segment(0).equals("nl")) //$NON-NLS-1$ continue; // 'nl' resource have been // processed // above // Guess package name String packageName = null; if (segmentCount > 1) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < segmentCount - 1; i++) { if (i > 0) builder.append('.'); builder.append(path.segment(i)); } packageName = builder.toString(); } String baseName = getBaseName(file.getName()); String language = getLanguage(file.getName()); String country = getCountry(file.getName()); ResourceBundleFamily family = getOrCreateFamily(project.getName(), pluginId, packageName, baseName); addBundle(family, getLocale(language, country), file); } } } } catch (Throwable e) { // MessagesEditorPlugin.log(e); } // Look for resource bundles in Java packages (output folders, // e.g. 'bin', will be ignored) if (javaProject != null) { IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true); for (IClasspathEntry entry : classpathEntries) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath path = entry.getPath(); IFolder folder = workspace.getRoot().getFolder(path); IFile[] propertyFiles = collectPropertyFiles(folder); for (IFile file : propertyFiles) { String name = file.getName(); String baseName = getBaseName(name); String language = getLanguage(name); String country = getCountry(name); IPackageFragment pf = javaProject .findPackageFragment(file.getParent().getFullPath()); String packageName = pf.getElementName(); ResourceBundleFamily family = getOrCreateFamily(project.getName(), pluginId, packageName, baseName); addBundle(family, getLocale(language, country), file); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IPackageFragmentRoot[] findPackageFragmentRoots = javaProject .findPackageFragmentRoots(entry); for (IPackageFragmentRoot packageFragmentRoot : findPackageFragmentRoots) { IJavaElement[] children = packageFragmentRoot.getChildren(); for (IJavaElement child : children) { IPackageFragment pf = (IPackageFragment) child; Object[] nonJavaResources = pf.getNonJavaResources(); for (Object resource : nonJavaResources) { if (resource instanceof IJarEntryResource) { IJarEntryResource jarEntryResource = (IJarEntryResource) resource; String name = jarEntryResource.getName(); if (name.endsWith(PROPERTIES_SUFFIX)) { String baseName = getBaseName(name); String language = getLanguage(name); String country = getCountry(name); String packageName = pf.getElementName(); ResourceBundleFamily family = getOrCreateFamily(project.getName(), pluginId, packageName, baseName); addBundle(family, getLocale(language, country), jarEntryResource); } } } } } } } // Collect non-Java resources Object[] nonJavaResources = javaProject.getNonJavaResources(); ArrayList<IFile> files = new ArrayList<IFile>(); for (Object resource : nonJavaResources) { if (resource instanceof IContainer) { IContainer container = (IContainer) resource; collectPropertyFiles(container, files); } else if (resource instanceof IFile) { IFile file = (IFile) resource; String name = file.getName(); if (isIgnoredFilename(name)) continue; if (name.endsWith(PROPERTIES_SUFFIX)) { files.add(file); } } } for (IFile file : files) { // Convert path to package name format IPath path = file.getProjectRelativePath(); String packageName = null; int segmentCount = path.segmentCount(); if (segmentCount > 1) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < segmentCount - 1; i++) { if (i > 0) builder.append('.'); builder.append(path.segment(i)); } packageName = builder.toString(); } String baseName = getBaseName(file.getName()); String language = getLanguage(file.getName()); String country = getCountry(file.getName()); ResourceBundleFamily family = getOrCreateFamily(project.getName(), pluginId, packageName, baseName); addBundle(family, getLocale(language, country), file); } } } catch (Exception e) { MessagesEditorPlugin.log(e); } } }
From source file:org.eclipse.recommenders.internal.coordinates.rcp.EclipseDependencyListener.java
License:Open Source License
public static Set<IPackageFragmentRoot> detectJREPackageFragementRoots(final IJavaProject javaProject) { // Please note that this is merely a heuristic to detect if a Jar is part of the JRE or not: // All Jars in the JRE_Container which are not located in the ext folder are considered part of the JRE. Set<IPackageFragmentRoot> jreRoots = new HashSet<IPackageFragmentRoot>(); try {/* www. java2 s. co m*/ for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (entry.getPath().toString().contains("org.eclipse.jdt.launching.JRE_CONTAINER")) { //$NON-NLS-1$ for (IPackageFragmentRoot packageFragmentRoot : javaProject .findPackageFragmentRoots(entry)) { if (!packageFragmentRoot.getPath().toFile().getParentFile().getName().equals("ext")) { //$NON-NLS-1$ jreRoots.add(packageFragmentRoot); } } } } } } catch (JavaModelException e) { Logs.log(LogMessages.ERROR_FAILED_TO_DETECT_PROJECT_JRE, e, javaProject); } return jreRoots; }
From source file:org.eclipse.recommenders.internal.models.rcp.ProjectCoordinateProvider.java
License:Open Source License
private static boolean isPartOfJRE(IPackageFragmentRoot root, IJavaProject javaProject) { try {//from w w w . j a v a2s . c o m for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (entry.getPath().toString().contains("org.eclipse.jdt.launching.JRE_CONTAINER")) { //$NON-NLS-1$ for (IPackageFragmentRoot packageFragmentRoot : javaProject .findPackageFragmentRoots(entry)) { if (!packageFragmentRoot.getPath().toFile().getParentFile().getName().equals("ext")) { //$NON-NLS-1$ if (packageFragmentRoot.equals(root)) { return true; } } } } } } } catch (JavaModelException e) { Logs.log(LogMessages.ERROR_FAILED_TO_TRAVERSE_PROJECT_DEPENDENCIES, e, javaProject); } return false; }
From source file:org.eclipse.recommenders.models.dependencies.rcp.EclipseDependencyListener.java
License:Open Source License
public static Set<IPackageFragmentRoot> detectJREPackageFragementRoots(final IJavaProject javaProject) { // Please notice that this is a heuristic to detect if a Jar is part of // the JRE or not. // All Jars in the JRE_Container which are not located in the ext folder // are defined as part of the JRE Set<IPackageFragmentRoot> jreRoots = new HashSet<IPackageFragmentRoot>(); try {/*from w w w.j a v a2 s. co m*/ for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (entry.getPath().toString().contains("org.eclipse.jdt.launching.JRE_CONTAINER")) { for (IPackageFragmentRoot packageFragmentRoot : javaProject .findPackageFragmentRoots(entry)) { if (!packageFragmentRoot.getPath().toFile().getParentFile().getName().equals("ext")) { jreRoots.add(packageFragmentRoot); } } } } } } catch (JavaModelException e) { e.printStackTrace(); } return jreRoots; }
From source file:org.eclipse.xtext.xbase.ui.editor.XbaseEditorInputRedirector.java
License:Open Source License
/** * @param an input//from w w w . j a va 2s . c o m * * @return the original source for an editor input that points to an Xtext resource copied to the output folder, the given input otherwise */ public IEditorInput findOriginalSourceForOuputFolderCopy(final IEditorInput input) { try { final IFile resource = ResourceUtil.getFile(input); if ((resource != null)) { boolean _isValid = this.fileExtensionProvider.isValid(resource.getFullPath().getFileExtension()); if (_isValid) { final IJavaProject project = JavaCore.create(resource.getProject()); boolean _exists = project.exists(); if (_exists) { boolean _isPrefixOf = project.getOutputLocation().isPrefixOf(resource.getFullPath()); if (_isPrefixOf) { final IPath relative = resource.getFullPath() .removeFirstSegments(project.getOutputLocation().segmentCount()); final Function1<IPackageFragmentRoot, Boolean> _function = ( IPackageFragmentRoot it) -> { try { int _kind = it.getKind(); return Boolean.valueOf((_kind == IPackageFragmentRoot.K_SOURCE)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; Iterable<IPackageFragmentRoot> _filter = IterableExtensions .<IPackageFragmentRoot>filter(((Iterable<IPackageFragmentRoot>) Conversions .doWrapArray(project.getPackageFragmentRoots())), _function); for (final IPackageFragmentRoot source : _filter) { { final IPath fullPath = source.getCorrespondingResource() .getProjectRelativePath().append(relative); final IFile newFile = resource.getProject().getFile(fullPath); boolean _exists_1 = newFile.exists(); if (_exists_1) { return new FileEditorInput(newFile); } } } } final Function1<IClasspathEntry, Boolean> _function_1 = (IClasspathEntry it) -> { int _entryKind = it.getEntryKind(); return Boolean.valueOf((_entryKind == IClasspathEntry.CPE_SOURCE)); }; Iterable<IClasspathEntry> _filter_1 = IterableExtensions.<IClasspathEntry>filter( ((Iterable<IClasspathEntry>) Conversions.doWrapArray(project.getRawClasspath())), _function_1); for (final IClasspathEntry sourceFolder : _filter_1) { if (((sourceFolder.getOutputLocation() != null) && sourceFolder.getOutputLocation().isPrefixOf(resource.getFullPath()))) { final IPath relative_1 = resource.getFullPath() .removeFirstSegments(sourceFolder.getOutputLocation().segmentCount()); final IPackageFragmentRoot source_1 = IterableExtensions .<IPackageFragmentRoot>head(((Iterable<IPackageFragmentRoot>) Conversions .doWrapArray(project.findPackageFragmentRoots(sourceFolder)))); final IPath fullPath = source_1.getCorrespondingResource().getProjectRelativePath() .append(relative_1); final IFile newFile = resource.getProject().getFile(fullPath); boolean _exists_1 = newFile.exists(); if (_exists_1) { return new FileEditorInput(newFile); } } } } } } return input; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
From source file:org.grails.ide.eclipse.core.internal.GrailsResourceUtil.java
License:Open Source License
public static IPackageFragmentRoot[] getGrailsDependencyPackageFragmentRoots(IProject project, IPath path) { if (project == null) { return null; }/* w ww .ja v a 2 s . com*/ IJavaProject javaProject = JavaCore.create(project); try { IClasspathEntry[] entries = javaProject.getRawClasspath(); for (IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { for (IClasspathAttribute attr : entry.getExtraAttributes()) { if (attr.getName().equals(GrailsClasspathContainer.PLUGIN_SOURCEFOLDER_ATTRIBUTE_NAME)) { IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(entry.getPath()); if (folder.getLocation().equals(path)) { return javaProject.findPackageFragmentRoots(entry); } } } } } } catch (JavaModelException e) { GrailsCoreActivator.log(e); } return null; }