Note that there are some explanatory texts on larger screens.

plurals
  1. POexec-maven-plugin goal is not started during build
    text
    copied!<p>Hallo,</p> <p>I try to run a main method during my maven build process. Hence, I added the exec-maven-plugin and the following snippet to my pom.xml</p> <pre><code>&lt;plugin&gt; &lt;!-- http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ --&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt; &lt;version&gt;1.1.1&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;compile-reports&lt;/id&gt; &lt;phase&gt;compile&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;java&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;mainClass&gt;at.xyz.dls.util.JasperReportCompiler&lt;/mainClass&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>The main class exists and is also executed, when I call it out of the command line:</p> <pre><code>mvn exec:java -Dexec.mainClass="at.xyz.dls.util.JasperReportCompiler" </code></pre> <p>I also tried to create a empty new project to test, if an other depencency in the pom causes the problem, but had no success. In the maven settings.xml in the ~/.m2 folder, there is only the entry for an mirror, but no profiles, or anything else, which could cause a problem.</p> <p>It just does not start it. When I deleted all my artifacts in my repo under org.codehouse, it did not download the exec-maven-plugin. Only when I did the command line call.</p> <p>Any hints? Thanks in advance!</p> <p>edit: I forgot to mention I have used "mvn clean install". so it should have passed the compile phase...</p> <p>edit:</p> <h2>up to now, I could not solve the problem. Thanks for your answers so far! I will try to give all information once again, and hope, one of you guys, find's the fishy part. I have no idea anymore....</h2> <p>What I did: </p> <ul> <li>Delete the folder org/codehouse/mojo in my maven proxy. just to show, when the dependencies are loaded.</li> <li>show some java and maven version information</li> <li>build the project with: mvn -clean install (which should pass the test phase to execute my main method)</li> <li>execute the main method to show, the exec-maven-plugin is loaded only afterwards and works</li> </ul> <p>As far as I understood, calling "mvn clean install" should pass the test phase (the tests are executed...), hence the exec-maven-plugin should be called, which should execute the main method. Am I right?</p> <pre><code>D:\Eclipse-3.6.1-JSF\ws\exec-test&gt;java -version java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing) D:\Eclipse-3.6.1-JSF\ws\exec-test&gt;mvn -version Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200) Java version: 1.6.0_21 Java home: C:\Programme\Java\jdk1.6.0_21\jre Default locale: de_AT, platform encoding: Cp1252 OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows" D:\Eclipse-3.6.1-JSF\ws\exec-test&gt;mvn clean install [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - at.test:exec-test:jar:0.0.1-SNAPSHOT [INFO] task-segment: [clean, install] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean {execution: default-clean}] [INFO] Deleting directory D:\Eclipse-3.6.1-JSF\ws\exec-test\target [INFO] [resources:resources {execution: default-resources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 1 source file to D:\Eclipse-3.6.1-JSF\ws\exec-test\target\classes [INFO] [resources:testResources {execution: default-testResources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] Compiling 1 source file to D:\Eclipse-3.6.1-JSF\ws\exec-test\target\test-classes [INFO] [surefire:test {execution: default-test}] [INFO] Surefire report directory: D:\Eclipse-3.6.1-JSF\ws\exec-test\target\surefire-reports T E S T S Running at.test.ExecTestTest JUnit Test call: end of junit test. Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [jar:jar {execution: default-jar}] [INFO] Building jar: D:\Eclipse-3.6.1-JSF\ws\exec-test\target\exec-test.jar [INFO] [install:install {execution: default-install}] [INFO] Installing D:\Eclipse-3.6.1-JSF\ws\exec-test\target\exec-test.jar to D:\maven.m2\repository\at\test\exec-test\0.0.1-SNAPSHOT\exec-test-0.0.1-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3 seconds [INFO] Finished at: Thu Mar 10 12:07:08 CET 2011 [INFO] Final Memory: 15M/37M [INFO] ------------------------------------------------------------------------ D:\Eclipse-3.6.1-JSF\ws\exec-test&gt;mvn exec:java -Dexec.mainClass="at.test.ExecTest" [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'exec'. Downloading: http://pced06.vab.sozvers.at:8080/artifactory/repo/org/codehaus/mojo/exec-maven-plugin/1.2/exec-maven-plugin-1.2.pom 6K downloaded (exec-maven-plugin-1.2.pom) Downloading: http://pced06.vab.sozvers.at:8080/artifactory/repo/org/codehaus/mojo/exec-maven-plugin/1.2/exec-maven-plugin-1.2.jar 35K downloaded (exec-maven-plugin-1.2.jar) [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - at.test:exec-test:jar:0.0.1-SNAPSHOT [INFO] task-segment: [exec:java] [INFO] ------------------------------------------------------------------------ [INFO] Preparing exec:java [WARNING] Removing: java from forked lifecycle, to prevent recursive invocation. [INFO] No goals needed for project - skipping [INFO] [exec:java {execution: default-cli}] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7 seconds [INFO] Finished at: Thu Mar 10 12:07:20 CET 2011 [INFO] Final Memory: 5M/15M [INFO] ------------------------------------------------------------------------ D:\Eclipse-3.6.1-JSF\ws\exec-test&gt; </code></pre> <p>now again the modified pom.xml:</p> <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;at.test&lt;/groupId&gt; &lt;artifactId&gt;exec-test&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;properties&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;/properties&gt; &lt;build&gt; &lt;finalName&gt;exec-test&lt;/finalName&gt; &lt;defaultGoal&gt;install&lt;/defaultGoal&gt; &lt;pluginManagement&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;encoding&gt;UTF-8&lt;/encoding&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;!-- http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ --&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt; &lt;version&gt;1.2&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;compile-reports&lt;/id&gt; &lt;phase&gt;test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;java&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;mainClass&gt;at.test.ExecTest&lt;/mainClass&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/pluginManagement&gt; &lt;/build&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;version&gt;4.8.2&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; </code></pre> <p>The main class:</p> <pre><code>package at.test; public class ExecTest { /** * @param args */ public static void main(String[] args) { System.out.println("##################################"); } } </code></pre> <p>And the JUnit Test Class:</p> <pre><code>package at.test; import org.junit.Test; import at.test.ExecTest; public class ExecTestTest { @Test public void testTestTest() { System.err.println("JUnit Test call:"); ExecTest.main(null); System.err.println("end of junit test."); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload