tags:

views:

67

answers:

2

Hey there,

just set up a simple project to test the functionality of the maven exec plugin. I have one class containing one "Hello World" main method. I've tested two configurations of the exec plugin.

        <goals>
          <goal>exec</goal>
        </goals>
        <configuration>
          <executable>java</executable>
          <arguments>
            <argument>-classpath</argument>
            <classpath/>
            <argument>test.exec.HelloWorldExec</argument>
          </arguments>
        </configuration>

failed miserably, giving me a ClassNotFoundException, while

        <goals><goal>java</goal></goals>
        <configuration>
          <mainClass>test.exec.HelloWorldExec</mainClass>
        </configuration>            

worked. However I would like to be able to start my java main class in a separate process, so I'd like to understand whats different with exec:exec and how I can get it to work?

Any help appreciated

cheers

Whizz

+2  A: 

May be related to this bug. A workaround is included in the description, hope that helps :-)

If the workaround does not help though, you could still vote for the bug to raise the chances of a rapid fix.

Péter Török
I don't know why it works in some cases, and why it doesn't work in others. But while at my home computer I didn't run into this error (tried on a debian and a windows7 with different maven versions), at work on my ubuntu workstation its definitely related to the bug you posted - thanks for posting :-), that will at least give me a workaround.
whiskerz
A: 

I cannot reproduce with version 1.1 of the exec-maven-plugin. I've created a sample project:

$ mvn archetype:generate -DgroupId=com.stackoverflow.q2433572 -DartifactId=q2433572 -Dversion=1.0-SNAPSHOT
$ cd q2433572

I've added the following plugin configuration to the pom.xml:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.1</version>
        <goals>
          <goal>exec</goal>
        </goals>
        <configuration>
          <executable>java</executable>
          <arguments>
            <argument>-classpath</argument>
            <classpath/>
            <argument>com.stackoverflow.q2433572.App</argument>
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

And this is the output I get when running mvn exec:exec:

$ mvn exec:exec
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building q2433572
[INFO]    task-segment: [exec:exec]
[INFO] ------------------------------------------------------------------------
[INFO] [exec:exec {execution: default-cli}]
[INFO] Hello World!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Fri Mar 12 17:11:38 CET 2010
[INFO] Final Memory: 3M/53M
[INFO] ------------------------------------------------------------------------

Works as expected.

Pascal Thivent
I think I've been seeing ghosts, works on my home computer as you described. Will need to wait until monday to continue testing at work - 'tis a strange world after all ...
whiskerz