eclipse导入项目使用命令行 [英] eclipse import project using command line
问题描述
我想创建一个脚本来从cvs中检出一些项目,并自动将它们导入到eclipse中。我可以将所有内容都检入工作区文件夹,但项目不会出现在eclipse中。我必须手动导入它们。有没有办法使用命令行导入项目?
I want to create a script to checkout some projects from cvs and automatically import them into eclipse. I can checkout everything into the workspace folder, but the projects don't appear in eclipse. I have to manually import them. Is there a way to import the projects using the command line?
谢谢
凯利
推荐答案
可能的方法来自Ant + Groovy:
首先创建一个包含以下内容的build.xml文件:
A possible approach would be from Ant+Groovy: First create a build.xml file with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="default">
<taskdef name="groovy"
classname="org.codehaus.groovy.ant.Groovy"
classpath="/home/me/workspace/Groovy/lib/groovy-all-2.1.4.jar" />
<target name="default">
<groovy>
bundle = org.eclipse.core.runtime.Platform.getBundle("org.eclipse.core.resources");
resPlugin = bundle.loadClass("org.eclipse.core.resources.ResourcesPlugin");
root = resPlugin.getWorkspace().getRoot();
project = root.getProject("new");
project.create(null);
project.open(null);
resPlugin.getWorkspace().save(true, null);
</groovy>
</target>
</project>
然后运行执行:
./eclipse -nosplash -data /home/me/workspace -application org.eclipse.ant.core.antRunner -buildfile /home/me/build.xml
当然,一个完整的脚本将包含一些更多的代码,也许运行使用 IWorkspaceRunnable 等等,但基础在这里。只需确保您要从Eclipse使用的任何类都使用Platform.getBundle + bundle.loadClass机制定位。
Of course, a full-fledged script will contain some more code, perhaps run using an IWorkspaceRunnable and so on but the basics is here. Just be sure that any classes that you want to use from Eclipse are located using the Platform.getBundle + bundle.loadClass mechanism.
这篇关于eclipse导入项目使用命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!