stamp

2006年与我同在

 

nature和builder的添加

    项目nature和builder都会在.project文件中看到,如下:
<buildSpec>
  <buildCommand>
   <name>org.eclipse.jdt.core.javabuilder</name>
   <arguments>
   </arguments>
  </buildCommand>
   <buildCommand>
   <name>org.eclipse.pde.SchemaBuilder</name>
   <arguments>
   </arguments>
  </buildCommand>
 </buildSpec>
 <natures>
  <nature>org.eclipse.pde.PluginNature</nature>
  <nature>org.eclipse.jdt.core.javanature</nature>
 </natures>
 
    builder主要在项目构建时使用,nature主要用来区分项目,项目的图标主要由第一个natures来决定,在plugin.xml文件对org.eclipse.core.resources.natures和org.eclipse.core.resources.builders扩展点进行扩展后,可以通过如下方法将nature添加到项目中:(builder类似实现,api查看IProjectDescription)
 private static boolean addNature(IProject prj) throws Exception {
  IProjectDescription description = prj.getDescription();
  String onatures[] = description.getNatureIds();
  String[] natures = new String[onatures.length + 1];
  natures[0] = "cn.aaa.bbb.natures";  //根据plugin.xml文件配置决定
  System.arraycopy(onatures, 0, natures, 1, onatures.length);
  description.setNatureIds(natures);
  prj.setDescription(description, null);
  return true;
 }

posted on 2005-09-06 19:48 stamp 阅读(828) 评论(2)  编辑  收藏 所属分类: Eclipse开发diary

评论

# re: nature和builder的添加 2005-09-08 17:31 augustapple

http://www.spaces.msn.com/members/hanlu2005/  回复  更多评论   

# 关于资料 2005-10-11 17:08 bluegrass

我在我的论文中遇到了有关nature和builder的使用的问题,请问您这里有没有有关Eclipse下使用Natures和Builders管理资源的资料,能否发给我,谢谢!我的信箱是dxfno1_417@hotmail.com  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

相册

搜索

最新评论

阅读排行榜

评论排行榜