IndoKnight
IndoKnight

Reputation: 1864

Maven3 - Debug main source code only

I have a standalone maven project where I run a java program using org.codehaus.mojo exec plugin.

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <executable>java</executable>   
                    <argument>-classpath</argument>
                    <classpath>
                    </classpath>
                    <argument>com.abc.Main</argument>
                </arguments>
            </configuration>
        </plugin>

I also have test cases under src/test/java directory, which I can debug using surefire plugin. But, I can't debug the main code using mvnDebug directly by running com.abc.Main class(though this looks straightforward by attaching Eclipse workspace project in Debug mode on a port being listened by mvnDebug). I'm wondering if we can use surefire plugin directly on main code to debug?

UPDATED

I use eclipse Kepler version with installed "Maven Integration for Eclipse" plugin

Upvotes: 0

Views: 340

Answers (1)

carlspring
carlspring

Reputation: 32607

Try running Maven like this:

mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9001 -Xnoagent" clean install

And use the remote debugger to connect to port 9001. This will allow you to put breakpoints in your test code.

Upvotes: 2

Related Questions