1
votes

I'm trying to build a Flex project with Flexmojos 7.0.0 & mavenized Apache Flex SDK (groupId "org.apache...") with a dependency to an old library built with Flexmojos 5 and Adobe Flex SDK 4.6.b.23201 (groupId "com.adobe..."). The problem is that it gives following error:

ERROR] Failed to execute goal net.flexmojos.oss:flexmojos-maven-plugin:7.0.0:compile-swf (default-compile-swf) on project gestouch-examples: Execution default-compile-swf of goal net.flexmojos.oss:flexmojos-maven-plugin:7.0.0:compile-swf failed: Flex compiler and flex framework versions doesn't match. Compiler: '4.12.1.20140427' - Framework: '4.1.0.16076'.

[ERROR] You can use 'iKnowWhatImDoingPleaseBreakMyBuildIwontBlameFlexmojosForStopWorking' to disable this check. Please refer to Flexmojos maven doc.

[ERROR] If you prefer fixing it instead of ignoring, take a look at: https://docs.sonatype.org/display/FLEXMOJOS/How+to+set+Flex+SDK+version

Here's my POM:

<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>mygroup</groupId>
    <artifactId>myartifact</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>swf</packaging>
    <name>Flexmojos7 Test</name>

    <properties>
        <flexmojos.version>7.0.0</flexmojos.version>
        <flex.version>4.12.1.20140427</flex.version>
        <flex-sdk.version>${flex.version}</flex-sdk.version>
    </properties>

    <build>
        <sourceDirectory>src/main/flex</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>net.flexmojos.oss</groupId>
                <artifactId>flexmojos-maven-plugin</artifactId>
                <version>${flexmojos.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <sourceFile>Main.mxml</sourceFile>
                    <debug>true</debug>
                    <storepass/>
                    <skipTest>true</skipTest>
                    <skipTests>true</skipTests>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.flex</groupId>
                        <artifactId>compiler</artifactId>
                        <version>${flex.version}</version>
                        <type>pom</type>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.apache.flex.framework</groupId>
            <artifactId>flex-framework</artifactId>
            <version>${flex.version}</version>
            <type>pom</type>
        </dependency>

        <!-- 3rd party libraries -->

        <dependency>
            <groupId>org.as3commons</groupId>
            <artifactId>as3commons-logging</artifactId>
            <version>2.7</version>
            <type>swc</type>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/releases</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
        </repository>

        <repository>
            <!-- has as3commons -->
            <id>yoolab.org-releases</id>
            <url>http://dev.yoolab.org/maven/content/repositories/releases/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>
</project>

As you can see, as3commons-logging library is my dependency I mentioned. If you open it's POM you will see that it depends on

<groupId>com.adobe.flex.framework</groupId>
<artifactId>air-framework</artifactId>

and

<groupId>com.adobe.flex.framework</groupId>
<artifactId>common-framework</artifactId>

both with 4.1.0.16076 version.

I'm relatively new to Maven and I personally don't understand why it respects as3commons-logging POM when I specified in my POM dependency to as3commons-logging to be of type "swc". But okay, after a weekend of research I found out how to solve this issue by specifying "excludes" for my dependency:

<dependency>
    <groupId>org.as3commons</groupId>
    <artifactId>as3commons-logging</artifactId>
    <version>2.7</version>
    <type>swc</type>
    <exclusions>
        <exclusion>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>air-framework</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>common-framework</artifactId>
        </exclusion>
    </exclusions>
</dependency>

With this fix in my POM it finally compiles.

Now, my question is – is this the right fix? I mean conceptually. Because the whole thing seems not very clear for me. Is that a price for switching from Adobe Flex to Apache Flex and all that?

2

2 Answers

0
votes

Sorry for the late reply to your question.

Here the answer to your problem: I noticed some problems with the way the old FDKs were published and refactored the structure to avoid these problems when generating the new FDKs. One thing I changed was to eliminate the flex-framework, air-framework and common-framework as they mixed up dependencies from Apache and Adobe. Now all you have is something similar to the common-framework pom. org.apache.flex:framework:{fdkVersion}:pom if you reference this instead of flex-framework and add a dependency to the playerglobal matching your minimum Flash version com.adobe.flash.framework:playerglobal:{flashVersion}:swc you should be ready to go.

And I would strongly suggest to switch to Flexmojos 7.0.1 (I released that a few days ago) as it contains a few fixes to annoying problems.

<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>mygroup</groupId>
    <artifactId>myartifact</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>swf</packaging>
    <name>Flexmojos7 Test</name>

    <properties>
        <flexmojos.version>7.0.1</flexmojos.version>
        <flex.version>4.12.1.20140427</flex.version>
        <flex-sdk.version>${flex.version}</flex-sdk.version>
        <flashplayer.version>11.1</flashplayer.version>
    </properties>

    <build>
        <sourceDirectory>src/main/flex</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>net.flexmojos.oss</groupId>
                <artifactId>flexmojos-maven-plugin</artifactId>
                <version>${flexmojos.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <sourceFile>Main.mxml</sourceFile>
                    <debug>true</debug>
                    <storepass/>
                    <skipTest>true</skipTest>
                    <skipTests>true</skipTests>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.flex</groupId>
                        <artifactId>compiler</artifactId>
                        <version>${flex.version}</version>
                        <type>pom</type>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.adobe.flash.framework</groupId>
            <artifactId>playerglobal</artifactId>
            <version>${flashplayer.version}</version>
            <type>swc</type>
        </dependency>
        <dependency>
            <groupId>org.apache.flex</groupId>
            <artifactId>framework</artifactId>
            <version>${flex.version}</version>
            <type>pom</type>
        </dependency>

        <!-- 3rd party libraries -->

        <dependency>
            <groupId>org.as3commons</groupId>
            <artifactId>as3commons-logging</artifactId>
            <version>2.7</version>
            <type>swc</type>
            <!--exclusions>
                <exclude>
                    <groupId>....</groupId>
                    <artifactId>....</artifactId>
                </exclude>
            </exclusions-->
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/releases</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
        </repository>

        <repository>
            <!-- has as3commons -->
            <id>yoolab.org-releases</id>
            <url>http://dev.yoolab.org/maven/content/repositories/releases/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>
</project>

Another problem could be that third party libs might reference artifacts in other versions. So probably as3commons-logging was compiled against the adobe flex version, so you definitely have to exclude this. You can see which dependencies are pulled in by issueing the following command:

mvn dependency:tree

It should output a dependency tree in which you can see which libs you have to exclude.

Hope this helps.

Chris

-1
votes

The problem is that flexmojos-maven-plugin 7.0.x version has been built using the Apache FDK 4.12.1.20140427

To build your project by flexmojos you need firstly deploy this FDK (4.12.1.20140427) in your maven repository by mavenizer (https://cwiki.apache.org/confluence/display/FLEX/Apache+Flex+SDK+Mavenizer). If you have external repository (like Nexus server) you need to deploy this FDK into the repository. Then you need to explicitly declare this repository in POM file in the pluginRepositories section:

<!-- REPOS -->
<pluginRepositories>
    <pluginRepository>
        <id>flex-repository</id>
        <url>http://path-to-your-repository/</url>
    </pluginRepository>
</pluginRepositories>

<repositories>
    <repository>
        <id>flex-repository</id>
        <url>http://path-to-your-repository/</url>
    </repository>
</repositories>