[GRADLE-1974] eclipse-wtp plugin doesn't add 'Web Libraries' classpath container to jst.web applications Created: 30/Nov/11  Updated: 04/Jan/13  Resolved: 02/Apr/12

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.0-rc-1

Type: Bug
Reporter: Kris De Volder Assignee: Szczepan Faber
Resolution: Fixed Votes: 3


For details, please see https://issuetracker.springsource.com/browse/STS-2185

I've already implemented a workaround/fix in STS (i.e. STS gradle import wizard will add the missing container on importing such projects). However, I think ultimately this is a bug in the gradle eclipse-wtp plugin and it should be fixed there instead/as-well.

This will affect projects that use the "web-app/WEB-INF/lib" folder to store jars they want to compile against and deploy with their web application.

Comment by Szczepan Faber [ 10/Mar/12 ]

Should the 'web libraries' container be added for every kind of project? Or only for those that use jars from web-app/web-inf/lib folder? Or maybe for those that have the web-app/WEB-INF/lib folder?


Comment by Mauro Molinari [ 11/Mar/12 ]

IMHO it should be added to every kind of Faceted Project with a Deployment Assembly (for instance: Dynamic Web Project, Utility Project...). The user will then be free to add the WEB-INF/lib folder or not, and to add new JARs in there if he/she needs to. Otherwise he/she would need to manually add the "Web Libraries" classpath container first.

Comment by Szczepan Faber [ 11/Mar/12 ]

>IMHO it should be added to every kind of Faceted Project with a Deployment Assembly (for instance: Dynamic Web Project, Utility Project...)

Ok, what does it mean for gradle? We only do web projects or ear projects at the moment. If I read you correctly, we should add 'web libraries' for every web project, that is for every gradle project that uses 'war' and 'eclipse-wtp' plugin. Do you concur?

Thanks a lot for help!

Comment by Mauro Molinari [ 11/Mar/12 ]

Well, after thinking on this more, I just elaborated that:

  • if you apply the eclipse-wtp plugin but not the war plugin, a WTP Utility project is created from that project
  • if you apply both the eclipse-wtp plugin and the war plugin, a WTP Dynamic Web Project (i.e.: a web application) is created from that project

In Eclipse world, both these types of project can have a "web content" folder and so a WEB-INF/lib folder in it, containing JARs to be deployed.

However, while in the second case I'm convinced that the "Web App Libraries" container should always be present (because you're actually setting up a web application), in the first case it might be too invasive to always put that container in the Eclipse project build path, especially since it is somewhat needed for all the projects your war+eclipse-wtp project depends on to also have the eclipse-wtp plugin applied (see GRADLE-1880) in order to get a valid Eclipse WTP project setup.

In addition to this, in Gradle world only projects applying the war plugin can have a src/main/webapp folder containing web content: for this reason, I don't think it would even work to add the "Web App Libraries" classpath container to projects that only apply the eclipse-wtp plugin, since the corresponding Eclipse WTP project wouldn't have any Web Content folder in its Deployment Assembly from which to pick the WEB-INF/lib folder to feed the "Web App Libraries" classpath container.

For this reason, I would say that the "Web App Libraries" classpath container should always be added when creating the corresponding Eclipse project of a Gradle project that applies both the war and the eclipse-wtp plugins.

Please note that I don't know the ear plugin at all and what Eclipse project will be created from a Gradle project that applies both that plugin and the eclipse-wtp one. However, I guess that the "Web App Libraries" should be added in that case too.

Comment by Szczepan Faber [ 11/Mar/12 ]

>if you apply the eclipse-wtp plugin but not the war plugin

Hmmm, I didn't know about this use case. I thought that applying eclipse-wtp without 'war' (or at least 'ear') does not make sense.

My current plan is to create the classpath container when 'war'+'eclipse-wtp' are both applied. I'll leave out the ear for now as we don't have anyone asking for this feature. Also it doesn't feel right that every ear has 'web libraries' container because the ear archive might be unrelated to the web.

Mauro, thanks a lot for the comprehensive information. It is greatly helpful as I'm not a domain expert in the eclipse-wtp and without your help the problem would be very difficult to solve.

Comment by Szczepan Faber [ 17/Mar/12 ]

I think I'd prefer not to add the container by default but instead provide a simple way of doing that if someone needs it. The reason is that the container does not add any value for a project that does not keep libraries in WEB-INF/lib. So if a project does need the container I'd prefer it to be explicitly declared in the build.

It's kind of easy to add the container via the existing api:

eclipse.classpath.containers 'org.eclipse.jst.j2ee.internal.web.container'

However, it does feel a bit to low-level since the casual eclipse user does not read the metadata files and he only uses the Eclipse. Eclipse refers to the container as 'Web App Libraries' and not via the fully qualified magic name.

So I would add a simple DSL, a convenience method for adding that container:


Down the road, above method can add different container for a different wtp project (ie. ear uses a different container). However, for now it'll just add the web libraries container.

So that's the current plan, please don't hesitate to give feedback

Comment by Mauro Molinari [ 19/Mar/12 ]

It's acceptable, thank you. My only concern is about documentation: I think this part of Gradle needs better documentation. I mean, also GRADLE-1880 is something I discovered by trial and error. Also, things like https://issuetracker.springsource.com/browse/STS-2065?focusedCommentId=48367&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-48367 (that is, the need to apply the eclipse-wtp plugin and not just the eclipse plugin in order to obtain a "web application project" in Eclipse from a Gradle project that applies the war plugin) are aspects that are not so clear when you try to first approach Gradle and you're normally using Eclipse WebTools Platform to develop web applications.

Thank you Szczepan!

Comment by Szczepan Faber [ 27/Mar/12 ]

I had a chat with Adam about this feature today. I'm more inclined to actually add the 'web libs' container by default for every war+wtp combo. The reason is that Gradle automatically uses the content of WEB-INF/lib when creating war so it feels the IDE plugin should also automatically use it. Feel free to give feedback!

Comment by Kris De Volder [ 27/Mar/12 ]

Agreed. It would be best to be consistent. Also I tend to prefer a solution that works by default/convention and doesn't require the user to do something special to indicate they want the container added.

If an empty container is added it is not a big deal. I don't even think it will show up in the Eclipse UI if it is empty.

Mauro is really the one who uses this stuff, so his opinion carries more weight than mine here


Comment by Mauro Molinari [ 28/Mar/12 ]

As I previously said in my comment of 11 March 2012, for me it's good to always add the container for every war+wtp project. Thank you.

Comment by Szczepan Faber [ 02/Apr/12 ]

Ok, we're adding the container for every 'war' + 'eclipse-wtp' plugin combo.

Thanks guys for help!

Generated at Wed Jun 30 12:09:23 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.