如何在eclipse插件开发中获取项目引用库的列表?

时间:2014-05-01 07:14:56

标签: eclipse eclipse-plugin

我能够在eclipse中获得对项目的引用。喜欢这个

public void selectionChanged(IAction action,ISelection selection){

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


}

但是我需要获得该项目中引用库的列表。谷歌没有帮助。请帮助。

感谢。

1 个答案:

答案 0 :(得分:1)

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

  }