mavenflex4flex3mxmlflexmojos

Flex Maven project: Could not resolve <mx:Application> to a component implementation


While converting an existing flex project to a maven project using the IntelliJ IDEA, I am facing an interesting issue for couple of days:

Problem Description:
When I use the module dependency as Flex SDK 3.2.0, I am able to see the 'mx:Application' tag properly in the mxml file, and there is no error shown in it. However, as soon as I select the Flexmojos SDK 4.5/4.6, then the 'mx:Application' element starts showing an error message saying 'Element mx:Application must be declared'. Also, during compile time, it gives error saying 'Could not resolve mx:Application to a component implementation.' Refer this image with screenshots from IntelliJ IDEA.

Analysis:
I have seen similar posts on StackOverflow and also on the other adobe forums, but none of their solutions are helping. I checked on adobe site that Flex 4 is backward compatible, so ideally the mx:Application tag should work, even if it is deprecated in Flex 4.

Current Situation:
Since I have to convert this normal Flex project to a Maven project, I have to use the Flexmojos-maven-plugin only, and hence I have to use its relevant latest SDK 4.5/4.6 too. Plus, I am not intending to migrate entire Flex 3 code in Flex 4, since that's too much work, and my current objective is just to make this flex project build properly with maven.

Any ideas you can give me about how to resolve this?


Solution

  • I finally addressed the issue by adding the reference to following dependency:

    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>mx</artifactId>
      <version>4.5.0.19786</version>
      <type>pom</type>
    </dependency>
    

    Above is present in our company's internal Nexus, but I could not find it on the mvnrepository website online.

    I also had to use the older version of flexmojos-maven-plugin to compile my flex project. Here is complete working pom.xml for reference:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.test</groupId>
        <artifactId>TA_UI_Test2</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>swf</packaging>
        <name>TA_UI_Test2 Flex</name>
    
        <dependencies>
            <dependency>
                <groupId>com.adobe.flex.framework</groupId>
                <artifactId>playerglobal</artifactId>
                <version>10-3.3.0.4852</version>
                <type>swc</type>
            </dependency>
            <dependency>
                <groupId>com.adobe.flex.framework</groupId>
                <artifactId>rpc</artifactId>
                <version>4.5.1.21328</version>
                <type>swc</type>
            </dependency>
            <dependency>
                <groupId>com.adobe.flex.framework</groupId>
                <artifactId>framework</artifactId>
                <version>3.2.0.3958</version>
                <type>swc</type>
            </dependency>
            <dependency>
                <groupId>com.adobe.flex.framework</groupId>
                <artifactId>mx</artifactId>
                <version>4.5.0.19786</version>
                <type>pom</type>
            </dependency>
        </dependencies>
    
        <build>
            <sourceDirectory>src</sourceDirectory>
    
            <plugins>
                <plugin>
                    <groupId>org.sonatype.flexmojos</groupId>
                    <artifactId>flexmojos-maven-plugin</artifactId>
                    <version>3.8</version>
                    <extensions>true</extensions>
                    <configuration>
                        <sourceFile>Main.mxml</sourceFile>
                        <debug>true</debug>
                        <storepass/>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>com.adobe.flex</groupId>
                            <artifactId>compiler</artifactId>
                            <version>3.2.0.3958</version>
                            <type>pom</type>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
    
        </build>
    
    </project>