Skip to content
Curtis Rueden edited this page Aug 12, 2015 · 4 revisions

Testing the latest SNAPSHOTs

To use the latest code on the master branch and/or topic branches: clone the code from GitHub, and build it using mvn install. This installs the JAR into your local Maven repository cache (typically at ~/.m2/repository/com/github/maven-nar/nar-maven-plugin/3.0.0-SNAPSHOT). Then add a reference to the plugin within your project's POM:

<plugin>
    <groupId>com.github.maven-nar</groupId>
    <artifactId>nar-maven-plugin</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</plugin>

It will resolve the plugin from your local cache.

Note that this approach is recommended only for testing, not for production code, because anyone else building your code will then also need to build nar-maven-plugin beforehand as well.

Running a specific integration test

Call mvn -Prun-its -Dinvoker.test=<directory-name> where <directory-name> is something like it0003-jni.

Debugging integration tests in an IDE

There are two good methods. Which one is better depends on the integration test/failures.

Importing the generated integration test projects directly

Once mvn -Prun-its was called from the command-line, the integration tests are actually available as fully valid Maven projects in target/it/it*/. Those projects can be easily imported into your IDE of choice.

Important note for Eclipse users: Eclipse's Maven support will only pick up the NAR plugin when it is installed (i.e. after mvn -DskipTests install has been called from NAR plugin's top-level directory, before that Eclipse will happily ignore any changes you make to the NAR plugin's source code), and then still only when the integration test's configuration has been updated via Maven>Update Project... (no need to force SNAPSHOT updates, though).

Using a remote debugger

First, run the integration test as specified above. Then, create a new file called invoker.properties in target/it/<it-name>/ that contains this line:

invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000

Now, run the integration test again. The JVM launched to run the test should suspend and wait for your next steps.

The next steps are:

  1. Fire up Eclipse (or whatever IDE with debugging capabilities you want to use).
  2. Create a new Debug Configuration for Remote Debugging, attached to port 8000 and associated with the nar-maven-plugin project, which you imported previously with File>Import>Existing Maven Project (you did, didn't you?).
  3. Add any desired breakpoints.
  4. Finally, click the Debug button of said debug configuration.
Clone this wiki locally