简体   繁体   English

为什么我不能在Java项目中添加“Groovy Nature”?

[英]Why can't I add a “Groovy Nature” to a java project?

I have some java projects that have been around for a long time and am currently using a pretty recent version of SpringSource Toolsuite and the groovy plugin which works fine (this was added for people who don't read beyond the first paragraph). 我有一些已经存在很长时间的java项目,目前我正在使用最新版本的SpringSource Toolsuite和groovy插件,它工作正常(这是为那些没有阅读超出第一段的人添加的)。

I can create a Groovy project or I can convert a Java project to a groovy project, but I'd really like to add a Groovy nature to my java project (I don't think the team would be very happy about me converting all the projects over to groovy projects!) 我可以创建一个Groovy项目,或者我可以将Java项目转换为groovy项目,但我真的想在我的java项目中添加一个Groovy特性(我不认为团队会对我转换所有的项目到常规项目!)

The problem is that the "Groovy" menu item containing "Add Groovy Nature" doesn't appear in any java projects (legacy projects or new ones I create). 问题是包含“添加Groovy Nature”的“Groovy”菜单项不会出现在任何Java项目(遗留项目或我创建的新项目)中。 It appears in a Groovy project with "Remove Groovy Nature", but not in java projects. 它出现在一个带有“删除Groovy Nature”的Groovy项目中,但在java项目中却没有。

Everything else works pretty well. 其他一切都很好。

Oh also, not using maven, just straight eclipse & ant--I can deal with the Ant part it's just the eclipse integration that's being probleematic. 哦,也没有使用maven,只是直接eclipse和蚂蚁 - 我可以处理Ant部分它只是有问题的eclipse集成。

Am I missing a setting or something? 我错过了一个设置还是什么?

My colleague and I had the same problem today. 我和我的同事今天遇到了同样的问题。 We manually fixed it using basically this process: 我们基本上使用这个过程手动修复它:

  1. Clean all projects without starting a new build. 无需启动新构建即可清理所有项目。
  2. Exit eclipse. 退出日食。
  3. Add/edit the project configuration files below. 添加/编辑下面的项目配置文件。
  4. Start eclipse. 开始日食。
  5. Refresh project. 刷新项目。
  6. Enable Project->Build Automatically. 启用项目 - >自动构建。

Here are the files to add/edit: 以下是要添加/编辑的文件:

  • .project : Add this line to the <natures> element: .project :将此行添加到<natures>元素:

     <nature>org.eclipse.jdt.groovy.core.groovyNature</nature> 
  • .classpath : Add this line: .classpath :添加以下行:

     <classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/> 
  • .settings/org.eclipse.jdt.groovy.core.prefs : New file: .settings / org.eclipse.jdt.groovy.core.prefs :新文件:

     eclipse.preferences.version=1 groovy.compiler.level=-1 

Note that the target project was already a java project. 请注意,目标项目已经是一个java项目。 To add this stuff to a plain or other non-java project, you might also need to add the following: 要将此内容添加到普通或其他非Java项目,您可能还需要添加以下内容:

  • .project : .project

     <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> 
  • .classpath : Copy from one of your java projects and edit appropriately. .classpath :从您的一个Java项目中复制并进行适当的编辑。 Here's a default .classpath file: 这是一个默认的.classpath文件:

     <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> </classpath> 

Install Groovy eclipse plugin 安装Groovy eclipse插件

http://groovy.codehaus.org/Eclipse+Plugin http://groovy.codehaus.org/Eclipse+Plugin

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM