|
|
|
Attached test project. This project was created with eclipse 3.1.2 (WTP 1.0) and managed with the Maven 2.x Extension for Eclipse. It has 3 dependencies on jstl, standard and commons-lang, none of which are copied to WEB-INF/lib when you perform a "Run -> Run on Server" operation.
For these dependencies to be correctly copied, the maven 2 extension would have to create entries in .settings/.component like the ones that I have manually written (and commented) there. Hello,
I am using Eclipse 3.2 RC2 with the latest (also RC2) Callisto update site modules (Web Standard Tools Version: 1.5.0.v200604030005-eYe38P_OHPq8Dcd) and Maven plugin 0.0.6 and having the same issue. Resolving this request would really boost dev cycle. Regards, From http://blogs.unixage.com/blojsom/blog/adam.kruszewski/?month=5&year=2006
I have hacked a little eclipse plugin to do the dirty work for me, and by "dirty work" I mean linking maven resolved dependencies directly into "src/main/webapp/WEB-INF/lib", which results in double classpath entries in project but at last WTP publish the application with all the libraries. Now I can use maven within Eclipse for every project type I could dream of. If you want to obtain the plugin just point the update manager to http://adam.kruszewski.name/eclipse/ I've been stepping through the WTP code, and have as a result raised this improvement request:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=154165 I wonder if someone who is much more familiar with the Eclipse extensibility framework could have a look and see whether there is anything that can be done without an alteration to WTP. Questions I immediately have are:
I'm afraid I'm very green when it comes to the Eclipse plugin framework. The way I work around this is to add a m2 builder which calls war:inplace
Then, every time my project builds, maven gets invoked and copies the jars out to the correct location. With all due respect, this issue has been open for a year. It is the most popular issue open. Your discussion with Rob Frost on the Eclipse bug broke off a month ago with no resolution. I wasted a week or so trying to solve this problem a few months ago, and now there is a relatively simple way to get what I, at least, want - namely that dependencies int he POM with scope "compile" and "runtime" will be included in the WEB-INF/lib folder when WTP publishes a WAR.
Whether that happens by putting WTP putting containers in WEB-INF/lib and M2Eclipse setting up the containers on a scope basis from the POM, or by M2Eclipse setting in memory attributes on individual classpath entries, is largely academic to me. The reality is that WTP doesn't support the latter approach and isn't going to in the near future. What's more, it isn't a hack to do it; whether Maven dependencies are in a single classpath container or separated into different classpath containers by scope is largely a matter of preference unrelated to WTP, and can be made optional. After that the functionality is all on WTP's side. If you can give me a steer as to how you would like me to work on this, which does not involve touching the WTP or JDT code, great, fire away. Otherwise I'll carry on, as I'd rather produce a tactical solution that works on Monday, even if it gets superseded, than wait another year whilst you try and get a change made to Eclipse. OK, worked it out - you mean mark the Maven classpath container for deployment to WEB-INF/lib in the .classpath file, and then put a "nondeploy" attribute on all the test and provided scope jars.
The separate classpath container solution seems more elegant to me, I have to say, but I'll do it your way. > [Scope specific classpath container] approach will cause more troubles then benefits it would give Can I ask why? Not that I don't believe you, I'm just interested. I rather agree with Tomasz that a visual way of seeing which dependencies are in which scope would be nice generally. I am concerned with keeping multiple containers in sync. For example, when entry changes scope, it may appear in bot containers for some period of time and that would break the JDT compiler. Such kind of corner cases will be difficult to work around.
For visualizing part, one can probably contribute a label decorator, or special model for Project Explorer that would do some fancy stuff. OK, thanks. I see the problem.
Are you happy for me to have a go at getting the WTP thing working? Sure. Hack away. I am not really using WTP on a daily base and can only verify correctness from the point of JDT.
I have a proposal that needs discussion. As this
As such I suggest giving the user the option for POM entries that resolve to projects in the workspace simply to be ignored by the M2Eclipse plugin, so that the user can then handle them in the standard Eclipse and WTP way (making them a dependent project and a J2EE module). Happy to produce a patch to this effect. So long as it's only an option it should be OK, shouldn't it? (The other possibility would be to add them as a required project on the build path and then do a check for WTP and if it is present add them as a J2EE module; this would have the advantage of making the user's life easier, though it would be a touch more complicated to code.) Then when WTP has developed a bit (and hopefully abandoned the .component file!) this option could be removed and we could return to the more elegant everything in the Maven2 Classpath Container model. I've attached an initial effort. Sorry it took so long, I had forgotten Sunday was a write off due to family commitments.
It's a tactical solution which is intended to be as non-invasive as possible. No dependency on WTP naturally. Fairly limited. What it does: What it doesn't do: The thinking is that the user is responsible for ensuring that the war project is a WTP Dynamic Web Project and for adding any client workspace projects to it as J2EE Module Dependencies via the GUI. The user is also responsible for editing the relevant org.eclipse.wst.common.component files to prevent test classes and resources being published (irritatingly there is no GUI way of doing this provided by WTP). As I say, limited, but at least it is now possible, with a little intervention, to use the M2Eclipse plugin in conjunction with WTP to control the dependency management for wars and publish them via WTP, which was my initial goal. Next objectives - I'd like to handle "what it doesn't do" 2 & 4, at a minimum, and have a look at 3 depending on how much support there is in the WTP project for turning an existing project into a dynamic web project. I'd also like to be a bit cleverer about when the plug-in does and doesn't do things.
In order to do that I will unavoidably have to use WTP classes, but obviously it is deeply undesirable to have the M2Eclipse plugin dependent on the whole of WTP. So I'm going to look into creating an extension point and a child plug-in to handle WTP specific things. Long term this is probably all unnecessary - as is mentioned here Hello Everybody,
if you still strugle with WTP support, i supose to give thirty party to handle resolved dependencies by their needs. I think that Classpath container should be extendable by extension point defined in maven core plugin. A wtp project or any other project that need handle its classpath in different way, they will just implement extension point of maven. And maven will ask defined extension points who is responsible for certain project and that implementation will be finally used. BTW: I was developing & playing with "automatically add client workspace projects as J2EE Module Dependencies", right now it +- works for me, but i would like to discuss with you how to deal with wtp like projects, because not everybody can use WTP2.0, so there should be still support for WTP1.5 also in any bad way, but it should be there! Using extension points we can fulfill both supports and it will not split comunity as well. What do you think about my proposal? Robert, Andrej... have you managed to move forward on this issue?
I noticed that the patch has not been commited and it no longer applyies cleanly against latest SVN. I'm willing to work on a solution for Eclipse 3.3 / WTP 2.0, but I won't like to step over someone else's work. Hi Abel,
currently i have created extension point for that and all necessarily thinks, but implementation of extension point is not finished, i would like to based it on the Robert patch. But anyway Eugene is boss and i am as the same volunteer as you are and i think we should more discuss with someone responsible for real solution, for example by skype and then create tasks and distribute what to do, what do you think? Very quick review of my changes:
-Extended add dependency actions Andrej, please note that it is very time consuming and in result practically impossible to apply patches that are built on something or fixing multiple bugs, even if there is no conflicts. Your patch is conflicting with my workspace, hence I can't apply it.
Please read correspond page on the project wiki. http://docs.codehaus.org/display/M2ECLIPSE/How+To+Contribute+Patches This patch against latest SVN adds attributes to the Maven2ClasspathContainer and the managed jars with the appropriate scope. It's basically Robert Elliot's patch with a couple of changes.
Currently, the attributes are only added for war projects, and only if the WTP nature (2.0 version) is found (the project must be a dynamic web project). For testing, use the updated eclipse project (in teh original one the packaging=war was missing from the pom). With the project as-is, testing to deploy will fail. Once the Maven2 plugin is enabled on the project, after refresing the webapp the JSP page displays properly. Remember that the WTP WebContent folder must match the maven webapp folder (by now, this must be done manually). It would be great if someone could verify this and we could have the changes committed. I would vote for treating support for other WTP versions as different JIRA issues. Then we can think if an extension point is needed to handle different WTP flavors. Sorry, I uploaded the wrong project. This (
Note: The "mylyn-context.zip" is teh task context used by the Mylyn plugin... it was attached when using the JIRA connector before I noticed... I'll look into avoiding that in the future (unless project owners think sharing Mylyn contexts is OK). I'm uploading a version of the org.maven.ide.eclipse with the patch applyied to simplify testing.
It will be available in a few minutes from http://candy4appfuse.sourceforge.net/tmp/org.maven.ide.eclipse_0.0.11.20070707-0122.jar Is patch
After patching i got new BuildPathManager.java file with following lines (249-256): // Check the scope & set WTP non-dependency as appropriate
List attributeList = new ArrayList();
String scope = a.getScope();
if (Artifact.SCOPE_PROVIDED.equals(scope)
|| Artifact.SCOPE_TEST.equals(scope)
|| Artifact.SCOPE_SYSTEM.equals(scope)) {
attributeList.add(JavaCore.newClasspathAttribute(CLASSPATH_COMPONENT_NON_DEPENDENCY, ""));
}
But attributeList variable i never used/read in rest of this file. Yes, there seems to be an error. I'll look into it when I find the time.
Attached a fixed patch. Now attributes are correctly added.
For testing against an existing m2eclipse project, please disable m2eclipse support and re-enable it. Hello Abel,
Could you please kindly post the jar with the latest patch? I've uploaded the plugin to: http://personales.ya.com/abelmuino/tmp/org.maven.ide.eclipse_0.0.11.20070731-0000.jar
However, it is non official and unsupported. I have been reading a lot on the dependency resolution issues with the M2Eclipse plugin and the Eclipse WTP. It seems that this solutions is the one that is being recommended, but does anyone know it this is the case and if so is there any estimate as to when it would be included or released as a bug fix on the update site?
Sorry about delay with reviewing this patch. Unfortunately I can't apply it because of the massive refactorings in the code. Can you please merge from trunk and recreate this patch?
Also, I have one comment about implementation based on fragments of your patch. I don't think it is necessary to check for any wtp natures and everything should be based on the stuff you have in pom.xml I won't be able to update the patch before October 12th. After that date, I'll try to find the time for merging it against latest SVN.
If anybody interested: I have patched release version (0.0.11.20070916-2300) with patch from Abel.
Note: I did it explicitly against the release and not against the trunk because I actually needed exactly that: released version of m2eclipse with minimal changes. I am interested by this patched version. Could you put a patched jar on a web server, like Abel did ?
I hope Abel will have the time to reintegrate his patch with the lastest SVN, a lot of people are waiting on this bug. I am really surprised that it is not targeted for 0.12 release, as it is a must to have for all J2EE developers ... I'll try to look at this patch this week.
Eugene, I have attached an improved patch, again against the 0.0.11 release.
What it does: 2. Leaves out any dependencies in the POM that exist as projects in the filesystem IF WTP is loaded, the project has packaging "war" and the WTP natures. This is so that the project can be added as a J2EE Module Dependency via WTP specific UI. 3. The patch of Abel also added the WTP dependency attribute to the Maven2 Dependencies classpath container in any project that has packaging "war". My patch does NOT do it. The reason: if m2eclipse does it automatically then there is no way to switch this off. WTP UI can already handle this anyway. For my projects there is a single remaining issue: I am getting a WTP warning for a "utility" project: Classpath entry org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result. After poking around WTP 2.0.1 I'd sa | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I also suspect that this will be very different for WTP 1.5, since they have changed these settings.