开发者

Custom project structure in eclipse

I often use a eclipse plugins to quckliy generate project 开发者_如何学JAVAdirectory structure, for example Spring plugin helps to create WebContent folder to hold WEB-INF contents. But sometimes I create a projects with specific directory structure, always the same. Something like this:

[project_name]
-folder1
  -folderA
    -folderX
  -folderB
-folder2
  -dirC
-folder3

I know, that I can write my own ant/maven script to generate specific folders, but I don't want to manualy invoke scripts each time after project creating. I want to create a project template which I would use in the future.

What is the best way to create a this feature?

Should I create something like plugin? If yes, how would I do it?


If you don't want to use a plugin or a script to generate the project structure, you're pretty limited.

Since you can create a project from existing source, you could create the folder structure on your filesystem, and whenever you are creating another project, tell Eclipse to "Create Project from existing source" and point it to your template folder.

If you want to write a plugin, you'll want to contribute a org.eclipse.jdt.ui.actions.OpenProjectWizard that creates the folder structure as part of the project generation. A good tutorial can be found at: http://cvalcarcel.wordpress.com/2009/07/08/writing-an-eclipse-plug-in-part-1-what-im-going-to-do/%20


Maven has a concept of project templates called archetypes which is very similar to what you need. It defines the project structure, files, etc and can be customized upon creation.

Custom project structure in eclipse

If you install the Eclipse m2e maven plugin then you can create a new project from template with a few click

File / new Project / Maven project / Select archetype

Custom project structure in eclipse

You can use this feature even if you dont want to use maven later. You can auto generate ant scripts or anything like that. You can convert an exisint project into an archetype or create a new one from scratch, desciption is here

http://maven.apache.org/archetype/maven-archetype-plugin/

http://maven.apache.org/guides/mini/guide-creating-archetypes.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜