Franz,

Thanks for your contribution.  I'm new to developing maven internals and my
first question has been how to debug maven.  I want to use the debugger to
learn how maven is working internally.

I've discovered this technique to debug maven 2.0.4 under eclipse 3.2. 
Please add it to your tutorial if it is appropriate.  Part of your tutorial
is  addressing how to debug a user project's unit tests as they are run via
surefire.   I'm not certain if the technique I describe here is useful for
debugging a user projects' unit test under surefire, but maybe.

Here is how I can run/debug maven-core.  This is can be applied to any maven
subproject that a maven developer may want to edit and run/debug.

Please feel free to incorporate this into your tutorial if it is
appropriate.

First level: running and debugging maven under eclipse: setting up a run
config.  The principal here is to merely incorporate the important elements
of the mvn script into an eclipse run configuration.  This run configuration
would then be activated as any other run configuration would by clicking run
or debug buttons in the toolbar.

0) checkout the maven subproject (I picked maven-core but any should work)
and
   create an eclipse project. I used m2eclipse, but I suppose maven's
eclipse
   plugin ought to work as well.

1) In eclipse, create a new Run configuration:
1a) Run->Run...
1b) select Java Application
1c) select New (to create new Java Application run), pick a name for the
  config that would include the project name and goal like: "maven myproject
  install" which would be meant to run the install goal in myproject.

1d) In the Run dialog:
 Main tab)
  a) project: maven-core
  b) main class: org.codehaus.classworlds.Launcher
 Arguments tab)
  Program arguments:
    < any maven goals or command line argumens (like -X) >
  VM arguments:
   -Dmaven.home=<your maven installation root>
   -Dclassworlds.conf=<your maven installation root>/bin/m2.conf
  working directory:
   select other: <directory of the project used as maven's input>

 Classpath tab)
  remove User Entries -> maven-core
  add External Jars <your maven installation
root>/core/boot/classworlds-1.1.jar

 Source tab)
  add project maven-core

 Run)
  This step will invoke maven without debugging.  It will also have the
affect
  of registring this new run config as the default run config (and debug run
config)

2) Select a breakpoint int maven-core.  I picked:
   org.apache.maven.DefaultMaven.execute.  Then click the little beetle
(debug
   run).



The Next Level: developing maven internals and debugging them:

If you want to make changes to the maven-core or other maven subprojects,
you will need to provide your own version of bin/m2.conf. The purpose is to
tell the internal class loading mechanism (classworlds and
plexus) where your development build directory is so it could load your
version of the classes.

Your custom m2.conf file could be located anywhere in your filesystem, but
since m2.conf is homed in maven-core, which is my example maven subproject,
I edit it in place.

Editing this file doesn't take much understanding of classworlds (I for one
do not understand it to any level).

Copy the original from maven's install bin directory to your preferred
location.  Edit the file and add the path to your eclipse build output for
the maven projects involved.  I added the middle line in this snippet from
m2.conf:

[plexus.core.maven]
load /home/jfraney/projects/maven-2.0.4/maven-core/bin
load ${maven.home}/lib/*.jar

Then change the maven run configuration that was created above.  The
property classworlds.conf must be adjusted to point to your custom m2.conf
file. 

Regards,
John









-- 
View this message in context: 
http://www.nabble.com/debugging-maven-with-eclipse-tf2434872s177.html#a8988667
Sent from the Maven Developers mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to