`
qiuqiao2000
  • 浏览: 30732 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

项目的Nature&Builder

阅读更多

SpringProjectNature

org.springframework.ide.eclipse.core.internal.project.SpringProjectNatureconfigure()中添加org.springframework.ide.eclipse.core.springbuilder,在deconfigure()中删除springbuilder

 

 添加Nature

/** * Adds given nature as first nature to specified project. */ public static void addProjectNature(IProject project, String nature, IProgressMonitor monitor) throws CoreException { if (project != null && nature != null) { if (!project.hasNature(nature)) { IProjectDescription desc = project.getDescription(); String[] oldNatures = desc.getNatureIds(); String[] newNatures = new String[oldNatures.length + 1]; newNatures[0] = nature; if (oldNatures.length > 0) { System.arraycopy(oldNatures, 0, newNatures, 1, oldNatures.length); } desc.setNatureIds(newNatures); project.setDescription(desc, monitor); } } }

 

 删除Nature

 

/** * Removes given nature from specified project. */ public static void removeProjectNature(IProject project, String nature, IProgressMonitor monitor) throws CoreException { if (project != null && nature != null) { if (project.exists() && project.hasNature(nature)) { // first remove all problem markers (including the // inherited ones) from Spring beans project if (nature.equals(SpringCore.NATURE_ID)) { project.deleteMarkers(SpringCore.MARKER_ID, true, IResource.DEPTH_INFINITE); } // now remove project nature IProjectDescription desc = project.getDescription(); String[] oldNatures = desc.getNatureIds(); String[] newNatures = new String[oldNatures.length - 1]; int newIndex = oldNatures.length - 2; for (int i = oldNatures.length - 1; i >= 0; i--) { if (!oldNatures[i].equals(nature)) { newNatures[newIndex--] = oldNatures[i]; } } desc.setNatureIds(newNatures); project.setDescription(desc, monitor); } } }

 

添加Builder

 

/** * Adds given builder to specified project. */ public static void addProjectBuilder(IProject project, String builderID, IProgressMonitor monitor) throws CoreException { IProjectDescription desc = project.getDescription(); ICommand oldBuilderCommand = getProjectBuilderCommand(desc, builderID); if (oldBuilderCommand == null) { // Add a new build spec ICommand command = desc.newCommand(); command.setBuilderName(builderID); // Commit the spec change into the project addProjectBuilderCommand(desc, command); project.setDescription(desc, monitor); } } 

删除Builder

/** * Removes given builder from specified project. */ public static void removeProjectBuilder(IProject project, String builderID, IProgressMonitor monitor) throws CoreException { if (project != null && builderID != null) { IProjectDescription desc = project.getDescription(); ICommand[] commands = desc.getBuildSpec(); for (int i = commands.length - 1; i >= 0; i--) { if (commands[i].getBuilderName().equals(builderID)) { ICommand[] newCommands = new ICommand[commands.length - 1]; System.arraycopy(commands, 0, newCommands, 0, i); System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1); // Commit the spec change into the project desc.setBuildSpec(newCommands); project.setDescription(desc, monitor); break; } } } }

 添加BuilderCommand

/** * Adds (or updates) a builder in given project description. */ public static void addProjectBuilderCommand(IProjectDescription description, ICommand command) throws CoreException { ICommand[] oldCommands = description.getBuildSpec(); ICommand oldBuilderCommand = getProjectBuilderCommand(description, command.getBuilderName()); ICommand[] newCommands; if (oldBuilderCommand == null) { // Add given builder to the end of the builder list newCommands = new ICommand[oldCommands.length + 1]; System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length); newCommands[oldCommands.length] = command; } else { // Replace old builder with given new one for (int i = 0, max = oldCommands.length; i < max; i++) { if (oldCommands[i] == oldBuilderCommand) { oldCommands[i] = command; break; } } newCommands = oldCommands; } description.setBuildSpec(newCommands); }

删除BuilderCommand

/** * Returns specified builder from given project description. */ public static ICommand getProjectBuilderCommand(IProjectDescription description, String builderID) throws CoreException { ICommand[] commands = description.getBuildSpec(); for (int i = commands.length - 1; i >= 0; i--) { if (commands[i].getBuilderName().equals(builderID)) { return commands[i]; } } return null; }

 

 

 

 

 

 

 

 

StProjectNature

/** * 配置项目的性质,主要目的是为项目添加构建器 */ public void configure() throws CoreException { IProjectDescription desc = project.getDescription(); ICommand builderCommand = getBuilderCommand(desc, SoTowerProjectPlugin.BUILDER_ID); if (builderCommand == null) { ICommand command = desc.newCommand(); command.setBuilderName(StProjectPlugin.BUILDER_ID); setBuilderCommand(desc, command); project.setDescription(desc, new NullProgressMonitor()); } } /** * 向项目添加构建器 * * @param description 项目描述 * @param command 与构建器对应的构建命令 * @throws CoreException */ private void setBuilderCommand(IProjectDescription description, ICommand command) throws CoreException { ICommand[] oldCommands = description.getBuildSpec(); ICommand[] newCommands = new ICommand[oldCommands.length + 1]; System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length); newCommands[oldCommands.length] = command; description.setBuildSpec(newCommands); } /** * 获得项目的某个特定构建器 * * @param description 项目描述 * @param builderID 构建器ID * @return * @throws CoreException */ private ICommand getBuilderCommand(IProjectDescription description, String builderID) throws CoreException { for (ICommand command : description.getBuildSpec()) { if (command.getBuilderName().equals(builderID)) { return command; } } return null; } /** * 把性质从项目中移除 */ public void deconfigure() throws CoreException {}


 

分享到:
评论

相关推荐

    Flex Builder3+FDT3 环境配置及设置

    1. **转换为Flex项目**:右键点击项目,选择`Flex Project Nature` -&gt; `Add Actionscript Project Nature`,将项目转换为Flex AS项目。 2. **设置项目属性**: - `Actionscript Application`:指定项目的主类。 -...

    myeclipse项目转换成eclipse

    &lt;name&gt;org.eclipse.wst.common.project.facet.core.builder &lt;name&gt;org.eclipse.wst.validation.validationbuilder ``` 2. **刷新项目**: - 保存对`.project`文件所做的更改后,回到Eclipse IDE。 -...

    把外部项目导入eclipse

    &lt;name&gt;org.eclipse.wst.common.project.facet.core.builder &lt;name&gt;org.eclipse.wst.validation.validationbuilder ... ``` 然后,刷新项目,选择 Java 1.6 和 Dynamic Web Module 2.5,点击 OK。 ...

    向eclipse中导入外部项目

    (2)然后修改 Eclipse 工程下的 .project 文件:在 &lt;natures&gt; &lt;/natures&gt; 中加入 &lt;nature&gt;org.eclipse.wst.common.project.facet.core.nature&lt;/nature&gt;、&lt;nature&gt;org.eclipse.wst.common.modulecore....

    J2EE项目整合FLEX项目

    4. **添加Flex项目特性**:右键点击项目,选择`Flex Project Nature` -&gt; `Add Flex Project Nature`,并在出现的界面中按照提示配置相关信息,如`Root Folder`、`Root URL`等。 5. **配置Flex Build Path**: - 在...

    TOT项目开放代码

    2. `.project`:这也是Eclipse项目的配置文件,包含项目设置,如构建配置、Nature(项目类型)和Builder(构建工具)信息。这有助于在Eclipse环境中管理和构建项目。 3. `build.properties`:这是一个Ant构建工具的...

    myeclipse工程转eclipse工程

    &lt;name&gt;org.eclipse.wst.common.project.facet.core.builder &lt;name&gt;org.eclipse.wst.validation.validationbuilder ``` 3. **重新打开项目**:通过File -&gt; Import -&gt; General -&gt; Existing Projects...

    Spring项目初学(二)

    `.project`文件是项目的元数据,同样由Eclipse生成,它定义了项目的特性,如构建配置、Nature(项目类型)和Builder(构建工具)。对于一个Spring项目,`.project`文件可能会包含Spring Nature,这使得IDE能够识别...

    专题资料(2021-2022年)j2ee项目整合flex.doc

    3. 在MyEclipse中,为项目添加Flex特性,通过右键菜单选择Flex Project Nature并设置相应的项目属性,如Root folder、Root URL、Context root和Output folder。 4. 配置Flex Build Path,指定源代码文件夹(flex_src)...

    webwork_helloworld

    确认`.project`文件中的项目配置与WebWork项目需求一致,例如,确保它包含了Web项目应有的Nature和Builder。 `webtest`可能是一个测试目录,WebWork项目通常会包含JUnit测试来验证功能。在这个目录下,你可以找到...

    Java swing mysql(Oracle)实现的飞机订票系统项目

    &lt;name&gt;plane &lt;comment&gt;&lt;/comment&gt; &lt;name&gt;org.eclipse.jdt.core.javabuilder &lt;nature&gt;org.eclipse.jdt.core.javanature&lt;/nature&gt; &lt;/projectDescription&gt;

    aszip源代码

    【.project】文件是Eclipse或Flash Builder项目的元数据文件,定义了项目的结构、构建路径、nature(项目类型)等信息,使得IDE可以识别和管理项目。 【.flexLibProperties】文件是Flex项目的特定属性文件,它记录...

    JavaFx-文件删除小工具(源码)

    对于JavaFX项目,可能会包含特定的JavaFX nature,以支持JavaFX相关的构建和运行步骤。 `de`和`src`目录通常包含源代码文件。`de`可能代表德语(Deutsch)的缩写,但在这里更可能是代码组织的一个层次结构,而`src`...

    MyEclipse Web工程 完美移植到Eclipse WTP

    `&lt;name&gt;org.eclipse.wst.common.project.facet.core.builder&lt;/name&gt;` `&lt;arguments&gt;` `&lt;/arguments&gt;` - `&lt;buildCommand&gt;` `&lt;name&gt;org.eclipse.wst.validation.validationbuilder&lt;/name&gt;` `&lt;arguments&gt;` `...

    Eclipse导入问题整理以及解决方案

    &lt;name&gt;org.eclipse.jdt.core.javabuilder &lt;arguments&gt;&lt;/arguments&gt; &lt;name&gt;com.android.ide.eclipse.adt.ApkBuilder&lt;/name&gt; &lt;arguments&gt;&lt;/arguments&gt; &lt;nature&gt;...

    hrSys_zhanglianzhe.zip

    接着,`.project`文件同样属于Eclipse项目配置的一部分,它定义了项目的基本属性,如项目名称、Nature(项目类型)以及Builder(编译器)等。通过这个文件,我们可以推断该项目是使用Java语言开发的,并且可能采用了...

    flex源码Book.zip

    3. `.project`:这是Eclipse IDE(包括Flash Builder)的项目配置文件,它包含了项目的基本元数据,如项目名称、构建路径、nature(项目类型)等。这个文件让IDE知道如何管理项目,并执行构建过程。 4. `.settings`...

    备份软件

    2. `.project`: 这同样是Eclipse项目的一个配置文件,包含了项目的构建信息、Nature(项目特性)和Builder(构建器)设置。通过这个文件,可以重新导入和设置项目环境,恢复开发环境的原貌。 3. `ROOT`: 这可能是...

    androidSNS.zip

    3. **.project**:同样来自Eclipse,这是一个XML文件,包含项目的构建信息、构建路径、Natures(如Android Nature)和Builder设置。它帮助Eclipse识别项目类型并正确配置开发环境。 4. **project.properties**:这...

Global site tag (gtag.js) - Google Analytics