Archive for June, 2008

Adding libraries to compilation…

Friday, June 27th, 2008

This is a how to post.

When developing with flex, is very common the need for 3rd party libraries to build more elaborated application.  If you wanna charts you must add datavisualization.swc.  If wanna SHA1 algoritm you need as3corelib. So go on…

Using Adobe’s command line compilers (mxmlc and compc) you will use any (or many) parameters from this list:

-compiler.external-library-path
-compiler.include-libraries
-compiler.library-path
-runtime-shared-library-path

But on flex-mojos that options are not available.  If there is no option available, how to add dependencies?

Simple, following maven way =D

Each required library must be add as a dependency.  So, if you need datavisualization you will add a dependency like this:
<dependency>
<groupId>com.adobe.flex.sdk</groupId>
<artifactId>datavisualization</artifactId>
<version>3.0.0.477</version>
<type>swc</type>
</dependency>

One big question: How to discovery dependency groupId and artifactId?
Well who make the library must define it. Since maven is not very popular on flex world it provably will not be defined and not available at any maven repository.

When you face this, you will define your own groupId/artifactId and install on your repository by hand.

Maven Guide to installing 3rd party JARs

Often times you will have 3rd party JARs that you need to put in your local repository for use in your builds. The JARs must be placed in the local repository in the correct place in order for it to be correctly picked up by Maven. To make this easier, and then error prone, we have provide a goal in the install plug-in which should make this relatively painless. To install a JAR in the local repository use the following command:
mvn install:install-file -Dfile= -DgroupId= \
-DartifactId= -Dversion= -Dpackaging=

You can follow the same logic for swc libraries.

And how to define how the dependency should be used? If it should be external, how to get it?
Defining dependency scope:
<dependency>
<groupId>com.adobe.flex.sdk</groupId>
<artifactId>datavisualization</artifactId>
<version>3.0.0.477</version>
<type>swc</type>
<scope>external</scope>
</dependency>

Flex-mojos supports 6 scopes:

    external to -compiler.external-library-path
    internal to -compiler.include-libraries
    merged to -compiler.library-path
    rsl to -runtime-shared-library-path for SWF files
    caching to -runtime-shared-library-path for SWZ files
    test to -compiler.library-path only for test running

If not defined will assumed merged as default.

To read more about flex-mojos scopes click here.

Have a nice weekend every body.

VELO

Html Wrapper Mojo

Monday, June 23rd, 2008

Hi folks,

This week we make public the first release of HtmlWrapperMojo.

This guy is used to generate the html to open flex applications, like what is done by flex builder.

To enable it, just add this new mojo on plugins section:

<build>
  <plugins>
    <plugin>
      <groupId>info.flex-mojos</groupId>
      <artifactId>html-wrapper-mojo</artifactId>
      <executions>
        <execution>
          <goals>
            <goal>wrapper</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

A simple hello world can be view here.

It’s very simple to use, and has no need of configurations do get it running.

It support all standard templates made by Adobe. Just need to define templateURI parameter. Valid values to templateURI:
class:client-side-detection
class:client-side-detection-with-history (default)
class:express-installation
class:express-installation-with-history
class:no-player-detection
class:no-player-detection-with-history

You can even point to a file using “file:///etc/hosts”. This file must be a zip and must have index.template.html inside it.

When using custom templates you may need to set custom parameters on your index.template.html. This can be done by configuring parameters:

<parameters>
	<swf>${build.finalName}</swf>
	<width>100%</width>
	<height>100%</height>
</parameters>

All required parameters to Adobe’s template are defined by default. But you can overwrite they at any time.

Any suggestions?

VELO

Flex-mojos 2.0-alpha1

Saturday, June 21st, 2008

This week we start to run flex-mojos 2.0 roadmap.

For alpha1 we have achieve this goals:

    Change all groupIds to info.flex-mojos.
    Generation of optimized RSLs (on alpha2)
    archetypes mojos.
    Some PMD fixies, not all, but some on compiler.

One new mojo was released too: HtmlWrapperMojo. To generate html wrapper. More details on a dedicated post.

So, keep in mind, to use flex-mojos 2.0-alpha1, you need to change the groupIds.

Good weekend to every one.

VELO

Using HellFire compiler under flex-mojos

Friday, June 20th, 2008

Hi folks,

Some days ago Clement Worg released his HelfFire compiler.

How it works? Well, you will have server and client compiler. Start server as a daemon and run compilation with client. Client will send the configurations to server and server will compile. With this, you don’t have to reload flex compiler every time you call maven. That’s a interesting idea. On my tests, show 50% faster on recurrent compilations.

Just to remember, compiling flex SDK, flex-mojos is two times faster them ant tasks. And flex-mojos, with hellFire, so far, show be faster them standard flex-mojos. So I recommend it for complex projects =p.

Like always, I released a sample on SVN.
http://svn.sonatype.org/flexmojos/trunk/rvin-mojo/flex-mojo-IT/src/test/resources/rpc-hfcd-sdk/

It’s very like to using a newer flex SDK. Just need to add a updated dependency on pom.xml:

<plugin>
  <groupId>info.flex-mojos</groupId>
  <artifactId>flex-compiler-mojo</artifactId>
  <extensions>true</extensions>
  <dependencies>
    <dependency>
      <groupId>com.adobe.flex</groupId>
      <artifactId>flex-compiler-oem</artifactId>
      <version>3.0.0.477-hfcd-SNAPSHOT</version>
    </dependency>
  </dependencies>
</plugin>

I call hfcd as version 3.0.0.477-hfcd-SNAPSHOT. I need to discovery if is possible to exclude flex-compiler-oem from dependency list and then add hfcd-client-compiler or something like that. Ok, focus, focus, focus, lets back.

When add this on pom, all is done, on flex-mojos side.

Install HFC following blog instructions. Start hfcd in one console instance then run maven in other.

Easy right?

Here I got some cool results.

I added hfcd-SNAPSHOT to flex-mojos repository. But don’t figure out why is not downloading (11PM, I need to sleep). May need installing by hand:
mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=flex-compiler-oem -Dversion=3.0.0.477-hfcd-SNAPSHOT -Dpackaging=jar -Dfile=${HFCD_HOME}\lib\flex-compiler-oem.jar -DgeneratePom=true

So far, I still don’t know if Clement will release HFC opensource or not, but this is not a problem right now. This is a good question, for tomorrow.

Good rpc compilations for every one.

VELO

Optimizer Mojo

Wednesday, June 18th, 2008

On issue 34 Romanic call for a plugin to optimize SWC files.

Now is possible with the new optimizer-mojo.

The usage is very simple. Just need to add this:

  <plugin>
    <groupId>info.rvin.mojo</groupId>
    <artifactId>optimizer-mojo</artifactId>
    <version>2.0-alpha1</version>
    <executions>
      <execution>
        <goals>
          <goal>optimize</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

This mojo will extract library.swf from the current SWC. Them, will run adobe optimizer and digest. The new digest data will be placed on SWC. In the end, both (SWC and optimized SWF) will be installed at maven repo.

A sample is available here: http://svn.sonatype.org/flexmojos/trunk/rvin-mojo/flex-mojo-IT/src/test/resources/optimized-flex-library/

This is the first mojo released on 2.0 universe.

Waiting for comments.

VELO

Adding svn build number and timestamp

Monday, June 16th, 2008

As inspired by this post, I wanted to add the svn build number and a timestamp to our application’s about box. This is how to achieve this with flex-mojos:

First, configure your pom to use the buildnumber plugin as such (this requires that you have a command line subversion client installed and on your path):

  <build>
      <plugins>
    <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>buildnumber-maven-plugin</artifactId> 
      <executions> 
        <execution> 
          <phase>validate</phase> 
          <goals> 
            <goal>create</goal> 
          </goals> 
        </execution> 
      </executions> 
      <!-- <configuration> 
        <doCheck>false</doCheck> 
        <doUpdate>true</doUpdate> 
      </configuration>  -->
    </plugin>
<plugin>
<groupId>info.rvin.mojo</groupId>
<artifactId>flex-compiler-mojo</artifactId>
<configuration>
<defines>
<BUILD::buildNumber>${buildNumber}</BUILD::buildNumber>
<BUILD::timestamp>${timestamp}</BUILD::timestamp>
</defines>
</configuration>
</plugin>
</plugins>
</build>
Then, you can use this value like this in your code:
// application version
public static const VERSION:String = “1.0″;
// stores the svn build number
public static const BUILD_NUMBER:Number = BUILD::buildNumber;  

// stores the timestamp of the last build
public static const BUILD_TIMESTAMP:Date = new Date(BUILD::timestamp);

 

In our About box, we have:


<mx:Label text="Version: {VERSION} Build: {BUILD_NUMBER} Time: {BUILD_TIMESTAMP.toLocaleString()}"
selectable="true" />

You will then need to these variables to your Flex Builder compiler settings (Project Properties, Flex Compiler):
-locale en_US -define=BUILD::buildNumber,0 -define=BUILD::timestamp,0

If someone knows of a better way to integrate the maven values and Flex Builder, post a comment.

1.0 final

Monday, June 16th, 2008

Flex-mojos 1.0 is out.

The following mojos are released as 1.0:
asdoc
encrypter-mojo
flex-compiler-mojo
flex-super-pom
generator-mojo
source-mojo

Begin to work on 2.0

VELO

Maven Repository

Saturday, June 14th, 2008

Hi guys,

I moved maven repository with SVN. So, update your poms:
<repositories>
  <repository>
    <id>flex-mojos-repository</id>
    <url>http://svn.sonatype.org/flexmojos/repository/</url>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
</repositories>

VELO

RC4

Friday, June 13th, 2008

This is probably the last RC.

Fixed all open defects. We still have some Enhancement, but will be done on 2.0.

This version will be released as final this weekend, if nobody found any serious bug.

50 issues opened. Just 12 stay open, no Defects open.

I hope everyone likes. My favorite fix on this version is RSL order. When you use more then one RSL (i.e. Framework + rpc) you must load they in order (first framework then rpc). And the compilation must be in the order too. So, flex-mojos will look into pom.xml, resolve dependency tree, and sort it. So far is cool, but only works well on SWCs with pom.xml, and this pom must have the dependency list.

I implement this when I came across with this problem:
http://tech.groups.yahoo.com/group/flexcoders/message/113765

I hope everyone enjoy it.

VELO

Maven archetype for Flex-Mojos

Thursday, June 12th, 2008

Great work from Jeremy Anderson.

Read more here.

Usage:
mvn archetype:create -DgroupId=com.acme -DartifactId=simpleProject -DarchetypeGroupId=com.codeadept -DarchetypeArtifactId=flex-mojos-archetype -DremoteRepositories=http://flexonjava.googlecode.com/svn/repository