0

I just got all set up and compiling in Maven with Flex-Mojos, and now my next question is how I would "publish" my compiled application to an arbitrary directory along with its web resources. It has a few PHP scripts which need to be copied, as well as the html wrapper of course. If I were to do this in Ant (which is where I'm coming from), I would do the following:

<copy todir="${deploy.dir}">
    <fileset file="${compiled.swf.file}"/>
    <fileset dir="${web.dir}" includes="**/*"/>
</copy>

Since this is Maven and the approach to project management is very different, what should I do to accomplish this? I need a fairly easy way to test my application (not unit-test, mind you) in a browser, what should I do?

Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411

2 Answers2

1

On my project, I have the HTML wrapper file in a war project under src/main/resources. Then I used the Dependency Plugin to copy the SWF to the WAR. Here's an example:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>${maven-dependency-plugin.version}</version>
    <executions>
      <execution>
        <id>unpack-swf</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>copy-dependencies</goal>
        </goals>
        <configuration>              
          <outputDirectory>${project.build.directory}/<your-project-name></outputDirectory>
        </configuration>
      </execution>
    </executions>
  </plugin>

Here's an example dependency:

        <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId><your-swf-artifact></artifactId>
        <version>${project.version}</version>
        <type>swf</type>
    </dependency>
BennyMcBenBen
  • 1,438
  • 2
  • 20
  • 37
  • How would I copy my resources in main/resources to the output directory? Thanks for the help :) – Naftuli Kay Feb 08 '11 at 22:51
  • Good question. Files in src/main/resources will get copied automatically to that directory, assuming that matches build.finalName in your pom.xml. See this [link](http://www.sonatype.com/books/mvnex-book/reference/web-sect-creating-project.html) for an example of a WAR pom.xml. Maven is all about convention over configuration. That means that by default files in src/main/resources should be copied automatically to that location. Then Maven zips up that output directory into the WAR file and you can deploy that WAR on your server. – BennyMcBenBen Feb 09 '11 at 00:24
  • src . But yeah, it's better to keep maven convention – Florian F Feb 09 '11 at 08:30
0

Ended up using the Maven Ant runner to do it in the copy-resources phase.

Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411