maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anonimac Anonimac <nit...@gmail.com>
Subject Re: Maven debugging HOWTO
Date Sat, 24 Dec 2005 21:04:33 GMT
Jochen,
thank you for this. I tried with embedder(didn't work), so this will really
help me.


On 12/23/05, Jochen Wiedmann <jochen.wiedmann@gmail.com> wrote:
>
> Hi,
>
> it took me some time to figure this out, so it seems worth sharing.
>
> Jochen
>
> --
> Often it does seem a pity that Noah and his party did not miss the
> boat. (Mark Twain)
>
>
> Maven Debugging HOWTO
> ===================
>
> When looking for bugs in Maven itself or plugins, it saves a real lot of
> time,
> if you can run Maven in a debugger. Fortunately, this is a relatively
> trivial task,
> if you know what to do.
>
> 1.) Invoking Maven from the command line
> ------------------------------------------------------------
>
> Basically, your debugger should execute the following command line.
>
>    M2_HOME=/usr/local/maven-2.0.1
>    # Or whatever you have as Maven home
>    # use set M2_HOME=... on Windows
>
>    M2_REPO=/home/jochen/.m2/repository
>    # Or whatever you have as Maven repository
>    # use set M2_REPO=... on Windows
>
>    CW=$M2_REPO/classworlds/classworlds/1.1-alpha-2/classworlds-
> 1.1-alpha-2.jar
>    # The version number may depend on the Maven version.
>    # Check your "mvn" script, if you are in doubt.
>    # Use set CW=%M2_REPO%/... on Windows
>
>    ARGS=-Dclassworlds.conf=$M2_HOME/bin/m2.conf -Dmaven.home=$M2_HOME
>    # Use set ARGS=-Dclassworlds.conf=%M2_HOME%/... on Windows
>
>    java -cp $CW $ARGS org.codehaus.classworlds.Launcher <goals>
>    # Use java -cp %CW% ... on Windows
>
>
> 2.) Using an IDE
> ------------------------
>
> Basically, it should be easy to translate the above command line into
> your IDE's settings.
> In what follows, I'll describe the Eclipse IDE as an example.
>
> However, there's one imortant Gotcha, which you should be aware of: In
> the above example, the initial classpath contains the classworlds jar
> file - and nothing else! Your IDE will typically suggest a larger
> classpath. For example, if you have a "Maven" project, it will suggest
> to put this project and its dependencies on the classpath. But that
> will most likely fail.
>
> The reason is, that the projects dependencies will typically contain
> multiple instances of the same dependency. For example, with Maven
> 2.0.1 you will have plexus-utils 1.0.4 as well as plexus-utils-1.0.5.
> This is no problem, if you are using the class loaders that Maven
> creates for you. It won't work, if the IDE creates class loaders: For
> example, depending on the order of dependencies, only version 1.0.4
> will be used, even if some classes depend on
> 1.0.5.
>
> In other words: Before starting the IDE's debugger, make sure that the
> class path contains the boot class loader and the classworlds.jar
> file, but nothing else.
>
>
> 3.) Example: The Eclipse IDE
> -------------------------------------------
>
> - Make sure, that the Maven 2 Eclipse Plugin is installed. See
>     http://maven.apache.org/eclipse-plugin.html
>   for installing the plugin.
> - Checkout the following projects from SVN.
>     Maven:
> http://svn.apache.org/repos/asf/maven/components/tags/maven-2.0.1/
>
>   If you need plugin parents, checkout other projects as well, for example
>
>     Plugins: http://svn.apache.org/repos/asf/maven/plugins/trunk
>
>   Note, that I did *not* checkout the Maven trunk. That rarely pays.
> Typically,
>   you'll find differences in the plugin versions which are being used.
>
>   Unfortunately, tags like Maven 2.0.1 are valid for the Maven core only.
> There
>   are no such tags for the various plugins. This makes it sometimes rather
>   difficult to have the right plugin sources. (Hint to the Maven
> developers!)
>
> - Use the Maven 2 plugin to enable that these projects are Maven projects.
>
> - Initially, invoke the "bootstrap" script in the Maven root directory.
>
> - Select Run/Run... in the menu. A window opens.
> - Select "Java Application" and press the "New" button.
> - Set the new debugging profiles name, for example "Maven".
> - Enter the "Main class": org.codehaus.classworlds.Launcher
>   Do not attempt to use the "Search" button: It doesn't show main classes
> in
>   dependencies.
> - Switch to "Arguments".
> - In "Program arguments", enter the goals you want to use, plus properties
>   you want to set.
> - In "VM arguments", enter the "-Dclassworlds.conf=...  -Dmaven.home=..."
>   arguments from 1.)
> - Select "Working directory/Other", and your projects base directory.
> (Where
>   you would typically invoke "mvn" from.)
> - Switch to "Classpath"
> - Remove all "User Entries". In particular, remove your project, and the
>   Maven projects, if they should be there.
> - Add the classworlds jar file from 1.) to "User Entries".
> - Switch to "Source Path".
> - You may safely add your own projects, the Maven projects, plugin
> projects,
>   and whatever you like, here.
>
> That's it. Press "Run" and watch Maven running.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message