-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Groovlets causing "The declared package "" does not match the expected package" warning #492
Comments
Could you supply a small sample project? I'm not familiar with groovlets. I'd like to understand if WEB-INF is being seen as within a source folder or not. |
The attached zip is of my eclipse project with everything deleted except the overall project structure and one groovlet. In the original, there are .jsp files right along-side the groovlet files. Groovlets are described here: http://docs.groovy-lang.org/latest/html/documentation/servlet-userguide.html . The idea is you create a servlet mapping between groovy.servlet.GroovyServlet and your .groovy scripts in your web.xml. At runtime, when someone hits a url that maps to a .groovy script, GroovyServlet compiles it (much like a JSP is compiled the first time it is referenced). I should add, this is actually an error, not a warning. I am able to work around it since my build is actually done via Ant so having this build error in eclipse isn't holding me up. |
From what I can tell from your sample project, you don't actually need to have the source and output folders defined in the <classpath>
<!--classpathentry kind="src" path=""/>
<classpathentry kind="output" path=""/-->
<classpathentry kind="con" path="GROOVY_SUPPORT"/>
<classpathentry kind="con" path="GROOVY_DSL_SUPPORT"/>
<!--classpathentry kind="lib" path="R:/third_party/sun/J2EE/EJB/v7.0/lib/j2ee.jar"/-->
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
</classpath> |
In the real project, there are java and groovy source code files that do get compiled but they are not under webApplication/WEB-INF. They are in packages that start at the root of the project's source path (e.g., com.ils.ediag...). The files under WEB-INF are xml, groovy, and jsp files. What is probably most important to keep in mind is this project has existed for years with groovlets and did not have this problem last week. |
Sure, but the META-INF and WEB-INF stuff is not meant to be compiled, correct? You are specifying your entire project as a source container, therefore any Java or Groovy sources contained within are compiled. If you don't want your groovlet sources to get compiled, they should be moved off the build path or marked as Groovy scripts. To indicate that everything in webApplication/WEB-INF is a script, you need to check the box "Enable project specific settings" on the Groovy Compiler page. |
I tried the "Enable project specific settings" on the Groovy Compiler page specifying this as a groovy script filter: "webApplication/WEB-INF/**/*.groovy" but that has no effect. If I use that same criteria as an eclipse source exclusion filter, the errors go away. Do you know what is wrong with the groovy script filter: "webApplication/WEB-INF/**/*.groovy"? I guess I'm fine with having to add this, this is an old project that was set up before I joined the company (although I did add Groovy to it). It's just that this was not a problem last week. The only thing that changed was an update to th plugin. |
Nothing wrong with the filter. I am trying it out now to be sure everything holds. The script is still being processed as a compilation unit to a point and the package check is still being performed. There was a check for scripts as part of the package name check. I'm checking on that now. |
Could you update to the latest and test again with the script filter enabled? |
The script filter is now solving the problem. Thanks! |
I think the fix for "No warning for source unit with missing package statement #473" is causing problems for projects with groovlets. Very recently, Eclipse Oxygen 2 with v 3.0.0 of the plugin started showing warnings like the following for all of the .groovy files I have under webApplication/WEB-INF: "The declared package "" does not match the expected package "webApplication.WEB-INF.toolDelete" Because these files are "groovlets," they are not supposed to have a package name. They are scripts that get compiled by groovy.servlet.GroovyServlet.
I looked for a way to tell the plugin to treat any .groovy file under webApplication/WEB-INF as scripts but I could not figure out what to add to the "Groovy Script Folder" section of the Groovy Preferences panel.
Thanks in advance!
The text was updated successfully, but these errors were encountered: