Maven 2.x Eclipse Plugin

WTP-2.0 support with howto apt, refactoring and contextroot handling

Details

  • Testcase included:
    yes
  • Patch Submitted:
    Yes
  • Number of attachments :
    7

Description

This patch contains:

  • WTP.2.0 support for ear and war's (includes MECLIPSE-264)
  • context root handling very much improved
    (war takes configuration from the ear, if available)
  • refactoring (constant usage, foreign plug-in access centralized)
  • a detailed description how we use maven-2 with WTP in multi module projects
  • testing code included

the patch is attached, together with a tar with all the new files.

  1. maven-eclipse-plugin_only_new_2.tar.tgz
    29/Oct/07 3:15 AM
    3 kB
    Richard van Nieuwenhoven
  2. maven-eclipse-plugin_only_new.tar.gz
    19/Oct/07 7:48 AM
    17 kB
    Richard van Nieuwenhoven
  3. wtp-2.0-and-more-2.5-SNAPSHOT.patch
    19/Oct/07 7:48 AM
    136 kB
    Richard van Nieuwenhoven
  4. wtp-2.0-and-more-2.5-SNAPSHOT-2.patch
    29/Oct/07 3:15 AM
    31 kB
    Richard van Nieuwenhoven
  5. wtp-2.0-and-more-2.5-SNAPSHOT-3.patch
    29/Oct/07 3:15 AM
    0.8 kB
    Richard van Nieuwenhoven
  1. Eclipse-3.3.0-about.png
    44 kB
    10/Dec/07 4:22 AM
  2. Eclipse-3.3.0-project-upgrade.png
    28 kB
    10/Dec/07 4:22 AM

Issue Links

Activity

Hide
peter maedel added a comment -

Seems to me to be a pretty good improvement, though i got some trouble patching my maven installation.

could you explain me how to patch the affected files? Somehow I cannot find any point in my repository where "patch -p0 < wtp-2.0-and-more-2.5-SNAPSHOT.patch" seems to work? Im using Maven 2.0.7 and patch of gnuwin32

Show
peter maedel added a comment - Seems to me to be a pretty good improvement, though i got some trouble patching my maven installation. could you explain me how to patch the affected files? Somehow I cannot find any point in my repository where "patch -p0 < wtp-2.0-and-more-2.5-SNAPSHOT.patch" seems to work? Im using Maven 2.0.7 and patch of gnuwin32
Hide
Richard van Nieuwenhoven added a comment -

you will have to checkout the sources and apply the patch to it (and add the additional files from the tar)

Show
Richard van Nieuwenhoven added a comment - you will have to checkout the sources and apply the patch to it (and add the additional files from the tar)
Hide
Pascal Thivent added a comment -

I have downloaded the tar with all new files and applied the patch on a clean maven-eclipse-plugin checkout.

I ran mvn install and got one error in the testJeeSimple() method of the EclipsePluginTest because of a missing dependency. I did a mvn install on the j2ee-simple bundled project as workaround to make the build pass. I can't remember out of my head which artifact was missing but I finally succeeded to build the plugin without skipping the tests. The strange part is that I just tried to reproduce this (after a mvn clean and removing everything related to the plugin from my local repository) but... unsuccessfully. When I check target\test-classes\m2repo\root\project, I see all required artifacts this time so they must have been build correctly. This try has been done under WindowsXP when the first attempt was under Linux. I'll try again at home.

Another thing : I'm using a JDK6 and noticed I had to add some maven-compiler-plugin configuration in my pom.xml to get the correct Java Facet in eclipse. Without this, the generated Java Facet was 1.4. This happens only when I had configuration for WTP2.0 support. This is non blocking but I just wanted to let you know.

Nice work anyway.

Show
Pascal Thivent added a comment - I have downloaded the tar with all new files and applied the patch on a clean maven-eclipse-plugin checkout. I ran mvn install and got one error in the testJeeSimple() method of the EclipsePluginTest because of a missing dependency. I did a mvn install on the j2ee-simple bundled project as workaround to make the build pass. I can't remember out of my head which artifact was missing but I finally succeeded to build the plugin without skipping the tests. The strange part is that I just tried to reproduce this (after a mvn clean and removing everything related to the plugin from my local repository) but... unsuccessfully. When I check target\test-classes\m2repo\root\project, I see all required artifacts this time so they must have been build correctly. This try has been done under WindowsXP when the first attempt was under Linux. I'll try again at home. Another thing : I'm using a JDK6 and noticed I had to add some maven-compiler-plugin configuration in my pom.xml to get the correct Java Facet in eclipse. Without this, the generated Java Facet was 1.4. This happens only when I had configuration for WTP2.0 support. This is non blocking but I just wanted to let you know. Nice work anyway.
Hide
Martin Zeltner added a comment -

I've patched the plugin but in Eclipse I still not have the expected result.

I have a jar artifact A and two war artifacts B & C. C depends on B depends on A. In A I've defined some general usable classes. In B I've added some web resources like the index.html (in web root), my.css and so on. In C I've added another index.html (also in web root).

What I would expect when A, B and C are as projects (Maven reactor projects) imported in Eclipse workspace:
When I deploy C on server (Tomcat, within Eclipse of course) I would expect the index.html of C, the my.css of B (and all other web resources of B) in web's root dir and the classes of A in WEB-INF/classes.

What I get:
As web resources I just get the index.html of C and NO web resources of B. Instead I get a JAR in WEB-INF/lib/B.jar with the complete artifact tree!! The classes of A are not directly placed in WEB-INF/classes but packed as jar in WEB-INF/lib. I can live with that but copy the classes in WEB-INF/classes would be even faster (shorter round trips).

Could anyone correct this web resource bug? I can (if Eclipse "allows" it) do it but I need the "complete" "specification" (xsd?, would be great!) how does the generated files (.classpath, .project and the files in folder .settings) has to look like for WTP 2(.0.1).

Thanks for any comment!

Have a nice weekend!
Cheers,
Martin

Show
Martin Zeltner added a comment - I've patched the plugin but in Eclipse I still not have the expected result. I have a jar artifact A and two war artifacts B & C. C depends on B depends on A. In A I've defined some general usable classes. In B I've added some web resources like the index.html (in web root), my.css and so on. In C I've added another index.html (also in web root). What I would expect when A, B and C are as projects (Maven reactor projects) imported in Eclipse workspace: When I deploy C on server (Tomcat, within Eclipse of course) I would expect the index.html of C, the my.css of B (and all other web resources of B) in web's root dir and the classes of A in WEB-INF/classes. What I get: As web resources I just get the index.html of C and NO web resources of B. Instead I get a JAR in WEB-INF/lib/B.jar with the complete artifact tree!! The classes of A are not directly placed in WEB-INF/classes but packed as jar in WEB-INF/lib. I can live with that but copy the classes in WEB-INF/classes would be even faster (shorter round trips). Could anyone correct this web resource bug? I can (if Eclipse "allows" it) do it but I need the "complete" "specification" (xsd?, would be great!) how does the generated files (.classpath, .project and the files in folder .settings) has to look like for WTP 2(.0.1). Thanks for any comment! Have a nice weekend! Cheers, Martin
Hide
Richard van Nieuwenhoven added a comment -

as far as i know one should not make a dependency between war's. Does the war plugin handle such things at all?

When i need such a requirement i use a system like tobago uses. a jar resource that will be extracted in the dependent war resource .

As far as i know WTP has no other way to split the WebContent into to directories or even in two modules/projects.

The classes of a dependent jar will never be exploded in the WEB-INF/classes directory. WTP will package your dependent jar into WEB-INF/lib, as it should! and as maven does!
WTP will also do the hot deployment of your changed classes during debugging so no need of copying classes. When it can't update them just do a republish.

regards,
Ritchie

Show
Richard van Nieuwenhoven added a comment - as far as i know one should not make a dependency between war's. Does the war plugin handle such things at all? When i need such a requirement i use a system like tobago uses. a jar resource that will be extracted in the dependent war resource . As far as i know WTP has no other way to split the WebContent into to directories or even in two modules/projects. The classes of a dependent jar will never be exploded in the WEB-INF/classes directory. WTP will package your dependent jar into WEB-INF/lib, as it should! and as maven does! WTP will also do the hot deployment of your changed classes during debugging so no need of copying classes. When it can't update them just do a republish. regards, Ritchie
Hide
Richard van Nieuwenhoven added a comment -

here are the next incremental patches, with some fixes / improvements and tests

Show
Richard van Nieuwenhoven added a comment - here are the next incremental patches, with some fixes / improvements and tests
Hide
Martin Zeltner added a comment -

Hi Ritchie

The maven-war-plugin does war overriding. In some (very) old version (more than one year ago) it doesn't work. Via the configuration parameter "<archiveClasses>false</archiveClasses>" of the maven-war-plugin, it will create no jar of these classes and so put the classes directly into "WEB_INF/classes".

I will ask the people of Eclipse WTP if WAR overriding is possible in WTP 2, but the longer the more I believe that this is not possible. Bummer.
BTW, if you're interested in you could have a look at my project, http://el4j.sf.net

Cheers,
Martin

Show
Martin Zeltner added a comment - Hi Ritchie The maven-war-plugin does war overriding. In some (very) old version (more than one year ago) it doesn't work. Via the configuration parameter "<archiveClasses>false</archiveClasses>" of the maven-war-plugin, it will create no jar of these classes and so put the classes directly into "WEB_INF/classes". I will ask the people of Eclipse WTP if WAR overriding is possible in WTP 2, but the longer the more I believe that this is not possible. Bummer. BTW, if you're interested in you could have a look at my project, http://el4j.sf.net Cheers, Martin
Hide
Arnaud Heritier added a comment -

Richard, a remark : It seems that you reformatted some files which create a noise in patchs for nothing. Our code style conventions are explained here : http://maven.apache.org/guides/development/guide-m2-development.html#Maven_Code_Style

Show
Arnaud Heritier added a comment - Richard, a remark : It seems that you reformatted some files which create a noise in patchs for nothing. Our code style conventions are explained here : http://maven.apache.org/guides/development/guide-m2-development.html#Maven_Code_Style
Hide
Arnaud Heritier added a comment -

Richard, I cannot apply patchs 2 & 3 because it doesn't seems that they are unified diff. With which command line can I apply them ?

Show
Arnaud Heritier added a comment - Richard, I cannot apply patchs 2 & 3 because it doesn't seems that they are unified diff. With which command line can I apply them ?
Hide
Richard van Nieuwenhoven added a comment -

They should be applyable with "patch -p0". I used diff -u to create them.

The code style must have been wrong before, because i used the eclipse formatter with the "Maven code style" settings.

So after you apply the patches you could apply the Formatter / Clean-Up and the Organize imports to the hole project!

When you do not succeed with patches 2/3 commit the wtp-2 branch with patch-1 and i will generate a "svn diff" patch for them.

Show
Richard van Nieuwenhoven added a comment - They should be applyable with "patch -p0". I used diff -u to create them. The code style must have been wrong before, because i used the eclipse formatter with the "Maven code style" settings. So after you apply the patches you could apply the Formatter / Clean-Up and the Organize imports to the hole project! When you do not succeed with patches 2/3 commit the wtp-2 branch with patch-1 and i will generate a "svn diff" patch for them.
Hide
Richard van Nieuwenhoven added a comment -

Another question? should we report an error if the "archiveClasses" setting in the war configuration or war overriding was activated? because wtp-2/maven-eclipse-plugin can not handle them "yet".

Show
Richard van Nieuwenhoven added a comment - Another question? should we report an error if the "archiveClasses" setting in the war configuration or war overriding was activated? because wtp-2/maven-eclipse-plugin can not handle them "yet".
Hide
Arnaud Heritier added a comment -

Patch applied. Thanks guys for you help. Sorry for the delay

Show
Arnaud Heritier added a comment - Patch applied. Thanks guys for you help. Sorry for the delay
Hide
Martin Zeltner added a comment -

I'm working now with the maven-eclipse-plugin including this patch. I import the Eclipse projects into the workspace and close the workspace. The next time I open Eclipse with this workspace I get the screen like attached with name "Eclipse-3.3.0-project-upgrade.png". I use the Eclipse version "Europe" 3.3.0 (see attachement Eclipse-3.3.0-about.png). It seams that this patch produces the Eclipse files in an old style. Who could help to correct this issue?

Cheers,
Martin

Show
Martin Zeltner added a comment - I'm working now with the maven-eclipse-plugin including this patch. I import the Eclipse projects into the workspace and close the workspace. The next time I open Eclipse with this workspace I get the screen like attached with name "Eclipse-3.3.0-project-upgrade.png". I use the Eclipse version "Europe" 3.3.0 (see attachement Eclipse-3.3.0-about.png). It seams that this patch produces the Eclipse files in an old style. Who could help to correct this issue? Cheers, Martin
Hide
Richard van Nieuwenhoven added a comment -

please specify the parameters do you give eclipse:eclipse?
i use 3.3.1 and have no such problems and my parameters are:

-Declipse.wtpmanifest=true
-Declipse.wtpapplicationxml=true
-Dwtpversion=2.0

did you forget the wtpversion parameter?

Show
Richard van Nieuwenhoven added a comment - please specify the parameters do you give eclipse:eclipse? i use 3.3.1 and have no such problems and my parameters are: -Declipse.wtpmanifest=true -Declipse.wtpapplicationxml=true -Dwtpversion=2.0 did you forget the wtpversion parameter?
Hide
Martin Zeltner added a comment -

I've now tried it with the Eclipse Europe 3.3.1.1 (eclipse-jee-europa-fall2-win32.zip) and the message doesn't appear. So all well.

Happy New Year!
Martin

Show
Martin Zeltner added a comment - I've now tried it with the Eclipse Europe 3.3.1.1 (eclipse-jee-europa-fall2-win32.zip) and the message doesn't appear. So all well. Happy New Year! Martin

People

Vote (7)
Watch (12)

Dates

  • Created:
    Updated:
    Resolved: