Maven exec Plugin

From NovaOrdis Knowledge Base
Revision as of 01:17, 10 November 2016 by Ovidiu (talk | contribs)
Jump to navigation Jump to search

External

Overview

The Exec plugin allows you to execute Java classes and other scripts.

Running in the Same VM

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <configuration>
        <mainClass>org.novaordis.util.xb.XBrowser</mainClass>
        <commandlineArgs>-verbose true</commandlineArgs>
    </configuration>
</plugin>

Command Line:

mvn exec:java 

Running in DEBUG Mode

{{{

export MAVEN_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"

}}}


Old:

{{{

export MAVEN_OPTS="-Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=mvn"

}}}

!!!Running a Main Class located in one of the test packages

By default, the classpath used by the Exec plugin does not include test classes. If the class you want to execute is located in one of the test packages, the classpath scope must be extended as follows:

{{{

           ...
           <plugin>
               ...
               <artifactId>exec-maven-plugin</artifactId>
               <configuration>
                   ...
                   <classpathScope>test</classpathScope>
                   ...
               </configuration>
           </plugin>
           ...

}}}

Then, run the plug in as follows:

{{{

   mvn -e clean test-compile exec:java

}}}


!!!Allowing more memory for the heap

{{{

export MAVEN_OPTS="-Xmx1024m"

}}}

!!!Maven and YourKit

|[Maven and YourKit|MavenAndYourKit]

__Referenced by:__\\ [{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=20, maxwidth=50}]