执行以下代码,更改47行的path变量,指定插件文件所在目录designer(designer下的目录结构是eclipse/features and plugins的形式),然后按照输出信息操作即可。
package cn.it;
import java.io.File;
public class CfgInfo {
public void generateAndPrintConfigInfo(String pluginPath) {
File dir = new File(pluginPath);
if (!dir.isDirectory()) {
throw new RuntimeException("请提供一个正确插件的路径(目录)");
}
for (File file : dir.listFiles()) {
if (file.getName().indexOf("_") < 0) {
if (file.isDirectory()) {
generateAndPrintConfigInfo(file.getAbsolutePath());
}
continue;
}
if (file.isDirectory()) {
String[] filenames = file.getName().split("_");
String result = new StringBuilder(filenames[0])// 插件名?
.append(",").append(filenames[1])// 版本号?
.append(",file:/").append(file.getAbsolutePath())//
.append("\\,4,false")//
.toString();
System.out.println(result.replace("\\", "/"));
} else if (file.isFile()) {
String filename = file.getName();
int lastUnderline = filename.lastIndexOf("_");// 最后一个下划线的位置
String fn1 = filename.substring(0, lastUnderline);
String fn2 = filename.substring(lastUnderline + 1, filename.length() - 4); // 4是指".jar"扩展名的长度吗?
String result = new StringBuilder(fn1)//
.append(",").append(fn2)//
.append(",file:/").append(file.getAbsolutePath())//
.append(",4,false")//
.toString();
System.out.println(result.replace("\\", "/"));
}
}
}
public static void main(String[] args) {
// // 插件文件所在目录designer下的目录结构是eclipse/features and plugins的形式
String path = "J:\\MySpace\\openSource\\jbpm_jar\\jbpm-jpdl-3.2.2\\designer";
String info = new StringBuilder("\n插件的路径为:").append(path).append("\n")//
.append("/*-------------------------------------------------------------------\\ \n")//
.append("| 将下面的插件配置信息复制到: | \n")//
.append("| MyEclipse 7.0/configuration/org.eclipse.equinox.simpleconfigurator | \n")//
.append("| 文件夹下的 bundles.info 文件内容的最后。 然后重启 myeclipse 即可。 | \n")//
.append("\\-------------------------------------------------------------------*/ \n")//
// .append("然后使用myeclipse -clean命令重启myeclipse即可。")//
.toString();
System.out.println(info);
new CfgInfo().generateAndPrintConfigInfo(path);
}
}
本文介绍了一个Java程序,该程序用于生成特定格式的插件配置信息,适用于Eclipse插件系统。通过遍历指定目录下的文件和子目录,程序能够自动生成所需的配置条目,并打印出来供用户复制到Eclipse的bundles.info文件中。
221

被折叠的 条评论
为什么被折叠?



