1. 程式人生 > >MyEclipse 10 中增加svn外掛

MyEclipse 10 中增加svn外掛

隨著Myeclipse版本號的變大,外掛的安裝也越來越複雜了,在有了configuration center之後,明明eclipse都能正常使用的update site,在Myeclipse中就是不能使用,真糾結。我試了好幾個外掛的線上安裝,沒有一個能成功的,而且巨慢無比,等待很長一段時間之後告訴你,失敗。所以安裝外掛最好還是採用離線安裝。

網上有另類的解決辦法,親自嘗試了一些,有些已經都不可用了,特記錄一下可用的方式。

首先:下載svn外掛,最新的已經是1.8版本了。svn外掛網站:http://subclipse.tigris.org/,外掛下載地址:http://subclipse.tigris.org/files/documents/906/49209/site-1.8.8.zip

解壓svn包,找到其中的兩個資料夾features和plugins目錄,在Myeclipse目錄下面新建一個資料夾,名稱隨意,可以就叫svn,將解壓的兩個資料夾放在這個新建的目錄中

找到Myeclipse的安裝目錄,在安裝目錄下的configuration\org.eclipse.equinox.simpleconfigurator這個目錄中有個

bundles.info檔案,需要在這個檔案中增加外掛的相關資訊Myeclipse才會去載入。

新增的內容使用下面的類生成:

  1. import java.io.File;         
  2. import java.util.ArrayList;        
  3. import java.util.List;         
  4. publicclass PluginConfigCreator         
  5. {         
  6. public PluginConfigCreator()         
  7.     {         
  8.     }         
  9. publicvoid print(String path)         
  10.     {         
  11.         List list = getFileList(path);         
  12. if (list == null)         
  13.         {         
  14. return;         
  15.         }         
  16. int length = list.size();         
  17. for (int i = 0; i < length; i++)         
  18.         {         
  19.             String result = "";         
  20.             String thePath = getFormatPath(getString(list.get(i)));         
  21.             File file = new File(thePath);         
  22. if (file.isDirectory())         
  23.             {         
  24.                 String fileName = file.getName();         
  25. if (fileName.indexOf("_") < 0)         
  26.                 {         
  27.                     print(thePath);         
  28. continue;         
  29.                 }         
  30.                 String[] filenames = fileName.split("_");         
  31.                 String filename1 = filenames[0];         
  32.                 String filename2 = filenames[1];         
  33.                 result = filename1 + "," + filename2 + ",file:/" + path + "/"
  34.                         + fileName + "\\,4,false";         
  35.                 System.out.println(result);         
  36.             } elseif (file.isFile())         
  37.             {         
  38.                 String fileName = file.getName();         
  39. if (fileName.indexOf("_") < 0)         
  40.                 {         
  41. continue;         
  42.                 }       
  43. int last = fileName.lastIndexOf("_");// 最後一個下劃線的位置       
  44.                 String filename1 = fileName.substring(0, last);         
  45.                 String filename2 = fileName.substring(last + 1, fileName         
  46.                         .length() - 4);         
  47.                 result = filename1 + "," + filename2 + ",file:/" + path + "/"
  48.                         + fileName + ",4,false";         
  49.                 System.out.println(result);         
  50.             }         
  51.         }         
  52.     }         
  53. public List getFileList(String path)         
  54.     {         
  55.         path = getFormatPath(path);         
  56.         path = path + "/";         
  57.         File filePath = new File(path);         
  58. if (!filePath.isDirectory())         
  59.         {         
  60. returnnull;         
  61.         }         
  62.         String[] filelist = filePath.list();         
  63.         List filelistFilter = new ArrayList();         
  64. for (int i = 0; i < filelist.length; i++)         
  65.         {         
  66.             String tempfilename = getFormatPath(path + filelist[i]);         
  67.             filelistFilter.add(tempfilename);         
  68.         }         
  69. return filelistFilter;         
  70.     }         
  71. public String getString(Object object)         
  72.     {         
  73. if (object == null)         
  74.         {         
  75. return"";         
  76.         }         
  77. return String.valueOf(object);         
  78.     }         
  79. public String getFormatPath(String path)         
  80.     {         
  81.         path = path.replaceAll("\\\\", "/");         
  82.         path = path.replaceAll("//""/");         
  83. return path;         
  84.     }         
  85. publicstaticvoid main(String[] args)         
  86.     {         
  87.             String plugin = "F:\\MyEclipse10.0\\myEclipsePlugin\\svn";         
  88. new PluginConfigCreator().print(plugin);         
  89.     }         
  90. }   

最後就是在bundles.info檔案後增加上面程式碼生成的內容,然後重啟下Myeclipse即可。