在命令行上创建一个 Eclipse 项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1718456/
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
Create an Eclipse project on the command line?
提问by Nathan
I would like to have a shell script create an entire CDT project on the command line and add it to a workspace. I'm willing to generate the .project and .cproject files myself, but I'd like something that would actually do the adding of the project to the workspace, because that is an opaque binary file that I'd rather not have to mess with.
我想让一个 shell 脚本在命令行上创建一个完整的 CDT 项目并将其添加到工作区。我愿意自己生成 .project 和 .cproject 文件,但我想要一些可以实际将项目添加到工作区的东西,因为这是一个不透明的二进制文件,我不想弄乱和。
I looked at both Buckminster and the Monkey Project, but I wasn't sure if either would do what I wanted. Anyone have any experience on this front and know what a good solution is?
我查看了 Buckminster 和 Monkey Project,但我不确定它们是否会做我想做的事。任何人都在这方面有任何经验并知道什么是好的解决方案?
Thanks,
谢谢,
Nathan
弥敦道
回答by James Blackburn
What version of CDT are you using?
您使用的是什么版本的 CDT?
If you have the recent CDT 6+ installed, you can perform a project import (as well as build), from the command line. To do this:
如果您安装了最新的 CDT 6+,您可以从命令行执行项目导入(以及构建)。去做这个:
eclipse -nosplash
-application org.eclipse.cdt.managedbuilder.core.headlessbuild
-import {[uri:/]/path/to/project}
-build {project_name | all}
-cleanBuild {projec_name | all}
The import switch can be used by itself. You'll need to specify the workspace you wish to import into with -dataas normal to Eclipse. The switches illustrated above are provided by the CDT managedbuild plugin, but should work with non-CDT projects (if not, let me know -- I wrote the feature ;) ).
导入开关可以单独使用。您需要像往常一样使用-data指定要导入到Eclipse的工作区。上面说明的开关由 CDT managedbuild 插件提供,但应该适用于非 CDT 项目(如果不是,请告诉我 - 我编写了该功能;))。
See this question on headless buildfor more details on the other switches.
有关其他开关的更多详细信息,请参阅有关无头构建的此问题。
回答by Alexandre Pauzies
I believe all you need is to do is create a folder here:
我相信您需要做的就是在此处创建一个文件夹:
WORKSPACE_DIR\.metadata\.plugins\org.eclipse.core.resources\.projects\YOUR_PROJECT_NAME
and a .locationfile in it.
和一个.location文件。
You can either use the Eclipse Resources API, or try to implement it yourself based on the current implementation
您可以使用Eclipse 资源 API,也可以尝试根据当前实现自己实现它
I don't know if there's an easiest way
不知道有没有最简单的方法
回答by ff.
This page contains also some convenience script: http://lugendal.wordpress.com/2009/07/22/eclipse-ctd-new-project-fast/
此页面还包含一些方便的脚本:http: //lugendal.wordpress.com/2009/07/22/eclipse-ctd-new-project-fast/
回答by Robert
There is a ant+groovy script in a different post, see https://stackoverflow.com/a/16949573/2457383
在不同的帖子中有一个 ant+groovy 脚本,参见https://stackoverflow.com/a/16949573/2457383
Disclaimer: The other post is also mine :)
免责声明:另一篇文章也是我的:)