发现 Eclipse 中未解析的插件依赖性(2)

2008-02-23 08:10:04来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

  下面是罗列 Eclipse 系统中所有插件的详细步骤:

  1. 找到目标平台的位置。
  2. 准备 links 文件夹的路径。links 文件夹在 \eclipse 文件夹中。
  3. 获得 \eclipse\links 文件夹中文件的清单。请参考源代码中的 Utilities.getLinkedPaths() 函数。
  4. 查看每个 .link 文件,获取链接 Eclipse 插件的路径。
  5. 准备一个所有插件根文件夹的清单(即,<targetPlatform>\eclipse\plugins 文件夹和所有可能的 <someLinkedPath>\eclipse\plugins 文件夹)。
  6. 对于每个根文件夹,进入每个插件目录中,并获取 plugin.xml 文件的路径。
  7. 对 plugin.xml 文件进行分析,获得插件 ID 和插件版本,并将这些信息保存到一个数据结构中。
  8. 回到步骤 6,继续处理下一个插件目录。

  清单 2. 准备在 Eclipse 系统下物理存在的所有插件的清单

 

/** 

 *   

 * @return returns a Vector containing PluginData objects. 

 * Each PluginData object represents a Plugin found under any of the following  

 * plugin directories 

 * a. the targetPlatformLocation\eclipse\plugins directory,  

 * b. other plugin directories as specified by *.link files under  

 *    targetPlatform\eclipse\links directory  

 **/  

public static Vector getPluginsInTargetPlatform(){ 

 /** 

 //step1: Get path of target platform. 

 //step2: Prepare path of links folder. 

 //step3: Get list of files in links folder. 

 //step4: Parse each link file and get the path of linked Eclipse folder. 

 //step5: Prepare a list of all plugin root folders  

 //       (Eclipse plugins and linked Eclipse plugins). 

 //step6: 6a. For each plugin root folder,  

 //       6b. go to each plugin directory and get path of plugin.xml. 

 //step7: Parse the plugin.xml file to get plugin id, plugin version,  

 //       and store in vectors, lists, etc. 

 //step8: Go back to step 6 to continue with next plugin directory. 

 **/ 

 //step1: Get path of target platform.  

 //Fall back to Eclipse install location if targetplatform in not set. 

 URL platFormURL = Platform.getInstallLocation().getURL(); 

 Location location = Platform.getInstallLocation(); 

 IPath eclipsePath = null ;   

 //Get path of target platform against which the users of this tool  

 //will compile their code.  

 IPath targetPlatFormLocation = new Path(getTargetPlatformPath(true)); 

 if(_useTargetPlatform == false) 

  eclipsePath = new Path(platFormURL.getPath()); 

 else 

  eclipsePath = targetPlatFormLocation; 

  

 showMessage("Considering target platform to be: "    

    eclipsePath.toString()); 

  

 //step2: Prepare path of links folder. 

 //step3: Get list of files in links folder.   

 //step4: Parse each link file and get the path of linked Eclipse folder. 

 IPath linksPath = new Path( eclipsePath.toString() ).append("/links"); 

 String linkedPaths[] = getLinkedPaths(linksPath.toString()); 

 int linkedPathLength = 0; 

 if(null != linkedPaths){ 

  linkedPathLength = linkedPaths.length; 

 } 

  

 //step5: Prepare a list of all plugin root folders  

 //       (Eclipse plugins and linked Eclipse plugins). 

 IPath eclipsePluginRootFolders[] = new IPath[linkedPathLength   1]; 

 eclipsePluginRootFolders[0] =  

  new Path( eclipsePath.toString() ).append("/plugins"); 

 if(null != linkedPaths){ 

  for(int i=0; i<linkedPaths.length; i  ){ 

   eclipsePluginRootFolders[i 1] =  

   new Path(linkedPaths[i]).append("/eclipse/plugins"); 

  } 

 } 

 //step6: 6a. For each plugin root folder,  

 //       6b. go to each plugin directory and get path of plugin.xml. 

 //step7: Parse the plugin.xml file to get plugin id, plugin version,  

 //       and store in vectors, lists, etc. 

 Vector vectorsInThisVector = new Vector(); 

 for(int i=0; i<eclipsePluginRootFolders.length; i  ){ 

  System.out.println("\n========plugin IDs and Versions in "    

  eclipsePluginRootFolders[i]   "========"); 

  Vector pluginDataObjs  =  

  getPluginDataForAllPlugins( 

   eclipsePluginRootFolders[i].toString()); 

  vectorsInThisVector.add(pluginDataObjs); 

  System.out.println(pluginDataObjs); 

  System.out.println("\n===========|||=== end ===|||==========="); 

 } 

  

 Vector pluginData = new Vector(); 

 Iterator outerIterator = vectorsInThisVector.iterator(); 

 while(outerIterator.hasNext()){ 

  Vector pluginDataObjs = (Vector)outerIterator.next(); 

  Iterator innerIterator = pluginDataObjs.iterator(); 

  while(innerIterator.hasNext()){ 

   PluginData pd = (PluginData)innerIterator.next(); 

   String pluginIdKey = pd.getPluginID(); 

   String versionValue = pd.getPluginVersion(); 

   String pluginPath = pd.getPluginLocation(); 

   pluginData.add(pd); 

  } 

 } 

  

 int breakpoint=0; 

 return pluginData; 

} 


  在掌握了所有的插件之后,我们就可以显示插件的 ID、版本、位置以及更多信息了,这些可以显示在一个 Standard Widget Toolkit(SWT)表中,从而使这些信息更加直观。我们也可以编写一些代码根据插件 ID 列进行排序,就像是我们的样例代码一样。还应该在一列中说明找到了多少个插件。结果应该如下所示:

  图 1. Target-Platform 视图中的所有插件

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:提升JSP应用程序七大绝招

下一篇:关于Html嵌入打成jar包的Applet方法