flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christofer Dutz <christofer.d...@c-ware.de>
Subject AW: FlexMojos with RSLs
Date Tue, 01 Sep 2015 10:13:13 GMT
Hi,

sorry for the late response ... I flagged the mail but didn't have the time to respond :-(
What page are you explicitly talking about? I hope you didn't edit it, as I do have some comments
to your findings.

As far as I know as soon as you set scope of a swc to "rsl" it is used and delivered as swf
file, so you don't need to provide the swf dependency. If you look at what the flexmojos copy-resources
goal creates you will probably see a "rsls" directory in your war containing swf files.

The problem with the resources is unfortunately not directly related to Flexmojos 7.1, but
to Maven. In maven they "fixed" a dependency scope resolution problem that Maven had from
the dark ages. Unfortunately we were relying on this. The result of Using Flexmojos 7.1 is
that you have to use Maven 3.1 or higher and therefore the rb.swc dependencies are stripped
from the maven dependency graph. The only way to fix this is to currently add an explicit
dependency to those transitive resources. With the simplified extensions mechanism of Maven
3.3.1, I'm thinking of a flex-maven-extension (That's also the reason for me renaming the
mavenizer artifact) that tells Maven how to resolve the "rsl" scopes. This will get rid of
the warnings and the need to re-define the rb.swcs of rsl dependencies and all should work
as desired, but I'm completely swamped with getting mobile support in Flexmojos at the moment.

In your case you shouldn't use the classifier to the rb, but use this instead:
<dependency>
    <groupId>org.apache.flex.framework</groupId>
    <artifactId>framework</artifactId>
    <version>${flex.sdk.version}</version>
    <type>rb.swc</type>
</dependency>

As Flexmojos knows how to handle this. Your solution would only work for one language, with
this option flexmojos uses a dummy rb.swc and resolves the correct languages at build time,
depending on the languages you define. Just have a look at what the mavenizer generates in
the pom.xml for "framework" for example ... you simply have to copy the transitive dependencies
to your project.

Chris

________________________________________
Von: mscharp <michael.scharp@fmr.com>
Gesendet: Donnerstag, 27. August 2015 20:57
An: dev@flex.apache.org
Betreff: FlexMojos with RSLs

Hey Chris.

In converting my company's project over to FM 7.1.0-SNAPSHOT and flex
4.14.1, I had to make some changes regarding how the RSLs were specified in
the pom.  I see that you have a page to address this in the wiki, so thought
I would give a go at writing some of it based off my experience.  Please
look at this and use whatever pieces of it you can.  If there is anything
that I've done incorrectly or made bad assumptions, please let me know as
well.

In order to use RSLs in your flex project, you need to declare their usage
in the dependencies section of your pom, eg:

<dependencies>
    <dependency>
        <groupId>org.apache.flex.framework</groupId>
        <artifactId>framework</artifactId>
        <version>${flex.sdk.version}</version>
        <type>swc</type>
        <scope>rsl</scope>
    </dependency>
</dependencies>

Maven will complain that it doesn't know about the 'rsl' scope type, but you
can safely ignore that warning.  It looks like this:

[WARNING] 'dependencies.dependency.scope' for
org.apache.flex.framework:framework:swc must be one of [provided, compile,
runtime, test, system] but is 'rsl'.

The 'rsl' scope type will instruct the compiler not to compile the RSLs into
the final swf and instead will load the RSLs at runtime.

When Flex moved over from Adobe to Apache, the RSL signing went the way of
the dinosaurs.  Before, the RSLs were loaded as swz files.  These were
Adobe's signed RSLs that lived on their servers and the flashplayer would
load the RSLs from there.  The nice thing about this approach was that you
could visit any website and if you had loaded the RSLs once, it would just
pull them from your cache.

Now, however, you must host the RSLs on your own server.  The RSLs that are
loaded are now loaded as swf files, and will only be cached for other flex
applications on the same domain.  Because of this limitation, RSLs are a bit
less useful than before.  If you have multiple different flex applications
under the same domain however, it can make sense to load the RSLs at runtime
rather than compiling them into your flex application.

In order to get these RSLs as swfs, you also need to depend on the swf
version of the RSL.

<dependency>
    <groupId>org.apache.flex.framework</groupId>
    <artifactId>framework</artifactId>
    <version>${flex.sdk.version}</version>
    <type>swf</type>
    <scope>test</scope>
</dependency>

Previous to FM 7.1.0 and Flex 4.14.1 this was all that was needed in the
dependency section.  However, now this will result in build errors like
this:

Error: Unable to resolve resource bundle "components" for locale "en_US".
Error: Unable to resolve resource bundle "textLayout" for locale "en_US".
... etcetera

To resolve these errors, you must also declare the resource bundles for the
RSLs you are using.

<dependency>
    <groupId>org.apache.flex.framework</groupId>
    <artifactId>framework</artifactId>
    <version>${flex.sdk.version}</version>
    <classifier>${language}.rb</classifier>
    <type>swc</type>
    <scope>rsl</scope>
</dependency>

You also need to add an element to the configuration section of the flex
mojos plugin to tell the flex application where it needs to look for the
RSLs.

<plugin>
    <groupId>net.flexmojos.oss</groupId>
    <artifactId>flexmojos-maven-plugin</artifactId>
    <version>${flex.mojo.version}</version>
    <extensions>true</extensions>
    <configuration>
        ...
        <rslUrls>
            <url>rsl/{artifactId}-{version}.{extension}</url>
        </rslUrls>
        ...
    </configuration>
</plugin>

Another helpful configuration parameter you can specify is the
removeUnusedRsls parameter.

<removeUnusedRsls>true</removeUnusedRsls>

Lastly, you also need to copy the RSLs into the directory where you've told
your application to look for them.  This will depend on your project and
deployment structure as to whether you need this or not, but a helpful
plugin to do this automatically is the maven-dependency-plugin.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.8</version>
    <executions>

        <execution>
            <id>copy-rsls</id>
            <phase>process-resources</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <includeGroupIds>${flex.groupId}.framework</includeGroupIds>
                <includeTypes>swf</includeTypes>
                <excludeTransitive>true</excludeTransitive>
                <outputDirectory>${basedir}/target/rsl</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

Putting this all together, a basic pom would look like this:

<?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.groupId</groupId>
    <artifactId>artifactId</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>swf</packaging>

    <name>My Project</name>

    <properties>
        <flex.mojo.version>7.1.0-SNAPSHOT</flex.mojo.version>
        <flex.sdk.version>4.14.1</flex.sdk.version>
        <flex.groupId>org.apache.flex</flex.groupId>
        <flashplayer.version>18.0</flashplayer.version>
        <flexunit.version>4.3.0-SNAPSHOT</flexunit.version>
        <language>en_US</language>
    </properties>

    <build>
        <sourceDirectory>src/main/flex</sourceDirectory>
        <testSourceDirectory>src/test/flex</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>net.flexmojos.oss</groupId>
                <artifactId>flexmojos-maven-plugin</artifactId>
                <version>${flex.mojo.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <debug>true</debug>
                    <rslUrls>
                        <url>rsl/{artifactId}-{version}.{extension}</url>
                    </rslUrls>
                    <removeUnusedRsls>true</removeUnusedRsls>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.flex</groupId>
                        <artifactId>compiler</artifactId>
                        <version>4.14.1</version>
                        <type>pom</type>
                    </dependency>
                   <dependency>
                        <groupId>com.adobe</groupId>
                        <artifactId>fontkit</artifactId>
                        <version>1.0</version>
                    </dependency>
                    <dependency>
                        <groupId>net.flexmojos.oss</groupId>

<artifactId>flexmojos-threadlocaltoolkit-wrapper</artifactId>
                        <version>7.1.0-SNAPSHOT</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>

                    <execution>
                        <id>copy-rsls</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>

<includeGroupIds>${flex.groupId}.framework</includeGroupIds>
                            <includeTypes>swf</includeTypes>
                            <excludeTransitive>true</excludeTransitive>

<outputDirectory>${basedir}/target/rsl</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

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

        <dependency>
            <groupId>com.adobe.flash.framework</groupId>
            <artifactId>playerglobal</artifactId>
            <version>${flashplayer.version}</version>
            <type>swc</type>
        </dependency>

        <dependency>
            <groupId>${flex.groupId}.flexunit</groupId>
            <artifactId>flexunit-flex</artifactId>
            <version>${flexunit.version}</version>
            <type>swc</type>
            <scope>test</scope>
        </dependency>


         <dependency>
            <groupId>org.apache.flex.framework</groupId>
            <artifactId>framework</artifactId>
            <version>${flex.sdk.version}</version>
            <type>swc</type>
            <scope>rsl</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.flex.framework</groupId>
            <artifactId>framework</artifactId>
            <version>${flex.sdk.version}</version>
            <classifier>${language}.rb</classifier>
            <type>swc</type>
            <scope>rsl</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.flex.framework</groupId>
            <artifactId>framework</artifactId>
            <version>${flex.sdk.version}</version>
            <type>swf</type>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>



--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexMojos-with-RSLs-tp48944.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
Mime
View raw message