Skip to content

Open Source

Using a faster Flex SDK on Maven

Flex-mojos: Maven 2 plugins for Flex - Thu, 10/30/2008 - 03:34

Brian spent some time with Flex SDK, and guess what, he did magic, got it faster.

He publish how and binaries here.

Well, if you wanna try this patched version, it’s easy:
1 - Download your fresh Flex SDK;
2 - Download Brian’s patch (FDK 3.0 or FDK 3.1);
3 - Unpack zip content into SDK lib folder (jars to jars);
4 - Use install mojo to get it on maven repo. (I suggest using a version like 3.1.0-brian, or something like that)
5 - Then just need to update plugin and project dependencies. Like what is done to upgrade FDK version.

Just 5 steps =P

VELO

Categories: Open Source

More Archetypes from FNA

Flex-mojos: Maven 2 plugins for Flex - Tue, 10/28/2008 - 20:53

François keep working on FNA.

Today he announce more archetypes.

The available archetype’s list is here.

Just to remember:

Archetype is a Maven project templating toolkit.

Read more about archetypes at Maven Introduction to Archetypes.

Another cool thing on François’ announcement is the flex-mojos presence at Max.
May be next year I can be there too :D
That is all folks,

VELO

Categories: Open Source

Cool AspectJ usage

Flex-mojos: Maven 2 plugins for Flex - Mon, 10/27/2008 - 16:11

Hi folks,

Flex-mojos is written in Java.
Most flex back end are in Java (at least here)
And time to time, in order to fix/improve/update Flex-mojos I need to dig into some cools Java APIs. So, I will blog a little bit every time I found and use something cool.

Why?
1) Share cool Java APIs;
2) Exchange ideas (through comments, discussions, whatever);
3) Get more ideas to improve Flex-mojos;
4) That can help readers to improve their own server side applications.

So, first topic will be AspectJ.

AspectJ is:
* a seamless aspect-oriented extension to the Javatm programming language
* Java platform compatible
* easy to learn and use

AspectJ enables:
* clean modularization of crosscutting concerns, such as error checking and handling, synchronization, context-sensitive behavior, performance optimizations, monitoring and logging, debugging support, and multi-object protocols

For years I looked with curiosity to AspectJ, but I never tried it. Why? Fear to fail. No real need. No pressure for it. Don’t know.

One day, I read I came across with this post:
Two Fantastic Uses for AspectJ: Part One, Backward Compatibility

What was the problem here?
1 - Newer flex-compiler OEM has newer features, which means, new methods.
2 - I don’t wanna keep 2 flex-mojos versions, one “unstable” (with new features) and another “stable” (only with bug fixes). I wanna one version, with new features and bug fixes. And I don’t need to be afraid of add new features because flex-mojos has a good number of integration tests, which helps me to be sure my changes don’t break anything.

What was done?
Well, every time I have a feature, which depends on a new flex-compiler-oem version, I put this feature on a new method. And this method receives one annotation like this:

@FlexCompatibility( maxVersion = "2" )
@FlexCompatibility( minVersion = "3" )
@FlexCompatibility( minVersion = "3.1", maxVersion = "4" )

And I create one around aspect. Every time one method annotated with @FlexCompatibility is about to run, my aspect is invoked. Then it check if current versions is bigger then minVersion and/or smalled then maxVersion. If true, run the method code. If not, log and skip.

That prevent my code from throwing method not found exceptions. And allow me to use new features without breaking backward compatibility. Doing so, flex-mojos is even compatible with flex 2… May be even compatibili-zable (if this word exists) with 1.0 and 1.5 compilers, but this is something I will not look into =D

I could do that adding several ifs to my code. But ifs are harder do maintain. This annotation made my code much more elegant. Now I purge deprecated API invocations to specific methods, annotated with @FlexCompatibility( maxVersion = “2″ ) and @SuppressWarnings( “deprecation” ).

The aspect code is here. And it is used at compiler-mojo here.

If someone have more ideas to improve this, ping me. And I hope that can help on your projects too.

VELO

Categories: Open Source

Get Test Coverage Reports

Flex-mojos: Maven 2 plugins for Flex - Tue, 10/21/2008 - 10:44

The Maven Flexcover plugin is not quite finished, but for those that are impatient or adventurous, it is far enough along to do a few things. Until the plugin is finished and integrated into the normal build, there are 2 ways to run Flexcover with your flex-mojos project: Use the latest flexcover-mojo snapshot, or download your own Flexcover SDK and use a maven profile as a special build. I will show how to do each of them below.

For either method, you need to install the CoverageViewer Air application in order to capture and view the coverage results. If you do not have Air installed, install it first. Then download flexcover-0.50.zip from the Flexcover Google code site and unzip it. You should be able to now double-click CoverageViewer.air to install it. Keep track of where you installed the CoverageViewer application (CoverageViewer.app on Mac, CoverageViewer.exe on Windows, CoverageViewer on Linux) as you may need this path later.

1. To use the latest snapshot (2.0M8-SNAPSHOT) from trunk, first checkout the trunk:

svn co http://svn.sonatype.org/flexmojos/trunk/rvin-mojo/
cd rvin-mojo
mvn install -DskipTests
mvn install -f flexcover-mojo/pom.xml

Now that you have the latest snapshot installed in your local repository, modify your project pom to configure the flexcover-mojo:

  <plugin>
        <groupId>info.flex-mojos</groupId>
        <artifactId>flexcover-mojo</artifactId>
	<version>2.0M8-SNAPSHOT</version>
        <dependencies>
          <dependency>
	      <groupId>com.adobe.flex</groupId>
	      <artifactId>compiler</artifactId>
	      <version>3.0.1.1092-flexcover_0.61</version>
              <type>pom</type>
           </dependency>
        </dependencies>
  <configuration>
	<coverageViewerPath>/Users/logan/projects/Tools/CoverageViewer.app/Contents/MacOS/CoverageViewer</coverageViewerPath>
  </configuration>
</plugin>

You will need to replace coverageViewerPath with the path to your CoverageViewer executable (CoverageViewer.exe on Windows, CoverageViewer on Linux, CoverageViewer.app/Contents/MacOS/CoverageViewer on Mac).

I have uploaded the modified Flexcover SDK (MPL/free version) to our Google code repository, so you will need to add this repository to your pom as well (if you need non-free SDK libraries like fontkit, Charts, or automation, you will need to create your own Flexcover SDK following the instructions on the Flexcover website and install it using the install-mojo).

<repository>
	<id>flex-mojos-googlecode-repository</id>
	<url>http://flex-mojos.googlecode.com/svn/trunk/repository/</url>
</repository>

You also need to add a dependency to the Flexcover SDK:

<dependency>
	<groupId>com.adobe.flex.framework</groupId>
	<artifactId>flex-framework</artifactId>
	<version>3.0.1.1092-flexcover_0.61</version>
	<type>pom</type>
</dependency>

You should be able to run your project now like this:
mvn clean flexcover-mojo:instrument flexcover-mojo:flexcover-run
That will instrument your classes and run your tests. Your results will be at target/flexcover-classes/flexcover-results.cvr
You can look at this example project.

The other way to use flexcover right now is to:
2. Use a special profile and your own copy of the Flexcover SDK
To do this, you will need to follow the instructions in the Flexcover download on how to create your own modified Flexcover SDK (doc/index.html in the zip file).
Once you have the Flexcover SDK properly set up on your local machine, modify your prom and add a special flexcover profile:

    <profile>
      <id>flexcover</id>
      <properties>
        <flex.sdk.version>3.0.1.1092-flexcover_0.50</flex.sdk.version>
        <flexcover.sdk.path>/Users/logan/flexcover-sdk/</flexcover.sdk.>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>info.flex-mojos</groupId>
            <artifactId>flex-compiler-mojo</artifactId>
            <version>2.0M7</version>
            <configuration>
              <locales>
                <locale>en_US</locale>
              </locales>
              <configFile>${flexcover.sdk.path}/frameworks/flex-config.xml</configFile>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

You need to replace the path at flexcover.sdk.path with the path to your local Flexcover SDK that you created earlier.
For this to work, you will need to add a properties section to your normal build configuration:

  <properties>
    <flex.sdk.version>3.1.0.2710</flex.sdk.version>
  </properties>

And replace every place that you have the Flex SDK version in your pom with ${flex.sdk.version}

You should now be able to run:
mvn test -P flexcover
on your project, and in your target/test-classes directory will be .cvm files that you can load into CoverageViewer. You then run:
mvn test -P flexcover
again with CoverageViewer open to capture the coverage.

I probably have mistakes, typos, and bugs in these instructions or the flexcover-mojo code. Please let us know if it worked or what problems you had, we’ll keep this updated as best we can. Comment here or on the mailing list.

Hopefully an integrated version of the flexcover-mojo will be available in the near future. Until then, I hope this gets you started with Flexcover

Logan

Categories: Open Source

Automated UI tests

Flex-mojos: Maven 2 plugins for Flex - Fri, 10/17/2008 - 03:38

Some days ago, I came across with FlexMonkey.

FlexMonkey is a unit testing framework for Flex apps that provides for automating the testing of Flex UI functionality. FlexMonkey can record and play back Flex UI interactions, and generates ActionScript-based testing scripts that can easily be included within a continuous integration process. It uses the Flex Automation API and was created by adapting Adobe’s sample application, AutoQuick.

So I decide to try it with flex-mojos. And figure out it works, but, need some preparation.

With you wanna do that too, I first suggest you to take a look on FlexMokey quick tutorial here.

FlexMokey uses flex automation, so, we need to make it available at maven repository. So let’s start installing flexbuilder FDK at maven repo. For that task we use the install-mojo:
mvn info.flex-mojos:install-mojo:install-sdk -Dflex.sdk.folder=${your path to flexbuilder}/sdks/3.1.0 -Dversion=3.1.0-fb3

I call it 3.1.0-fb3. Because I don’t wanna to confuse with mpl version available at flex-mojos repo. I suggest you do the same.

Another dependency we need at maven repo is the flex monkey itselft. So, download this zip (or any newest), unpack somewhere and install it using maven install-file:
mvn install:install-file -DgroupId=com.gorillalogic -DartifactId=flexmonkey -Dversion=0.2b -Dpackaging=swc [-DgeneratePom=true] -Dfile=${unpack.folder}/MonkeyExample/libs/FlexMonkey.swc

I’m using this ids (groupId and artifactId) as personal guess. May be project authors can one day start to use maven and change it. So far they don’t. The parameter under [] is not required. But is good to have, avoid get maven trying to download this pom each time you compile the project.

Now we must create a pom.xml. Like this one:

<?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>info.flex-mojos.samples</groupId>
  <artifactId>flexmonkey-sample</artifactId>
  <version>1.0-SNAPSHOT</version>
 
  <packaging>swf</packaging>
 
  <build>
    <sourceDirectory>src</sourceDirectory><!-- I don't wanna change MonkeyExample project -->
    <resources>
      <resource>
        <directory>resources</directory><!-- need a resouces directory to FlexMonkeyEnv.xml -->
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>info.flex-mojos</groupId>
        <artifactId>flex-compiler-mojo</artifactId>
        <version>2.0M8-SNAPSHOT</version> <!-- need to use TRUNK -->
        <extensions>true</extensions>
        <configuration>
          <locales>
            <locale>en_US</locale>
          </locales>
          <includes>
            <include>test.FlexUnitTests</include>
          </includes>
        </configuration>
      </plugin>
      <plugin>
        <!-- get FlexMonkeyEnv.xml copyed -->
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
          <outputDirectory>${project.build.directory}</outputDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
 
  <repositories>
    <repository>
      <id>flex-mojos-repository</id>
      <url>http://svn.sonatype.org/flexmojos/repository/</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>flex-mojos-repository</id>
      <url>http://svn.sonatype.org/flexmojos/repository/</url>
    </pluginRepository>
  </pluginRepositories>
 
  <dependencies>
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>flex-framework</artifactId>
      <version>3.1.0-fb3</version>
      <type>pom</type>
    </dependency>
    <dependency> <!-- I'm guessing this IDs -->
      <groupId>com.gorillalogic</groupId>
      <artifactId>flexmonkey</artifactId>
      <version>0.2b</version>
      <type>swc</type>
      <scope>internal</scope>
    </dependency>
 
    <!--
      Automation dependencies, already added by flex-framework, but need to
      change the scope
    -->
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>automation</artifactId>
      <version>3.1.0-fb3</version>
      <type>swc</type>
      <scope>internal</scope>
    </dependency>
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>automation_agent</artifactId>
      <version>3.1.0-fb3</version>
      <type>swc</type>
      <scope>internal</scope>
    </dependency>
 
    <!-- flexunit dependencies -->
    <dependency>
      <groupId>flexunit</groupId>
      <artifactId>flexunit</artifactId>
      <version>0.85</version>
      <type>swc</type>
      <scope>internal</scope>
    </dependency>
    <dependency>
      <groupId>flexunit.junit</groupId>
      <artifactId>flexunit-optional</artifactId>
      <version>0.85</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>
 
  </dependencies>
</project>

The last step is to copy FlexMonkeyEnv.xml from flexmonkey to resouces folder. That folder don’t exists, must be created.

Now you should be able to run maven:
mvn clean package [or install]

Double click on flexmonkey-sample-1.0-SNAPSHOT.swf should show Monkey Contact Manager with Flex Monkey panel. Like this.

So a fast check list.

    Install FLEX SDK using install-mojo
    Install FlexMonkey using maven install-file
    Create pom.xml
    Copy FlexMonkeyEnv.xml to resouces folder

My final project is available here.

So far so good, but, the application is not tested at maven build. How do we do that? I don’t know that! Yet. Anyone wanna help?

VELO

Categories: Open Source

Thu, 01/01/1970 - 02:00