views:

71

answers:

1

Hi Folks,

I have started playing with Maven2 and I'm attempting to port one of my projects from ant to maven. I have managed to build ear file, use jaxb and other bits, but there is one thing left I don't know how to approach.

I have WAR module, with ExtJS code, and I'm using JSBuilder to create and package the code nicely. This is done as ant task and looks like this:

<target name="-pre-compile" description="Building Frontend Libraries">
    <java jar="web/lib/dev/JSBuilder2.jar" failonerror="true" fork="true" >
        <arg line="--projectFile web/lib/dev/frontend.jsb2 --homeDir web/lib"/>
    </java>
</target>

I am wondering what would be the 'maven' way to do this? Is there a way I can do it purely in maven (had a look at maven:exec plugin but is a bit confusing) or do I have to call ant from maven to achieve this?

Thanks

A: 

The exec-maven-plugin is the correct answer (though you want the java goal). You need to bind it to a lifecycle phase. Look at the usage page for an example. In your case, you'd need something like this:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.1</version>
  <executions>
    <execution>
      <id>jsbuilder</id>
      <goals>
        <goal>java</goal>
      </goals>
      <phase>compile</phase>
      <configuration>
        <mainClass><!-- fill in from jar's META-INF/MANIFEST.MF --></mainClass>
        <argument>--projectFile</argument>
        <argument>web/lib/dev/frontend.jsb2</argument>
        <argument>--homedir</argument>
        <argument>web/lib</argument>
      </configuration>
    </execution>
  </executions>
  <configuration>
    <includeProjectDependencies>false</includeProjectDependencies>
    <includePluginDependencies>true</includePluginDependencies>
  </configuration>
  <dependencies>
    <!-- a bit nasty, would be better if jsbuilder2 available in a maven repo. -->
    <dependency>
      <groupId>com.extjs</groupId>
      <artifactId>jsbuilder2</artifactId>
      <version>2.0.0</version>
      <scope>system</scope>
      <systemPath>web/lib/dev/JSBuilder2.jar</systemPath>
    </dependency>
  </dependencies>
</plugin>

If you're a big user of JSBuilder2, it'd be worth asking Cencha if they can release it to the maven central repo. Point them at OSS Repository Hosting.

Dominic Mitchell
Hi Dominic,Thanks for replay. I have adjusted your example and I am able to call JSBuilder from maven, however there is small problem I am experiencing right now. It seems like arguments described in the script are not being visible for jsbuilder. Invoking returns help printout, which suggests none of required parameters has been passed on. I did have look at the examples you mentioned, and looking at them it seems they should be ok so am a bit puzzled. I thought I'd try with different versions of maven exec plugin, but same result.I wonder what could be the problem.
Greg
A bit more research and mystery solved! :)I have had to use <commandlineArgs> to pass command line params as one string. Thanks a lot for help!
Greg