replace <goal>exec</goal> with <goal>java</goal>

TimHedger schrieb:
You're right - I did some unnecessary work!  (I took my approach from the
idlj plugin, that basically puts some wrapper stuff around running the main
method on a Java class - I guess that was done that way for convenience
rather than needing lots of config in the pom).

Anyway, I've dumped my plugin (less code has to be better) and am now using
the exec-maven-plugin.  And I can get it to do exactly what I need stand
alone - by invoking it explicitly:

mvn exec:java

will run the necessary Java class with all my arguments.

But I want to attach this step to a phase so it is nicely included in my
build cycle.  So I took the approach I have taken with other pugins, but it
doesn't seem to work here.

Specifics - this is the plugin section of my pom.xml:
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>glue-processing</id>
            <phase>compile</phase>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <debug>true</debug>
          <executable>java</executable>
          <mainClass>electric.application.tools.NewApp</mainClass>
          <arguments>
            <argument>-Delectric.apphome=target/glue</argument>
            <argument>-Delectric.home=/apps/product/glue</argument>
            <argument>-h</argument>
            <argument>VentureVaRService</argument>
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>

Here I've tried to attach the exec:java goal to the compile phase.

When I invoke mvn exec:java, I get what I expect:

: mvn exec:java
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'.
[INFO]
----------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype
[INFO]    task-segment: [exec:java]
[INFO]
----------------------------------------------------------------------------
[INFO] Preparing exec:java
[INFO] No goals needed for project - skipping
[INFO] [exec:java]
[DEPLOYMENT] creating application directory at
/home/hedgert/maven/venvar/target/glue/VentureVaRService
[DEPLOYMENT] copying application files from /apps/product/glue/common
[DEPLOYMENT] adding application configuration URLs to config.xml
[DEPLOYMENT] saving application configuration file
[DEPLOYMENT] application has been successfully created
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Tue Jul 11 18:47:37 BST 2006
[INFO] Final Memory: 3M/8M
[INFO]
------------------------------------------------------------------------

(The DEPLOYMENT lines are the correct output from the Java class I'm
running, and this output shows it has taken the arguments I defined in the
pom).

But if I try to use the compile phase instead:

: mvn compile
[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype
[INFO]    task-segment: [compile]
[INFO] -------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] No sources to compile
[INFO] [exec:exec {execution: glue-processing}]
[INFO] Usage: java [-options] class [args...]
[INFO]            (to execute a class)
[INFO]    or  java -jar [-options] jarfile [args...]
[INFO]            (to execute a jar file)
[INFO]
[INFO] where options include:
[INFO]     -d32
[INFO]                   use a 32-bit data model if available
[INFO]     -d64
[INFO]                   use a 64-bit data model if available
(etc etc)

In this case it seems to have invoked the plugin, but it has ignored all my
arguments and simply run Java with no parameters.  And yet the pom.xml file
is unchanged between these two runs.

So given the first one (mvn exec:java) works, I guess I'm doing something
wrong with the way I'm trying to attach the plugin goal to the compile phase
of the build.

Can someone point out my mistake?


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to