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

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

  •  13-07-2023
  •  | 
  •  

Frage

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.

War es hilfreich?

Lösung

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

  }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top