考试网 >> IT认证 >> JAVA >> JAVA指导 >> 如何加入到eclipse workspace方式

如何加入到eclipse workspace方式

发布时间:2006-06-28 11:09     点击:
分页:[1] 2 3 4 5  下一页

  在开发eclipse pluin的时候,某些情况下我们需要访问eclipse workspace,例如:在插件中以编程的方式调用ant命令、访问eclipse workspace中的project等。一次在网上偶遇到本文的原创者kobye,此人正在进行jsports项目的开发,对此颇有心地,故在此行文与众人共同探讨之。

  

  一、基础工作-在插件中以编程的方式调用ant命令:

  

  在开发eclipse pluin的时候,某些情况下我们需要访问eclipse workspace,例如:在插件中以编程的方式调用ant命令等。

  

  如何做到这一点?

  

  public void execute(){

  IWorkspace ws = ResourcesPlugin.getWorkspace();

  IProject[] ps = ws.getRoot().getProjects();

  System.out.println(ws.getRoot().getFullPath().makeAbsolute().toOSString());

  for(int i=0;i<ps.length;i++){

  IProject p = ps[i];

  IPath location = p.getLocation();

  IFile ifile = p.getFile("build.xml");

  System.out.println(ifile.getLocation().toFile().getAbsolutePath());

  File f = new File(ifile.getLocation().toFile().getAbsolutePath());

  if(!f.exists()){

  continue;

  }

  Project pro = new Project();

  pro.setBasedir(location.toFile().getAbsolutePath());

  pro.init();

  ProjectHelper helper = ProjectHelper.getProjectHelper();

  helper.parse(pro, f);

  Hashtable tars = pro.getTargets();

  System.out.println("name==="+name);

  Target t = (Target) tars.get(name);

  if(t==null){

  return;

  }

  DefaultLogger consoleLogger = new DefaultLogger();
分页:[1] 2 3 4 5  下一页
版权申明:未经书面授权请勿转载本站信息!!作品版权归所属媒体与作者所有!!
发表评论: 匿名发表 用户名: 查看评论
您将承担一切因您的行为、言论而直接或间接导致的民事或刑事法律责任
留言板管理人员有权保留或删除其管辖留言中的任意内容
本站提醒:不要进行人身攻击。谢谢配合。
在本站搜索相关信息
2003-2005 Ksw123.com All Rights Reserved. - TOP
Copyright © 2006 Ksw123.com. All rights reserved.中国考题网 版权所有