how to get a list of referenced libraries of a project in eclipse plugin development?

StackOverflow https://stackoverflow.com/questions/23403608

  •  13-07-2023
  •  | 
  •  

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.

Était-ce utile?

La 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();

  }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top