Question

I am a able to get a reference to a project in eclipse. Like this

public void selectionChanged(IAction action, ISelection selection) {

      IStructuredSelection ss = (IStructuredSelection) selection;
      IResource resource = (IResource) ss.getFirstElement();
      project=  resource.getProject();


}

But i need to get the list of referenced libraries in that project. Google is not helping . Kindly help.

Thanks.

Was it helpful?

Solution

I found the solution:

    IStructuredSelection ss = (IStructuredSelection) selection;
    IResource resource = (IResource) ss.getFirstElement();
    project=  resource.getProject();

    IJavaProject javaProject= JavaCore.create(project); 


   classpath= javaProject.getRawClasspath();

   for (IClasspathEntry entry : classpath) {


          if (entry.getEntryKind() ==  IClasspathEntry.CPE_LIBRARY) {

               libs [i] = entry.getPath();

  }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top