简体   繁体   English

Eclipse自动生成项目结构

[英]Eclipse Autogenerate Project Structure

Does Eclipse support the concept of reusable "project structures" via scripting/configging? Eclipse是否通过脚本/配置支持可重用的“项目结构”的概念?

For instance if I want all of my projects - upon creation - to take on the form: 例如,如果我希望所有项目(创建时)采用以下形式:

MyProjectRoot/
    src/
    fizz/
        buzz/
    docs/

Is there a way to define this project structure somewhere (XML, etc.), and then link a new project to that structure? 有没有办法在某个地方(XML等)定义此项目结构,然后将新项目链接到该结构?

I know I can write an ant/maven script to do this for me, but having a resource like this would save me from a lot of manual copying & pasting the same buildscript. 我知道我可以编写一个ant / maven脚本来为我执行此操作,但是拥有这样的资源将使我免于大量手动复制和粘贴相同的构建脚本的麻烦。

Thanks in advance! 提前致谢!

Out of the box, I don't think this exists. 开箱即用,我认为这不存在。

One option is to create a template project and save the dir tree off somewhere. 一种选择是创建模板项目并将目录树保存在某个地方。 Then when you need a new project that should follow template, you can copy the dir tree and use File -> Import. 然后,当您需要遵循模板的新项目时,可以复制目录树并使用文件->导入。

Another option that I'd recommend is to just use Maven and have Maven dictate dir structure. 我建议的另一个选择是只使用Maven并让Maven决定目录结构。 Eclipse can then import that maven project. 然后,Eclipse可以导入该Maven项目。

Yes it is possible. 对的,这是可能的。 But not easily . 但是不容易 You basically have to create your own plugin, which frankly I don't see the juice being worth the squeeze. 基本上,您必须创建自己的插件,坦率地说,我认为果汁不值钱。 Now, if you are learning/using Maven, then you already have a very good directory layout defined for you. 现在,如果您正在学习/使用Maven,那么您已经为您定义了一个非常好的目录布局。 Getting that directory structure imported into Eclipse is a one-line command in your shell. 将目录结构导入Eclipse是您外壳程序中的单行命令。 And if you decide to switch to NetBeans then you don't even have too run that shell command (native integration ftw)! 而且,如果您决定切换到NetBeans,那么您甚至不必运行该Shell命令(本机集成为ftw)!

But of course, you are constrained to Maven best-practices for directory layout (good, bad or indifferent). 但是,当然,您受制于目录布局(好的,坏的或无关紧要的)的Maven最佳实践。

I'm including a link to the Eclipse Help documentation, in the case you decide to go down the custom plugin route. 如果您决定遵循定制插件路线,那么我将提供指向Eclipse帮助文档的链接。 Good luck! 祝好运!

Custom project types in Eclipse Eclipse中的自定义项目类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM