eclipse 使用命令行导入项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8908219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
eclipse import project using command line
提问by Kelly Goedert
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?
我想创建一个脚本来从 cvs 中检出一些项目并自动将它们导入到 eclipse 中。我可以将所有内容签出到工作区文件夹中,但项目不会出现在 eclipse 中。我必须手动导入它们。有没有办法使用命令行导入项目?
Thanks
谢谢
Kelly
凯利
回答by mpderbec
I wanted something simple without any dependencies and a plugin seemed to be the best answer. I wrote one and posted it here:
我想要一些没有任何依赖关系的简单东西,插件似乎是最好的答案。我写了一篇并贴在这里:
回答by Robert
A possible approach would be from Ant+Groovy: First create a build.xml file with the following content:
一种可能的方法来自 Ant+Groovy:首先创建一个包含以下内容的 build.xml 文件:
<?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>
Then run by executing:
然后通过执行运行:
./eclipse -nosplash -data /home/me/workspace -application org.eclipse.ant.core.antRunner -buildfile /home/me/build.xml
Of course, a full-fledged script will contain some more code, perhaps run using an IWorkspaceRunnableand 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.
当然,一个完整的脚本将包含更多代码,可能使用IWorkspaceRunnable等运行,但基础知识在这里。只要确保您想从 Eclipse 使用的任何类都使用 Platform.getBundle + bundle.loadClass 机制定位。
回答by NovusMobile
You use the -import
argument:
你使用这个-import
论点:
eclipse -nosplash
-application org.eclipse.cdt.managedbuilder.core.headlessbuild
-import {[uri:/]/path/to/project}
-build {project_name | all}
-cleanBuild {projec_name | all}
This link to Eclipse documentation may be helpful:
这个指向 Eclipse 文档的链接可能会有所帮助:
回答by VonC
With Eclipse 4.12, June 2019, seven years later... you do have project import by passing it as command-line argument!
使用 Eclipse 4.12,2019 年 6 月,七年后……您确实可以通过将其作为命令行参数传递来导入项目!
You can import a project into Eclipse by passing its path as a parameter to the launcher.
The command would look like:
eclipse /path/to/project
on Linux and Windows, oropen Eclipse.app -a /path/to/project
on macOS.
您可以将项目的路径作为参数传递给启动器,从而将项目导入 Eclipse。
该命令如下所示:
eclipse /path/to/project
在 Linux 和 Windows 上,或open Eclipse.app -a /path/to/project
在 macOS 上。