-1

Hi i had been setting up a flex project, its basically into 3 modules, a flex, a java and a war project. Am able to compile all, but the flexmojos:copy-flex-resources plugin only copies the ".swf" file into the webapp directory. There are other files like html wrapper which are skipped. Had anyone sort it out. Thanks!

My SWF POM

swf Application

<properties>
    <path_to_services_config_xml>${basedir}/src/main/resources/services-config.xml</path_to_services_config_xml>
</properties>

<build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <testSourceDirectory>src/test/flex</testSourceDirectory>
    <directory>target</directory>
    <plugins>
        <plugin>
            <groupId>org.sonatype.flexmojos</groupId>
            <artifactId>flexmojos-maven-plugin</artifactId>
            <!-- <version>3.8</version> -->
            <executions>
                <execution>
                    <id>html-wrapper</id>
                    <goals>
                        <goal>wrapper</goal>
                    </goals>
                    <configuration>
                        <templateURI>folder:/html-template</templateURI>
                        <parameters>
                            <swf>${project.build.finalName}</swf>
                            <width>100%</width>
                            <height>100%</height>
                            <version_major>${flash.major}</version_major>
                            <version_minor>${flash.minor}</version_minor>
                            <version_revision>${flash.revision}</version_revision>
                            <bgcolor>#FFFFFF</bgcolor>
                        </parameters>
                        <htmlName>Main</htmlName>
                        <!-- <targetPlayer>${flash.major}.${flash.minor}.${flash.revision}</targetPlayer> -->
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.adobe.flex.compiler</groupId>
                    <artifactId>flex-compiler-oem</artifactId>
                    <version>4.5.1.21328</version>
                </dependency>
            </dependencies>
            <extensions>true</extensions>
            <configuration>
                <debug>true</debug>
                <!-- <output>target/bin/</output> <sourcePaths> <path>src/main</path> 
                    </sourcePaths> Configuration to copy assets (Images) folder to target -->
                <includeFileSets>
                    <fileset>
                        <directory>src/main/assets</directory>
                        <includes>
                            <include>*.*</include>
                        </includes>
                    </fileset>
                </includeFileSets>

                <!-- service-config.xml specification (path defined above) -->
                <services>${path_to_services_config_xml}</services>

                <!-- Context Root URL -->
                <contextRoot>clv-web-0.3</contextRoot>
                <localesCompiled>
                    <locale>en_US</locale>
                    <locale>fr_FR</locale>
                </localesCompiled>
                <localesSourcePath>${basedir}/src/main/locale/{locale}</localesSourcePath>
                <!-- <localesSourcePath>${basedir}/src/main/locale/fr_FR</localesSourcePath> -->
                <!-- <templateURI>${basedir}/html-template/</templateURI> <outputDir>target/flex-html</outputDir> 
                    <htmlName>myindex.html</htmlName> <parameters> <swf>${build.finalName}</swf> 
                    </parameters> -->
            </configuration>
            <!-- <executions> <execution> <goals> <goal>wrapper</goal> </goals> </execution> 
                </executions> -->
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>com.adobe.flex.framework</groupId>
        <artifactId>flex-framework</artifactId>
        <version>4.5.1.21328</version>
        <type>pom</type>
    </dependency>

    <dependency>
        <groupId>com.adobe.flexunit</groupId>
        <artifactId>flexunit</artifactId>
        <version>0.85</version>
        <type>swc</type>
        <scope>test</scope>
    </dependency>

and my war POM is

<packaging>war</packaging>
<build>
    <plugins>
        <plugin>
            <groupId>org.sonatype.flexmojos</groupId>
            <artifactId>flexmojos-maven-plugin</artifactId>
            <version>4.1-beta</version>
            <extensions>true</extensions>
            <executions>
                <!-- <execution> <id>wrapper</id> <phase>generate-resources</phase> 
                    <goals> <goal>wrapper</goal> </goals> <configuration> <wrapperArtifact> <groupId>com.cat.clv.swf</groupId> 
                    <artifactId>clv-swf</artifactId> <version>0.3</version> </wrapperArtifact> 
                    <htmlName>Main</htmlName> </configuration> </execution> -->
                <execution>
                    <goals>
                        <goal>copy-flex-resources</goal>
                    </goals>
                    <configuration>
                    <webappDirectory>>${basedir}/src/main/webapp/demo</webappDirectory>
                        <stripVersion>true</stripVersion>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <webResources>
                    <resource>
                        <!-- this is relative to the pom.xml directory -->
                        <directory>src/main/webapp</directory>
                    </resource>
                </webResources>
                <debug>true</debug>
                <!-- <warSourceExcludes>index.template.html</warSourceExcludes> <webResources> 
                    <resource> <directory>target</directory> </resource> </webResources> -->
            </configuration>
        </plugin>
Bash
  • 21
  • 3
  • 8

2 Answers2

1

I am the guy who has officially taken over development of flexmojos.

The problem you are encountering might be related to some changes in flexmojos staring with 3.x (don't remember the version) I was having the same problems as you were. While searching for the reason I found out that flexmojos was having trouble determining the finalName from the projects pom because in some cases maven throws errors. As I was specifying the finalName myself I solved the problem by setting false in the copy-flex-resources configuration. Eventually this helps.

Another solution I had to use in a different project was to explicitly use an oder version of the copy-flex-resources mojo in my war project. 3.7.1 seems to be the last version without this problem.

Unfortunately I didn't manage to sort out this error yet, but it's still on my radar.

Chris

Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34
1

I had a very similar configuration issue with flexmojos-maven-plugin version 3.8 which I fixed by adding by warSourceDirectoryPath to the outputDirectory of the wrapper goal config in the swf project:

I defined a property: warSourceDirectoryPath = ../workbench-server/src/main/webapp/flex

  <plugin>
    <groupId>org.sonatype.flexmojos</groupId>
    <artifactId>flexmojos-maven-plugin</artifactId>
    <version>3.8</version>
    <executions>
        <execution>
            <id>flex-ui-wrapper</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>wrapper</goal>
            </goals>
            <configuration>
                <templateURI>folder:/html-template</templateURI>
                   <templateOutputDirectory>${project.build.directory}/templates</templateOutputDirectory>
                <outputDirectory>${warSourceDirectoryPath}</outputDirectory>
                <parameters>
                    <swf>${project.build.finalName}</swf>
                    <title>Workbench</title>
                    <application>myapp</application>
                </parameters>           
                <htmlName>Workbench</htmlName>
            </configuration>
        </execution>
    </executions>       
    <dependencies> 
       ...      
    </dependencies>
    <extensions>true</extensions>    
    <configuration>
      <debug>true</debug>
      <sourceFile>${basedir}/src/main/flex/Workbench.mxml</sourceFile>
      <contextRoot>/workbench-server</contextRoot>          
      <generateHtmlWrapper>true</generateHtmlWrapper>
      <targetPlayer>11.1.0</targetPlayer> 
      <!-- <services>generated-resources</services> this is the default -->
    </configuration>
  </plugin>

Hope that helps.