Maven exec Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * http://mojo.codehaus.org/exec-maven-plugin =Overview= The Exec plugin allows you to execute Java classes and other scripts. !!!Running in the same VM {{{...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
The Exec plugin allows you to execute Java classes and other scripts.
The Exec plugin allows you to execute Java classes and other scripts.


!!!Running in the same VM
=Running in the Same VM=


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


Command Line:
Command Line:


{{{
<pre>
    mvn exec:java  
mvn exec:java  
}}}
</pre>


!!!Running in DEBUG mode
=Running in DEBUG Mode=
 
{{{


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


}}}
=Running a Main Class Located in One of the Test Packages=
 
 
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:
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:


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


Then, run the plug in as follows:
Then, run the plug in as follows:


{{{
<pre>
    mvn -e clean test-compile exec:java
mvn -e clean test-compile exec:java
}}}
</pre>
 
 
 
!!!Allowing more memory for the heap
 
{{{
 
export MAVEN_OPTS="-Xmx1024m"
 
}}}
 
!!!Maven and YourKit


|[Maven and YourKit|MavenAndYourKit]
=Allowing More Memory for the Heap=


__Referenced by:__\\
<pre>
[{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=20, maxwidth=50}]
export MAVEN_OPTS="-Xmx1024m"
</pre>

Latest revision as of 01:20, 10 November 2016

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"
<pre>

=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:

<pre>
<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"