The Grand Cloud

The Grand Cloud

Dec 19 / 2:21pm

Intro to flex mojo’s for maven

Velo has put together some nice mojo’s for compiling flex with maven. Here is some quick tips on quickly settings up and using them. Note that you don’t even have to download the mojo’s to use them. They will be automatically downloaded the first time you compile your project. The first thing to understand is that the mojo’s use the standard maven way of doing things and only use jar files and library files from a maven repository. That means that they don’t look in the flex sdk directory for the necessary files, so these need to be installed in your repository. Also I ran into the problem that compiling on a remote server I ended up needing the data visualization libraries? First be sure you have the current version of maven, which is 2.0.9: mvn -version On the Mac OSX, maven 2.0.6 is installed be default. To upgrade just overwrite the files in /usr/share/maven Now install all the necessary dependencies in your local repository. These are propietary jar files, so they can be distributed from a central repository. First cd to your flex sdk directory and the under the lib directory. In there you should a whole bunch of jar files. Then run the following commands: mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=license -Dversion=3.0.0.477 -Dpackaging=jar -Dfile=license.jar mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=aglj32 -Dversion=3.0.0.477 -Dpackaging=jar -Dfile=aglj32.jar mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=flex-fontkit -Dversion=3.0.0.477 -Dpackaging=jar -Dfile=flex-fontkit.jar mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=rideau -Dversion=3.0.0.477 -Dpackaging=jar -Dfile=rideau.jar Now it is likely that you will end up needing the data visualization libraries, so do the following. cd to the flex frameworks dir flex-sdk-3.0.0/frameworks/libs and run the following commands: mvn install:install-file -DgroupId=com.adobe.flex.sdk -DartifactId=datavisualization -Dversion=3.0.0.477 -Dpackaging=swc -Dfile=datavisualization.swc then cd to the flex locale dir flex-sdk-3.0.0/frameworks/locale/en_US and run the following commands: mvn install:install-file -DgroupId=com.adobe.flex.sdk -DartifactId=datavisualization -Dversion=3.0.0.477 -Dclassifier=en_US -Dpackaging=swc -Dfile=datavisualization_rb.swc Now you are all set to run the flex compiler on your project! I have put a sample pom file here. Here are a couple of tips to setting up your compile process: 1 - To configure all the different options of the compiler find the option you need on this page and then in your pom add it to the build -> plugins -> plugin (flex-compiler-mojo) -> configuration. For example I set the name of the sourceFile in there. 2 - To add library dependencies, for example swc libraries first add them to your repository. For example to use the flexlib files use the following command similar to this : mvn install:install-file -DgroupId=com.googlecode.flexlib -DartifactId=flexlib -Dversion=2.4 -Dpackaging=swc -Dfile=flexlib.swc Then add a dependency tag to your pom. In the sample it is the dependency with the flexlib artifact id. The types can be one of the following: 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 Good luck!

0 comments

Leave a comment...

Ryan Knight  //  Ryan Knight is a Senior Flex and Java consult with 14 years of experience in all aspects of technology.