When developing with flex, it is very common to need 3rd party libraries to build more elaborate applications. For example: if an application uses charts, the project will require datavisualization.swc. If an application needs an SHA1 algorithm, it will require as3corelib, and so on.
Using Adobe's command line compilers (mxmlc and compc) you will use parameters from this list:
But on flex-mojos those options are not available. If there is no option available, how does one add these libraries?
Simple, following maven way =D
Each required library must be added as a dependency. If you need datavisualization you will add a dependency like this:
One big question: How do you discover the dependency's groupId and artifactId?
As with any module in maven, those who created the module must define their groupId and artifactId. Since flex is not very popular with the maven world, it most likely will not be available in any maven repository. If this is the case, you will define your own groupId/artifactId and install on your own repository.
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.
Download data visualization swc's from here, you need to install them into your maven repo as follows:
- extract the zip file and cd to the datavisualization_sdk3.3/frameworks/libs and issue the mvn install command.
- do the same for /frameworks/locale/en_US and run the following commands:
You will need the matching dependencies in your pom:
How do you define how the dependency should be used? If it should be external, how do you get it?
Defining dependency scope:
Flex-mojos supports 6 scopes:
- merged: this is the default value, when not defined will assume merged. That means SWC/SWF file will be bigger and self sufficient. Same as -compiler.library-path
- internal: all dependency content will be included on target SWC/SWF. Biggest compiled file. Same as -compiler.include-libraries
- external: no dependency content will be included on target SWC/SWF. Smaller compiled file. Makes no sense to use this scope on SWF compilation. Same as -compiler.external-library-path
- rsl: no dependency content will be inclued on SWC/SWF. But, SWF will have a reference to load it a runtime. Do not use on SWC compilation. Same as -runtime-shared-library-path
- caching: same as RSL, but uses Adobe signed SWZ files.
- test: libraries required to run tests. Same as -compiler.include-libraries, but at test template only!