菜鸟请教:Eclipse中如何自定义工程目录模板?

时间:2022-02-23 19:07:09
是这样,我需要开发的若干项目,有些基本的配置文件、模板类、文件目录都已经建立好了,以后再新建的时候,我想以后每次新建web项目就按照这个项目的结构来建,不想每次都配置,请问如何做到?
比如说:我的webroot目录下有一个文件夹叫image,有一个配置文件叫conf.xml,我想以后每次建web工程,new project就直接包含了这个文件夹和文件。
请各位不吝赐教!

3 个解决方案

#1


maven archetype 自定义可以解决,但是要用mavan,我也在想maven之外的解决办法,是否可以有什么自定义插件

#2


的确是要开发插件的。

比如我利用eclipse开发c/c++工程,我也需要开发创建工程模板,达到的效果就是点击创建某个类型的工程后,就有了固定的配置和所需要的c文件和头文件,并且不需要做任何修改就可以编译通过的helloworld工程出来。之后想怎么改再怎么改咯。

插件开发的plugin.xml类似如下(当然也可以是java的工程),插件开发的步骤自己百度或者google下吧:

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <?eclipse version="3.4"?>
  3 <plugin>
  4         <extension point="org.eclipse.cdt.core.templates">
  5                 <template
  6                         filterPattern=".*g[c\+][c\+]"
  7                         id="ilg.gnuarmeclipse.templates.freescale.klxx.c.project"
  8                         location="$nl$/templates/klxx_c_project/template.xml"
  9                         projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
 10                 </template>
 11         </extension>
 12         <extension point="org.eclipse.cdt.core.templateAssociations">
 13                 <template id="ilg.gnuarmeclipse.templates.freescale.klxx.c.project">
 14                         <toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base">
 15                         </toolChain>
 16                 </template>
 17         </extension>
 18 </plugin>

#3


引用 2 楼 lizekun2010 的回复:
的确是要开发插件的。

比如我利用eclipse开发c/c++工程,我也需要开发创建工程模板,达到的效果就是点击创建某个类型的工程后,就有了固定的配置和所需要的c文件和头文件,并且不需要做任何修改就可以编译通过的helloworld工程出来。之后想怎么改再怎么改咯。

插件开发的plugin.xml类似如下(当然也可以是java的工程),插件开发的步骤自己百度或者google下吧:

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <?eclipse version="3.4"?>
  3 <plugin>
  4         <extension point="org.eclipse.cdt.core.templates">
  5                 <template
  6                         filterPattern=".*g[c\+][c\+]"
  7                         id="ilg.gnuarmeclipse.templates.freescale.klxx.c.project"
  8                         location="$nl$/templates/klxx_c_project/template.xml"
  9                         projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
 10                 </template>
 11         </extension>
 12         <extension point="org.eclipse.cdt.core.templateAssociations">
 13                 <template id="ilg.gnuarmeclipse.templates.freescale.klxx.c.project">
 14                         <toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base">
 15                         </toolChain>
 16                 </template>
 17         </extension>
 18 </plugin>
这段代码看起来很熟啊,貌似是Eclipse QEMU ARM中的。。。

#1


maven archetype 自定义可以解决,但是要用mavan,我也在想maven之外的解决办法,是否可以有什么自定义插件

#2


的确是要开发插件的。

比如我利用eclipse开发c/c++工程,我也需要开发创建工程模板,达到的效果就是点击创建某个类型的工程后,就有了固定的配置和所需要的c文件和头文件,并且不需要做任何修改就可以编译通过的helloworld工程出来。之后想怎么改再怎么改咯。

插件开发的plugin.xml类似如下(当然也可以是java的工程),插件开发的步骤自己百度或者google下吧:

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <?eclipse version="3.4"?>
  3 <plugin>
  4         <extension point="org.eclipse.cdt.core.templates">
  5                 <template
  6                         filterPattern=".*g[c\+][c\+]"
  7                         id="ilg.gnuarmeclipse.templates.freescale.klxx.c.project"
  8                         location="$nl$/templates/klxx_c_project/template.xml"
  9                         projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
 10                 </template>
 11         </extension>
 12         <extension point="org.eclipse.cdt.core.templateAssociations">
 13                 <template id="ilg.gnuarmeclipse.templates.freescale.klxx.c.project">
 14                         <toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base">
 15                         </toolChain>
 16                 </template>
 17         </extension>
 18 </plugin>

#3


引用 2 楼 lizekun2010 的回复:
的确是要开发插件的。

比如我利用eclipse开发c/c++工程,我也需要开发创建工程模板,达到的效果就是点击创建某个类型的工程后,就有了固定的配置和所需要的c文件和头文件,并且不需要做任何修改就可以编译通过的helloworld工程出来。之后想怎么改再怎么改咯。

插件开发的plugin.xml类似如下(当然也可以是java的工程),插件开发的步骤自己百度或者google下吧:

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <?eclipse version="3.4"?>
  3 <plugin>
  4         <extension point="org.eclipse.cdt.core.templates">
  5                 <template
  6                         filterPattern=".*g[c\+][c\+]"
  7                         id="ilg.gnuarmeclipse.templates.freescale.klxx.c.project"
  8                         location="$nl$/templates/klxx_c_project/template.xml"
  9                         projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
 10                 </template>
 11         </extension>
 12         <extension point="org.eclipse.cdt.core.templateAssociations">
 13                 <template id="ilg.gnuarmeclipse.templates.freescale.klxx.c.project">
 14                         <toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base">
 15                         </toolChain>
 16                 </template>
 17         </extension>
 18 </plugin>
这段代码看起来很熟啊,貌似是Eclipse QEMU ARM中的。。。