In order to get started with Apache Flex and Maven, you need to download and convert an Apache Flex SDK as well as the Adobe Flash/Air resources. For this task we have created a tool called the "flex-sdk-converter" which is part of the "flex-utilities" package. With this tool there are two options:
- Use the Commandline tool to download, convert, install and deploy flex related resources
- Use the flex-maven-extension as Maven extension to automatically download, convert, install but not deploy
If you are a one-man-show or just want to experiment, we strongly suggest to make use of the flex-maven-extension. If you are however working in a company with a company-internal maven repository or you need to make a CI system access the resources, the CLI tool is the better option as the extension need the user to enter "yes" several times, which is not possible in a CI build.
Both tools have not yet been officially released, so you need to stick to the SNAPSHOT version.
Building the flex-sdk-converter
Checkout the code via GIT:
git clone https://git-wip-us.apache.org/repos/asf/flex-utilities.git git checkout develop
Go to the "flex-sdk-converter" directory and run a normal Maven build:
cd flex-maven-tools/flex-sdk-converter mvn install
If all goes well you'll see this:
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 54.212s [INFO] Finished at: Wed Apr 22 19:42:36 CEST 2015 [INFO] Final Memory: 34M/362M [INFO] ------------------------------------------------------------------------
The CLI tool will be available in: "flex-utilities/flex-maven-tools/flex-sdk-converter/cli/target/apache-flex-sdk-converter-1.0.0-SNAPSHOT.jar".
The Maven extension will be located in: "flex-utilities/flex-maven-tools/flex-sdk-converter/maven-extension/target/flex-sdk-converter-maven-extension-1.0.0-SNAPSHOT.jar" and "flex-utilities/flex-maven-tools/flex-sdk-converter/maven-extension/target/flex-sdk-converter-maven-extension-nodeps-1.0.0-SNAPSHOT.jar"
Prepare the FDK resources using the CLI tool
The CLI is stared with the following command:
java -jar flex-utilities/flex-maven-tools/flex-sdk-converter/cli/target/apache-flex-sdk-converter-1.0.0-SNAPSHOT.jar
This will output a short description on how to use the tool:
usage: java -jar apache-flex-sdk-converter.jar [list] [-fdkDir <fdkDir>] [-mavenDir <mavenDir>] [[-flexVersion <version>] [-flashVersions <version(s)>] [-airVersion <version> [-platforms <platform(s)>]] [-fontkit] download] [convert] [-repoUrl <url> [-repoUsername <username> -repoPassword <password>] deploy] Commands: If the parameters 'fdkDir' and 'mavenDir' are not specified, the Converter creates two temporary directories in your systems temp directory and uses these for the follwoing commands. - list: List all available versions and platforms (for download) - download: Download the selected versions of FDK parts specified by 'flexVersion', 'flashVersions', 'airVersion' and 'fontkit' and creates an FDK in the directory specified by 'fdkDir'. If 'airVersion' is specified, the 'platforms' parameter specifies the platforms for which the given AIR SDK should be downloaded, if not specified the current systems platform is used. - convert: Convert the FDK located in 'fdkDir' into a mavenized form at 'mavenDir'. - deploy: Deploy the maven artifacts located in 'mavenDir', to the remote maven repository specified with 'repoUrl'. If the 'repoUsername' and 'repoPassword' parameters are specified, use these credentials for authenticating at the remote system. Options: -airVersion <version> (Optional and Only valid for download) Version of the Adobe Air SDK which should be downloaded. -fdkDir <dir> (Optional) Directory that the FDK will be located in. If omitted, a temporary directory will be used. -flashVersions <version(s)> (Optional and Only valid for download) Version(s) of the Adobe Flash SDK which should be downloaded. Multiple versions can be separated by ",". -flexVersion <version> (Optional and Only valid for download) Version of the FDK which should be downloaded. -fontkit (Optional and Only valid for download) If provided, the Converter will also download the Fontkit libraries needed for font encoding. -mavenDir <dir> (Optional) Directory that the mavenized artifacts will be located in. If omitted, a temporary directory will be used. -platforms <platform(s)> (Optional and Only valid for download) Platform the artifacts should be downloaded for. If omitted the platform this process is run on will be used. Valid options are: "WINDOWS", "MAC" and "LINUX". Multiple versions can be separated by ",". -repoPassword <password> (Optional and only valid for deploy) Password used to authenticate on the remote Maven repository that the generated Maven artifacts should be deployed to. -repoUrl <url> (Optional and only valid for deploy) Url of the remote Maven repository that the generated Maven artifacts should be deployed to. -repoUsername <username> (Optional and only valid for deploy) Username used to authenticate on the remote Maven repository that the generated Maven artifacts should be deployed to.
With the CLI tool you can download flex, flash, air and fontkit resources, convert them into a mavenized form as well as deploy them to a remote repository.
The paramerers.
- flashVersions
- platforms
are multi-value parameters with multiple values separated by ",".
Here come some example scenarios:
Download Flex 4.14.1, Flash 17.0, Air 17.0 (for Windows and Mac) as well as the Fontkit
java -jar apache-flex-sdk-converter-1.0.0-SNAPSHOT.jar -flexVersion 4.14.1 -flashVersions 17.0 -airVersion 17.0 -platforms WINDOWS,MAC -fontkit -fdkDir {fdk-dir} download
As a result you will get a full FDK in the {fdk-dir} directory (Same as you would with the Flex Installer)
Convert any resources in the {fdk-dir} and output maven artifacts to {maven-dir}
java -jar apache-flex-sdk-converter-1.0.0-SNAPSHOT.jar -fdkDir {fdk-dir} -mavenDir {maven-dir} convert
Deploy maven artifacts in {maven-dir} to a remote repository
java -jar apache-flex-sdk-converter-1.0.0-SNAPSHOT.jar -mavenDir {maven-dir} -repoUrl {repository-url} -repoUsername {username} -repoPassword {password} deploy
Download and convert an FDK directly into its mavenized form
java -jar apache-flex-sdk-converter-1.0.0-SNAPSHOT.jar -flexVersion 4.14.1 -flashVersions 17.0 -airVersion 17.0 -platforms WINDOWS,MAC -fontkit -mavenDir {maven-dir} download convert
Download, convert and deploy an FDK to a remote maven repository
java -jar apache-flex-sdk-converter-1.0.0-SNAPSHOT.jar -flexVersion 4.14.1 -flashVersions 17.0 -airVersion 17.0 -platforms WINDOWS,MAC -fontkit -repoUrl {repository-url} -repoUsername {username} -repoPassword {password} download convert deploy
If you want to keep the maven artifacts locally, just add the "mavenDir" directory:
java -jar apache-flex-sdk-converter-1.0.0-SNAPSHOT.jar -flexVersion 4.14.1 -flashVersions 17.0 -airVersion 17.0 -platforms WINDOWS,MAC -fontkit -mavenDir {maven-dir} -repoUrl {repository-url} -repoUsername {username} -repoPassword {password} download convert deploy
Prepare the FDK resources using the flex-sdk-converter-maven-extension
The by far easiest way to get started, is definitely using the flex-maven-extension. In order to use this option, you need to copy the jar "flex-maven-extension-1.0.0-SNAPSHOT.jar" into your maven installation in the directory "{maven-home}/lib/ext".
For users of Maven 3.3.1 or above
If you are using Maven 3.3.1 or above you can also enable the maven extension automaticaly by creating ".mvn" directory in your projects root and creating an extensions.xml inside this with the following content:
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd"> <extension> <groupId>org.apache.flex.utilities.converter</groupId> <artifactId>flex-sdk-converter-maven-extension</artifactId> <version>1.0.0-SNAPSHOT</version> </extension> </extensions>
Then maven will automatically download the extension and use it in your project (but just that project).
Currently the flex-sdk-converter-maven-extension has not been released yet and therefore the libs aren't available in Maven central. As the maven extensions are processed before the pom itself is read, you can add as many repositories as you like to your pom. Maven will still not know where to get the maven-extension from. Therefore you need to tell maven where to get it by modifying/creating a settings.xml file (See maven documentation on where to put it). I added a settings.xml HERE which should contain all entries you need to get started (It actually contains far more than you need for the maven-extension)
As soon as the extension is copied there it will monitor maven resolution requests and, in case of Flex related requests, it will automatically download, convert and locally install the missing parts. When downloading Adobe artifacts it will however prompt you that you need to accept a license agreement in order to proceed. If you enter "yes" the conversion will be done.
As soon as the maven extension is in place, as soon as a flex-releated resource is requested you will see the following output on the console:
[INFO] `,;':, :';;; `:;''';' `++'';;, :;'''++;' .+'+''';;; : ;'''++++'' ,';+++''';' ,. `, ,. ..: , `, `'''+++##;'', ;;'+#+++'''' ; ; ; ;; ;`: :,: ; ; ;'+++; #;;;;;:::;;;;+ +++'': ; ; : ;; ;., : : ;. ;;++# ';;;;;;;;;;+ .+++; `;: :; `;: :;: , :;` +;+# ,;;;:::::;: ;#+', ;++++:'++ : ;+,; ++;# +;::::::; ,+;;: ++++++,'++ `++' +'''` ;::::::, +:;;: `+++. '++ ++++++ +++ +++ ''''' ;::::: :;;;; +++` '++ ++++++++ +++` `++: :'';;; ;::` ::::: +++ '++ +++' :++: +++ +++ ;;;;;' :::::: +++ '++ +++ ++' `+++++` ;;;;;;: .:::::` +++++++ '++ +++:::+++. +++++ ;;;;;;; ,::::: +++++++ '++ +++++++++ :+++' ;;;;;;; ,::::: +++''' '++ +++;;;:` +++++ ;;;;;;` ::::::. +++ '++ +++ +++ +++ ;;;;;: :::::: +++ :++. ++++ ` :++, ,++; ''';;. `..: ::::;` +++ ++' +++++++ +++ +++ :'''; ,,,,,: ;;;;; ;++` +++ ++++++ +++ +++ .+';+ :,,,,,,: `';;; ++' `+''' ::,,,,,::: ';;' :++ #;'' +:::,,,:::: .'':; ';;'' ::::::::::::' ,';;:. ;;;;''`;+;;::` .::;;'.,';;;;: `::;;;''':;; `;;;'';;;;;; :::;;;'';: ;;';;;;;:; ,:::;;;', ',;;;;::` .:::;:. ;:;;::: ::;, `,;;`
As soon as you see this you are good to go.
Using the flex-sdk-converter-maven-extension behind a proxy
If you are trying to use the maven extension behind a prox, it will probably fail as it is not able to connect to the outside world. The flex-sdk-converter-maven-extension is therefore able to access the proxy settings in your settings.xml file. An example configuration would look like this:
<settings> ... <proxies> <proxy> <id>mycorp-proxy</id> <active>true</active> <protocol>http</protocol> <host>proxy.mycorp.int</host> <port>8080</port> <username>myuser</username> <password>mytopsecretpassword</password> <!--nonProxyHosts>www.google.com|*.example.com</nonProxyHosts--> </proxy> </proxies> ... </settings>