Featured Post

Maven Archetypes

217---->
Prev : 14.3. Getting Started
TOC
Next : 14.5. Using Add-Ons
14.4. Creating New Projects with the Android Maven Archetypes

When starting a fresh project it is easy to use the Maven Archetype Plugin to create a skeleton to start working with. Fortunately multiple archetypes for Android projects are available.

You can create a new android-quickstart project, which is similar to the helloflashlight example on the command line with

mvn archetype:generate \
-DarchetypeArtifactId=android-quickstart \
-DarchetypeGroupId=de.akquinet.android.archetypes \
-DarchetypeVersion=1.0.6 \
-DgroupId=your.company \
-DartifactId=my-android-application
Other archetypes available are an Android project including test execution with the archetypeArtifactId android-with-test-archetype and a project with release process configuration android-release-archetype.

Note

Many developmemt environments have a visual integration of creating new projects with a Maven archetype, so you can use that instead of the command line.

Prev : 14.3. Getting Started
TOC
Next : 14.5. Using Add-Ons
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








218---->
Prev : 14.2. Configuring Build Environment for Android Development
TOC
Next : 14.4. Creating New Projects with the Android Maven Archetypes
14.3. Getting Started

The HelloFlashlight example application serves as a starting point to introduce you to the usage of the Android Maven Plugin. The code for the helloflashlight example application as well as various more complex examples are available as part of the plugin samples project.

To enable a Maven based build of an Android project a pom.xml has to be added in the root folder of the project:

The HelloFlashlight pom.xml file.


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">
4.0.0
com.simpligility.android
helloflashlight
1.0.0-SNAPSHOT
apk
HelloFlashlight



com.google.android
android
1.6_r2
provided



${project.artifactId}
src



com.jayway.maven.plugins.android.generation2
android-maven-plugin
3.0.0-SNAPSHOT
true





com.jayway.maven.plugins.android.generation2
android-maven-plugin


true


4


16

true





The highlights of this pom.xml are:

the packaging type of apk
the dependency to the Android platform jar
and the build configuration with the Android Maven Plugin
The Android Package packaging type apk is what activates the Android-specific lifecycle modifications of the Android Maven Plugin. It takes care of all the specific calls to the Android SDK tools, that process resources, convert Java bytecode and so on. The Android Maven Plugin needs to be configured with extensions set to true for this to work as visible in the pluginManagement section.

The declared dependency to the android platform jar is available in Maven Central with various platform versions. Alternatively you could use an Android jar from the Maven Android SDK Deployer with the modified groupId and artifactId. The documentation of the deployer shows all valid dependencies.

The scope of provided is important. It signals to Maven that the contents of the jar will not need to be packaged into the application package, because they are available at runtime on the device as part of the environment.

In addition the android jar artifacts only contain exception throwing stubs for all methods in order to define the API for the compiler. They can not be executed on the development machine, but rely on an emulator or device runtime environment.

The configuration of the Android Maven Plugin is done in the build section. Initially only the sdk platform parameter is required to be specified. You can use either a platform version number or a API level number as documented on the Android developer documentation.

Tip

The version of the Android Maven Plugin in the pom file is a development version. Replace it with the latest released version, when running the example yourself or download the stable branch of the samples.

To build the application and run it on an already started emulator or attached device you could use

mvn install android:deploy android:run
Prev : 14.2. Configuring Build Environment for Android Development
TOC
Next : 14.4. Creating New Projects with the Android Maven Archetypes
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








219---->
Prev : 14.1. Introduction
TOC
Next : 14.3. Getting Started
14.2. Configuring Build Environment for Android Development

Before you attempt to build your Android libraries and applications with Maven, you will need to install the Android SDK and potentially install the Android API jar files into your local Maven repository or your repository server.

14.2.1. Installing the Android SDK

The Android Maven Plugin requires the presence of the Android SDK in your development environment. Install the SDK following the directions on the Android Developer web site.

The ANDROID_HOME environment variable should be configured to point to the installation directory of the Android SDK. For example if the SDK is installed in /opt/android-sdk-linux this can be achieved with

export ANDROID_HOME=/opt/android-sdk-linux
on a Unix/bash based system or

set ANDROID_HOME=C:\opt\android-sdk-linux
on a Windows system.

In addition to the SDK, the various platform versions you need for development should also be installed following the instructions. You can install a subset of available platforms or simply install all available versions.

Optionally, the path ANDROID_HOME/tools and ANDROID_HOME/platform-tools can be added to the PATH variable to allow easy command line execution of the various tools provided with the SDK.

14.2.2. Android artifact install into Maven repository

When building an Android application with Maven the compile process needs access to the Android API for the specific platform version the project is configured against. The Android SDK ships this as android.jar files in the different platform folders. In order for Maven to access these libraries, they need to be available in the local Maven repository.

Typically artifacts are available in Maven Central, however only the platform versions available in the Android Open Source Project are published to Maven Central. Newer versions of the platform as well as the compatibility package and proprietary extensions like the Google Maps support are not available there and need to be published to your Maven repository, if you want to use them in your Android project.

The artifacts published to Maven central are available as dependencies under the groupId com.google.android with the artifactId android and android-test.

The Maven Android SDK Deployer has been created to publish artifacts from the Android SDK into your local repository or repository server when using components that are not available in Central.

Download the tool by clicking on the Download Source button and extract the downloaded zip or tar archive in a folder of your choice. A folder with a naming pattern of mosabua-maven-android-sdk-deployer-XXX with XXX being a revision number like df824df will be created.

Installation to local repository

In order to install the android jar files from the different platform revisions into your local repository you run the command in the deployer folder.

cd mosabua-maven-android-sdk-deployer-df824df
mvn clean install
By default this will install all android.jar, maps.jar, usb.jar files and the compatibilty packages into your local Maven repository. You should find all newly installed files in the android, com.google.android.maps, com.android.future and android.support group identifiers under ~/.m2/repository.

Installation to remote repository

The above deployment works fine for one machine, but if you need to supply a whole team of developers and a cluster of build machines with the artifacts, you will want to deploy the artifacts once to a remote repository server that is available to all users. If you are not currently using a repository manager, you should download Nexus and configure a user with permission to deploy artifacts to a repository. To get started with Nexus, read the Nexus Installation chapter in the free, online Nexus book.

As a first step you will need to edit the repo.url property in the pom.xml in the top folder of the Maven Android SDK Deployer tool to point to the repository you want to publish to. Alternatively you can provide this property in the settings file or with -Drepo.url=theurl on the command line.

Then you need to add a server with the correct access credentials for the server to your Maven Settings file.

Snippet for settings.xml for the repository server access credentials.




android.repo
your username
your password



Once that configuration is completed, you can deploy the artifacts with the command mvn deploy. As a result you should find the artifact in the repository of your remote server.

Installation of a subset of all platforms

By default the Maven Android SDK Deployer tool will attempt to install or deploy all versions of the platforms artifacts into a repository. If you decide to only install a subset of the components the tool can be used with profile options to only install or deploy some artifacts. This can be done by specifying the platform API versions as a profile name.

mvn install -P 3.2
Further details are available in the Maven Android SDK Deployer documentation.

Prev : 14.1. Introduction
TOC
Next : 14.3. Getting Started
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








220---->
Prev : 14.1. Introduction
TOC
Next : 14.3. Getting Started
14.2. Configuring Build Environment for Android Development

Before you attempt to build your Android libraries and applications with Maven, you will need to install the Android SDK and potentially install the Android API jar files into your local Maven repository or your repository server.

14.2.1. Installing the Android SDK

The Android Maven Plugin requires the presence of the Android SDK in your development environment. Install the SDK following the directions on the Android Developer web site.

The ANDROID_HOME environment variable should be configured to point to the installation directory of the Android SDK. For example if the SDK is installed in /opt/android-sdk-linux this can be achieved with

export ANDROID_HOME=/opt/android-sdk-linux
on a Unix/bash based system or

set ANDROID_HOME=C:\opt\android-sdk-linux
on a Windows system.

In addition to the SDK, the various platform versions you need for development should also be installed following the instructions. You can install a subset of available platforms or simply install all available versions.

Optionally, the path ANDROID_HOME/tools and ANDROID_HOME/platform-tools can be added to the PATH variable to allow easy command line execution of the various tools provided with the SDK.

14.2.2. Android artifact install into Maven repository

When building an Android application with Maven the compile process needs access to the Android API for the specific platform version the project is configured against. The Android SDK ships this as android.jar files in the different platform folders. In order for Maven to access these libraries, they need to be available in the local Maven repository.

Typically artifacts are available in Maven Central, however only the platform versions available in the Android Open Source Project are published to Maven Central. Newer versions of the platform as well as the compatibility package and proprietary extensions like the Google Maps support are not available there and need to be published to your Maven repository, if you want to use them in your Android project.

The artifacts published to Maven central are available as dependencies under the groupId com.google.android with the artifactId android and android-test.

The Maven Android SDK Deployer has been created to publish artifacts from the Android SDK into your local repository or repository server when using components that are not available in Central.

Download the tool by clicking on the Download Source button and extract the downloaded zip or tar archive in a folder of your choice. A folder with a naming pattern of mosabua-maven-android-sdk-deployer-XXX with XXX being a revision number like df824df will be created.

Installation to local repository

In order to install the android jar files from the different platform revisions into your local repository you run the command in the deployer folder.

cd mosabua-maven-android-sdk-deployer-df824df
mvn clean install
By default this will install all android.jar, maps.jar, usb.jar files and the compatibilty packages into your local Maven repository. You should find all newly installed files in the android, com.google.android.maps, com.android.future and android.support group identifiers under ~/.m2/repository.

Installation to remote repository

The above deployment works fine for one machine, but if you need to supply a whole team of developers and a cluster of build machines with the artifacts, you will want to deploy the artifacts once to a remote repository server that is available to all users. If you are not currently using a repository manager, you should download Nexus and configure a user with permission to deploy artifacts to a repository. To get started with Nexus, read the Nexus Installation chapter in the free, online Nexus book.

As a first step you will need to edit the repo.url property in the pom.xml in the top folder of the Maven Android SDK Deployer tool to point to the repository you want to publish to. Alternatively you can provide this property in the settings file or with -Drepo.url=theurl on the command line.

Then you need to add a server with the correct access credentials for the server to your Maven Settings file.

Snippet for settings.xml for the repository server access credentials.




android.repo
your username
your password



Once that configuration is completed, you can deploy the artifacts with the command mvn deploy. As a result you should find the artifact in the repository of your remote server.

Installation of a subset of all platforms

By default the Maven Android SDK Deployer tool will attempt to install or deploy all versions of the platforms artifacts into a repository. If you decide to only install a subset of the components the tool can be used with profile options to only install or deploy some artifacts. This can be done by specifying the platform API versions as a profile name.

mvn install -P 3.2
Further details are available in the Maven Android SDK Deployer documentation.

Prev : 14.1. Introduction
TOC
Next : 14.3. Getting Started
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








221---->
Prev : 14.1. Introduction
TOC
Next : 14.3. Getting Started
14.2. Configuring Build Environment for Android Development

Before you attempt to build your Android libraries and applications with Maven, you will need to install the Android SDK and potentially install the Android API jar files into your local Maven repository or your repository server.

14.2.1. Installing the Android SDK

The Android Maven Plugin requires the presence of the Android SDK in your development environment. Install the SDK following the directions on the Android Developer web site.

The ANDROID_HOME environment variable should be configured to point to the installation directory of the Android SDK. For example if the SDK is installed in /opt/android-sdk-linux this can be achieved with

export ANDROID_HOME=/opt/android-sdk-linux
on a Unix/bash based system or

set ANDROID_HOME=C:\opt\android-sdk-linux
on a Windows system.

In addition to the SDK, the various platform versions you need for development should also be installed following the instructions. You can install a subset of available platforms or simply install all available versions.

Optionally, the path ANDROID_HOME/tools and ANDROID_HOME/platform-tools can be added to the PATH variable to allow easy command line execution of the various tools provided with the SDK.

14.2.2. Android artifact install into Maven repository

When building an Android application with Maven the compile process needs access to the Android API for the specific platform version the project is configured against. The Android SDK ships this as android.jar files in the different platform folders. In order for Maven to access these libraries, they need to be available in the local Maven repository.

Typically artifacts are available in Maven Central, however only the platform versions available in the Android Open Source Project are published to Maven Central. Newer versions of the platform as well as the compatibility package and proprietary extensions like the Google Maps support are not available there and need to be published to your Maven repository, if you want to use them in your Android project.

The artifacts published to Maven central are available as dependencies under the groupId com.google.android with the artifactId android and android-test.

The Maven Android SDK Deployer has been created to publish artifacts from the Android SDK into your local repository or repository server when using components that are not available in Central.

Download the tool by clicking on the Download Source button and extract the downloaded zip or tar archive in a folder of your choice. A folder with a naming pattern of mosabua-maven-android-sdk-deployer-XXX with XXX being a revision number like df824df will be created.

Installation to local repository

In order to install the android jar files from the different platform revisions into your local repository you run the command in the deployer folder.

cd mosabua-maven-android-sdk-deployer-df824df
mvn clean install
By default this will install all android.jar, maps.jar, usb.jar files and the compatibilty packages into your local Maven repository. You should find all newly installed files in the android, com.google.android.maps, com.android.future and android.support group identifiers under ~/.m2/repository.

Installation to remote repository

The above deployment works fine for one machine, but if you need to supply a whole team of developers and a cluster of build machines with the artifacts, you will want to deploy the artifacts once to a remote repository server that is available to all users. If you are not currently using a repository manager, you should download Nexus and configure a user with permission to deploy artifacts to a repository. To get started with Nexus, read the Nexus Installation chapter in the free, online Nexus book.

As a first step you will need to edit the repo.url property in the pom.xml in the top folder of the Maven Android SDK Deployer tool to point to the repository you want to publish to. Alternatively you can provide this property in the settings file or with -Drepo.url=theurl on the command line.

Then you need to add a server with the correct access credentials for the server to your Maven Settings file.

Snippet for settings.xml for the repository server access credentials.




android.repo
your username
your password



Once that configuration is completed, you can deploy the artifacts with the command mvn deploy. As a result you should find the artifact in the repository of your remote server.

Installation of a subset of all platforms

By default the Maven Android SDK Deployer tool will attempt to install or deploy all versions of the platforms artifacts into a repository. If you decide to only install a subset of the components the tool can be used with profile options to only install or deploy some artifacts. This can be done by specifying the platform API versions as a profile name.

mvn install -P 3.2
Further details are available in the Maven Android SDK Deployer documentation.

Prev : 14.1. Introduction
TOC
Next : 14.3. Getting Started
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








222---->
Prev : Chapter 14. Android Application Development with Maven
TOC
Next : 14.2. Configuring Build Environment for Android Development
14.1. Introduction

Android is an open source mobile phone and embedded device operating system developed by the Open Handset Alliance. It is based on a Linux kernel with a virtual machine environment for managed application code using Java bytecode for the runtime code generation. The development environment is based on the Java language and JVM/JDK based tooling. The generated Java bytecode is transformed into Dalvik executable code optimized for constrained devices. Once deployed to the device and executed the code will run on the Dalvik virtual machine. Java is the default programming language and the API?s are all Java based.

In most cases, development of Android applications is done within the Eclipse based Android Development Toolkit ADT. The optionally generated Apache Ant based build can be used to build applications outside the IDE. The Android Maven Plugin was created to allow development teams to build, deploy and release Android applications with Apache Maven, taking advantage of all the powerful features available like dependency management, reporting, code analysis and much more.

Tip

The Android Maven Plugin is rapidly evolving. The documentation below applies to version 3.0.0-alpha-12 and higher. For up to date information refer to the plugin website.

Prev : Chapter 14. Android Application Development with Maven
TOC
Next : 14.2. Configuring Build Environment for Android Development
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








223---->
Prev : 13.7. Developing and Customizing Flexmojos
TOC
Next : 14.1. Introduction
Chapter 14. Android Application Development with Maven

14.1. Introduction
14.2. Configuring Build Environment for Android Development
14.2.1. Installing the Android SDK
14.2.2. Android artifact install into Maven repository
14.3. Getting Started
14.4. Creating New Projects with the Android Maven Archetypes
14.5. Using Add-Ons
14.6. Multi Module Android Projects
14.7. Using external dependencies
14.8. The Custom Lifecycle from the Android Maven Plugin
14.9. Plugin Configuration Parameters
14.10. Device Interaction
14.11. Emulator Interaction
14.12. Other Useful Android Maven Plugin Goals
14.12.1. Manifest-update
14.12.2. Zipalign
14.12.3. Help
14.13. Internal Android Maven Plugin Goals
14.14. Testing Android Application Code
14.14.1. Unit tests
14.14.2. Instrumentation tests
14.15. Native Application Builds
14.16. Tips and Tricks
14.16.1. Other Maven Plugins
14.16.2. Performing a Release Build
14.16.3. Configuring command line usage
Prev : 13.7. Developing and Customizing Flexmojos
TOC
Next : 14.1. Introduction
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








224---->
Prev : 13.6. FlexMojos Plugin Reports
TOC
Next : Chapter 14. Android Application Development with Maven
13.7. Developing and Customizing Flexmojos

The following sections guide you through some of first steps toward customizing or contributing to the Flexmojos project. Flexmojos is more than just a tool for people who are interested in compiling Actionscript into SWF and SWC artifacts, it is a community of developers. This section isn?t for everyone, but, if you have an itch to scratch and you wish to participate, come on in.

13.7.1. Get the Flexmojos Source Code

Flexmojos is an open source project hosted on the Forge, and the source code for Flexmojos is stored in the Forge Subversion repository. You can browse the contents of the Flexmojos Subversion repository by opening http://svn..org/flexmojos/trunk in a web browser.


Figure 13.11. Flexmojos Subversion Repository


If you are interested in participating in the Flexmojos project, you will likely want to checkout the current Flexmojos source code to your local machine. To checkout the Flexmojos source using Subversion, execute the following command at the command line:

$ svn co http://svn..org/flexmojos/trunk flexmojos
A flexmojos
...
$ ls
COPYRIGHT flexmojos-sandbox pom.xml
flexmojos-archetypesflexmojos-super-poms src
flexmojos-maven-plugin flexmojos-testing
flexmojos-parentflexmojos-touchstone
Prev : 13.6. FlexMojos Plugin Reports
TOC
Next : Chapter 14. Android Application Development with Maven
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








225---->
Prev : 13.6. FlexMojos Plugin Reports
TOC
Next : Chapter 14. Android Application Development with Maven
13.7. Developing and Customizing Flexmojos

The following sections guide you through some of first steps toward customizing or contributing to the Flexmojos project. Flexmojos is more than just a tool for people who are interested in compiling Actionscript into SWF and SWC artifacts, it is a community of developers. This section isn?t for everyone, but, if you have an itch to scratch and you wish to participate, come on in.

13.7.1. Get the Flexmojos Source Code

Flexmojos is an open source project hosted on the Forge, and the source code for Flexmojos is stored in the Forge Subversion repository. You can browse the contents of the Flexmojos Subversion repository by opening http://svn..org/flexmojos/trunk in a web browser.


Figure 13.11. Flexmojos Subversion Repository


If you are interested in participating in the Flexmojos project, you will likely want to checkout the current Flexmojos source code to your local machine. To checkout the Flexmojos source using Subversion, execute the following command at the command line:

$ svn co http://svn..org/flexmojos/trunk flexmojos
A flexmojos
...
$ ls
COPYRIGHT flexmojos-sandbox pom.xml
flexmojos-archetypesflexmojos-super-poms src
flexmojos-maven-plugin flexmojos-testing
flexmojos-parentflexmojos-touchstone
Prev : 13.6. FlexMojos Plugin Reports
TOC
Next : Chapter 14. Android Application Development with Maven
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








226---->
Prev : 13.5. FlexMojos Plugin Goals
TOC
Next : 13.7. Developing and Customizing Flexmojos
13.6. FlexMojos Plugin Reports

The FlexMojos Maven Plugin contains the following report:

flexmojos:asdoc-report
Generates documentation for Actionscript sources as a report that can be included in a Maven site
13.6.1. Generating Actionscript Documentation Report

To generate the asdoc-report as part of your Maven site build, add the following XML to your POM:

Configuring the Actionscript Documentation Report.




org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}


flex-reports

asdoc-report






When you run mvn site, Maven will generate this report and place the results under the "Project Reports" menu as shown in Figure 13.10, ?Actionscript Documentation Report on Maven Site?.


Figure 13.10. Actionscript Documentation Report on Maven Site


If you need to pass in any configuration options to the asdoc-report, you will need add a configuration element to the reportSets element as shown in Configuring the asdoc-report.

Configuring the asdoc-report.




org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}


flex-reports

asdoc-report


My TEST API Doc

Copyright 2010







Prev : 13.5. FlexMojos Plugin Goals
TOC
Next : 13.7. Developing and Customizing Flexmojos
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








227---->
Prev : 13.5. FlexMojos Plugin Goals
TOC
Next : 13.7. Developing and Customizing Flexmojos
13.6. FlexMojos Plugin Reports

The FlexMojos Maven Plugin contains the following report:

flexmojos:asdoc-report
Generates documentation for Actionscript sources as a report that can be included in a Maven site
13.6.1. Generating Actionscript Documentation Report

To generate the asdoc-report as part of your Maven site build, add the following XML to your POM:

Configuring the Actionscript Documentation Report.




org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}


flex-reports

asdoc-report






When you run mvn site, Maven will generate this report and place the results under the "Project Reports" menu as shown in Figure 13.10, ?Actionscript Documentation Report on Maven Site?.


Figure 13.10. Actionscript Documentation Report on Maven Site


If you need to pass in any configuration options to the asdoc-report, you will need add a configuration element to the reportSets element as shown in Configuring the asdoc-report.

Configuring the asdoc-report.




org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}


flex-reports

asdoc-report


My TEST API Doc

Copyright 2010







Prev : 13.5. FlexMojos Plugin Goals
TOC
Next : 13.7. Developing and Customizing Flexmojos
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








228---->
Prev : 13.4. The FlexMojos Lifecycle
TOC
Next : 13.6. FlexMojos Plugin Reports
13.5. FlexMojos Plugin Goals

The FlexMojos Maven Plugin contains the following goals:

flexmojos:asdoc
Generates documentation for Actionscript source files
flexmojos:asdoc-report
Generates documentation for Actionscript sources as a report that can be included in a Maven site
flexmojos:compile-swc
Compiles Flex source (Actionscript and MXML) into a SWC library for use in a Flex or AIR application
flexmojos:compile-swf
Compiles Flex source (Actionscript and MXML) into a SWF for use in the Adobe Flash Player or Adobe AIR Runtime
flexmojos:copy-flex-resources
Copies Flex resources into a web application project
flexmojos:flexbuilder
Generates project files for use in Adobe Flex Builder
flexmojos:generate
Generates Actionscript 3 based on Java classes using Granite GAS3
flexmojos:optimize
Goal which run post-link SWF optimization on swc files. This goal is used to produce RSL files.
flexmojos:sources
Create a JAR which contains all the sources for a Flex project
flexmojos:test-compile
Compile all test classes in a Flex project
flexmojos:test-run
Run the tests using the Adobe Flash Player
flexmojos:test-swc
Build a SWC containing the test classes for a specific project
flexmojos:wrapper
Generate an HTML wrapper for a SWF application
13.5.1. Generating Actionscript Documentation

You can run the asdoc or asdoc-report goals to generate documentation for Actionscript. Once the goals has completed, the documentation will be saved to ${basedir}/target/asdoc as HTML. Figure 13.9, ?Actionscript Documentation Generated by the FlexMojos Plugin? shows the result of running the asdoc goal against the Flexmojos application archetype project.


Figure 13.9. Actionscript Documentation Generated by the FlexMojos Plugin


13.5.2. Compiling Flex Source

FlexMojos contains a number of goals which compile Actionscript and MXML into SWCs and SWFs. The compile-swc and compile-swf goals are used to generate output from a project?s source, and test-compile is used to compile unit tests. In the simple projects created by the FlexMojos archetypes, the compile-swc and compile-swf goals are called because the project customizes the lifecycle and binds either compile-swc or compile-swf to the compile phase and test-compile to the test-compile phase. If you need to configure the options for the FlexMojos compiler, you would configure the FlexMojos plugin configuration. For example, if you wanted the application with the POM shown in POM for Flex Application Archetype to ignore certain code-level warnings on compile and use some customized font settings, you might use the plugin configuration shown in Customizing the Compiler Plugin.

Customizing the Compiler Plugin.


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}
true

true

true
false


true
true

U+0020-U+007E


${basedir}/src/main/resources/fonts.ser


flash.fonts.BatikFontManager

20
1000





13.5.3. Generating Flex Builder Project Files

To generate Flex Builder project files for a FlexMojos project, configure the plugin groups as described in Section 13.2.4, ?Adding FlexMojos to Your Maven Settings' Plugin Groups?, and run the flexbuilder goal:

$ mvn flexmojos:flexbuilder
Running this goal will create a .project, .settings/org.eclipse.core.resources.prefs, .actionScriptProperties, and .flexLibProperties.

Prev : 13.4. The FlexMojos Lifecycle
TOC
Next : 13.6. FlexMojos Plugin Reports
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








229---->
Prev : 13.4. The FlexMojos Lifecycle
TOC
Next : 13.6. FlexMojos Plugin Reports
13.5. FlexMojos Plugin Goals

The FlexMojos Maven Plugin contains the following goals:

flexmojos:asdoc
Generates documentation for Actionscript source files
flexmojos:asdoc-report
Generates documentation for Actionscript sources as a report that can be included in a Maven site
flexmojos:compile-swc
Compiles Flex source (Actionscript and MXML) into a SWC library for use in a Flex or AIR application
flexmojos:compile-swf
Compiles Flex source (Actionscript and MXML) into a SWF for use in the Adobe Flash Player or Adobe AIR Runtime
flexmojos:copy-flex-resources
Copies Flex resources into a web application project
flexmojos:flexbuilder
Generates project files for use in Adobe Flex Builder
flexmojos:generate
Generates Actionscript 3 based on Java classes using Granite GAS3
flexmojos:optimize
Goal which run post-link SWF optimization on swc files. This goal is used to produce RSL files.
flexmojos:sources
Create a JAR which contains all the sources for a Flex project
flexmojos:test-compile
Compile all test classes in a Flex project
flexmojos:test-run
Run the tests using the Adobe Flash Player
flexmojos:test-swc
Build a SWC containing the test classes for a specific project
flexmojos:wrapper
Generate an HTML wrapper for a SWF application
13.5.1. Generating Actionscript Documentation

You can run the asdoc or asdoc-report goals to generate documentation for Actionscript. Once the goals has completed, the documentation will be saved to ${basedir}/target/asdoc as HTML. Figure 13.9, ?Actionscript Documentation Generated by the FlexMojos Plugin? shows the result of running the asdoc goal against the Flexmojos application archetype project.


Figure 13.9. Actionscript Documentation Generated by the FlexMojos Plugin


13.5.2. Compiling Flex Source

FlexMojos contains a number of goals which compile Actionscript and MXML into SWCs and SWFs. The compile-swc and compile-swf goals are used to generate output from a project?s source, and test-compile is used to compile unit tests. In the simple projects created by the FlexMojos archetypes, the compile-swc and compile-swf goals are called because the project customizes the lifecycle and binds either compile-swc or compile-swf to the compile phase and test-compile to the test-compile phase. If you need to configure the options for the FlexMojos compiler, you would configure the FlexMojos plugin configuration. For example, if you wanted the application with the POM shown in POM for Flex Application Archetype to ignore certain code-level warnings on compile and use some customized font settings, you might use the plugin configuration shown in Customizing the Compiler Plugin.

Customizing the Compiler Plugin.


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}
true

true

true
false


true
true

U+0020-U+007E


${basedir}/src/main/resources/fonts.ser


flash.fonts.BatikFontManager

20
1000





13.5.3. Generating Flex Builder Project Files

To generate Flex Builder project files for a FlexMojos project, configure the plugin groups as described in Section 13.2.4, ?Adding FlexMojos to Your Maven Settings' Plugin Groups?, and run the flexbuilder goal:

$ mvn flexmojos:flexbuilder
Running this goal will create a .project, .settings/org.eclipse.core.resources.prefs, .actionScriptProperties, and .flexLibProperties.

Prev : 13.4. The FlexMojos Lifecycle
TOC
Next : 13.6. FlexMojos Plugin Reports
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








230---->
Prev : 13.4. The FlexMojos Lifecycle
TOC
Next : 13.6. FlexMojos Plugin Reports
13.5. FlexMojos Plugin Goals

The FlexMojos Maven Plugin contains the following goals:

flexmojos:asdoc
Generates documentation for Actionscript source files
flexmojos:asdoc-report
Generates documentation for Actionscript sources as a report that can be included in a Maven site
flexmojos:compile-swc
Compiles Flex source (Actionscript and MXML) into a SWC library for use in a Flex or AIR application
flexmojos:compile-swf
Compiles Flex source (Actionscript and MXML) into a SWF for use in the Adobe Flash Player or Adobe AIR Runtime
flexmojos:copy-flex-resources
Copies Flex resources into a web application project
flexmojos:flexbuilder
Generates project files for use in Adobe Flex Builder
flexmojos:generate
Generates Actionscript 3 based on Java classes using Granite GAS3
flexmojos:optimize
Goal which run post-link SWF optimization on swc files. This goal is used to produce RSL files.
flexmojos:sources
Create a JAR which contains all the sources for a Flex project
flexmojos:test-compile
Compile all test classes in a Flex project
flexmojos:test-run
Run the tests using the Adobe Flash Player
flexmojos:test-swc
Build a SWC containing the test classes for a specific project
flexmojos:wrapper
Generate an HTML wrapper for a SWF application
13.5.1. Generating Actionscript Documentation

You can run the asdoc or asdoc-report goals to generate documentation for Actionscript. Once the goals has completed, the documentation will be saved to ${basedir}/target/asdoc as HTML. Figure 13.9, ?Actionscript Documentation Generated by the FlexMojos Plugin? shows the result of running the asdoc goal against the Flexmojos application archetype project.


Figure 13.9. Actionscript Documentation Generated by the FlexMojos Plugin


13.5.2. Compiling Flex Source

FlexMojos contains a number of goals which compile Actionscript and MXML into SWCs and SWFs. The compile-swc and compile-swf goals are used to generate output from a project?s source, and test-compile is used to compile unit tests. In the simple projects created by the FlexMojos archetypes, the compile-swc and compile-swf goals are called because the project customizes the lifecycle and binds either compile-swc or compile-swf to the compile phase and test-compile to the test-compile phase. If you need to configure the options for the FlexMojos compiler, you would configure the FlexMojos plugin configuration. For example, if you wanted the application with the POM shown in POM for Flex Application Archetype to ignore certain code-level warnings on compile and use some customized font settings, you might use the plugin configuration shown in Customizing the Compiler Plugin.

Customizing the Compiler Plugin.


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}
true

true

true
false


true
true

U+0020-U+007E


${basedir}/src/main/resources/fonts.ser


flash.fonts.BatikFontManager

20
1000





13.5.3. Generating Flex Builder Project Files

To generate Flex Builder project files for a FlexMojos project, configure the plugin groups as described in Section 13.2.4, ?Adding FlexMojos to Your Maven Settings' Plugin Groups?, and run the flexbuilder goal:

$ mvn flexmojos:flexbuilder
Running this goal will create a .project, .settings/org.eclipse.core.resources.prefs, .actionScriptProperties, and .flexLibProperties.

Prev : 13.4. The FlexMojos Lifecycle
TOC
Next : 13.6. FlexMojos Plugin Reports
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








231---->
Prev : 13.4. The FlexMojos Lifecycle
TOC
Next : 13.6. FlexMojos Plugin Reports
13.5. FlexMojos Plugin Goals

The FlexMojos Maven Plugin contains the following goals:

flexmojos:asdoc
Generates documentation for Actionscript source files
flexmojos:asdoc-report
Generates documentation for Actionscript sources as a report that can be included in a Maven site
flexmojos:compile-swc
Compiles Flex source (Actionscript and MXML) into a SWC library for use in a Flex or AIR application
flexmojos:compile-swf
Compiles Flex source (Actionscript and MXML) into a SWF for use in the Adobe Flash Player or Adobe AIR Runtime
flexmojos:copy-flex-resources
Copies Flex resources into a web application project
flexmojos:flexbuilder
Generates project files for use in Adobe Flex Builder
flexmojos:generate
Generates Actionscript 3 based on Java classes using Granite GAS3
flexmojos:optimize
Goal which run post-link SWF optimization on swc files. This goal is used to produce RSL files.
flexmojos:sources
Create a JAR which contains all the sources for a Flex project
flexmojos:test-compile
Compile all test classes in a Flex project
flexmojos:test-run
Run the tests using the Adobe Flash Player
flexmojos:test-swc
Build a SWC containing the test classes for a specific project
flexmojos:wrapper
Generate an HTML wrapper for a SWF application
13.5.1. Generating Actionscript Documentation

You can run the asdoc or asdoc-report goals to generate documentation for Actionscript. Once the goals has completed, the documentation will be saved to ${basedir}/target/asdoc as HTML. Figure 13.9, ?Actionscript Documentation Generated by the FlexMojos Plugin? shows the result of running the asdoc goal against the Flexmojos application archetype project.


Figure 13.9. Actionscript Documentation Generated by the FlexMojos Plugin


13.5.2. Compiling Flex Source

FlexMojos contains a number of goals which compile Actionscript and MXML into SWCs and SWFs. The compile-swc and compile-swf goals are used to generate output from a project?s source, and test-compile is used to compile unit tests. In the simple projects created by the FlexMojos archetypes, the compile-swc and compile-swf goals are called because the project customizes the lifecycle and binds either compile-swc or compile-swf to the compile phase and test-compile to the test-compile phase. If you need to configure the options for the FlexMojos compiler, you would configure the FlexMojos plugin configuration. For example, if you wanted the application with the POM shown in POM for Flex Application Archetype to ignore certain code-level warnings on compile and use some customized font settings, you might use the plugin configuration shown in Customizing the Compiler Plugin.

Customizing the Compiler Plugin.


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}
true

true

true
false


true
true

U+0020-U+007E


${basedir}/src/main/resources/fonts.ser


flash.fonts.BatikFontManager

20
1000





13.5.3. Generating Flex Builder Project Files

To generate Flex Builder project files for a FlexMojos project, configure the plugin groups as described in Section 13.2.4, ?Adding FlexMojos to Your Maven Settings' Plugin Groups?, and run the flexbuilder goal:

$ mvn flexmojos:flexbuilder
Running this goal will create a .project, .settings/org.eclipse.core.resources.prefs, .actionScriptProperties, and .flexLibProperties.

Prev : 13.4. The FlexMojos Lifecycle
TOC
Next : 13.6. FlexMojos Plugin Reports
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








232---->
Prev : 13.3. Creating a Flex Mojos Project from an Archetype
TOC
Next : 13.5. FlexMojos Plugin Goals
13.4. The FlexMojos Lifecycle

The FlexMojos Maven plugin customizes the lifecycle based on the packaging. If your project has a packaging of type swc or swf, the FlexMojos plugin with execute a customized lifecycle if your plugin configuration sets the extensions to true. Setting Plugin Extensions to True for Custom Flex Lifecycle shows the plugin configuration for the flexmojos-maven-plugin with the extensions set to true.

Setting Plugin Extensions to True for Custom Flex Lifecycle.


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}
*true*


en_US





13.4.1. The SWC Lifecycle

When the packaging is swc, FlexMojos will execute the lifecycle shown in Figure 13.7, ?The FlexMojos SWC Lifecycle?. The highlighted goals are goals from the FlexMojos plugin, the goals which are not highlights are standard goals from the Core Maven plugins.


Figure 13.7. The FlexMojos SWC Lifecycle


The FlexMojos contributed goals are:

flexmojos:compile-swc
This goal compiles all of the Actionscript and MXML files in the sourceDirectory into a SWC. A SWC is an Adobe library or class file which contains components and resources used in Flex applications.
flexmojos:test-compile
This goal compiles all of the Actionscript and MXML files in the testSourceDirectory.
flexmojos:test-run
This goal executes unit tests using the Flash Player. This goal can only run if the Flash Player has been configured as described in Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.
13.4.2. The SWF Lifecycle

When the packaging is swf, FlexMojos will execute the lifecycle shown in Figure 13.8, ?The FlexMojos SWF Lifecycle?. The highlighted goals are goals from the FlexMojos plugin, the goals which are not highlights are standard goals from the Core Maven plugins.


Figure 13.8. The FlexMojos SWF Lifecycle


The FlexMojos contributed goals are:

flexmojos:compile-swf
This goal compiles all of the Actionscript and MXML files in the sourceDirectory into a SWF. A SWF is a file which contains an application that can be render by the Adobe Flash Player or Adobe AIR software.
flexmojos:test-compile
This goal compiles all of the Actionscript and MXML files in the testSourceDirectory.
flexmojos:test-run
This goal executes unit tests using the Flash Player. This goal can only run if the Flash Player has been configured as described in Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.
Prev : 13.3. Creating a Flex Mojos Project from an Archetype
TOC
Next : 13.5. FlexMojos Plugin Goals
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








233---->
Prev : 13.3. Creating a Flex Mojos Project from an Archetype
TOC
Next : 13.5. FlexMojos Plugin Goals
13.4. The FlexMojos Lifecycle

The FlexMojos Maven plugin customizes the lifecycle based on the packaging. If your project has a packaging of type swc or swf, the FlexMojos plugin with execute a customized lifecycle if your plugin configuration sets the extensions to true. Setting Plugin Extensions to True for Custom Flex Lifecycle shows the plugin configuration for the flexmojos-maven-plugin with the extensions set to true.

Setting Plugin Extensions to True for Custom Flex Lifecycle.


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}
*true*


en_US





13.4.1. The SWC Lifecycle

When the packaging is swc, FlexMojos will execute the lifecycle shown in Figure 13.7, ?The FlexMojos SWC Lifecycle?. The highlighted goals are goals from the FlexMojos plugin, the goals which are not highlights are standard goals from the Core Maven plugins.


Figure 13.7. The FlexMojos SWC Lifecycle


The FlexMojos contributed goals are:

flexmojos:compile-swc
This goal compiles all of the Actionscript and MXML files in the sourceDirectory into a SWC. A SWC is an Adobe library or class file which contains components and resources used in Flex applications.
flexmojos:test-compile
This goal compiles all of the Actionscript and MXML files in the testSourceDirectory.
flexmojos:test-run
This goal executes unit tests using the Flash Player. This goal can only run if the Flash Player has been configured as described in Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.
13.4.2. The SWF Lifecycle

When the packaging is swf, FlexMojos will execute the lifecycle shown in Figure 13.8, ?The FlexMojos SWF Lifecycle?. The highlighted goals are goals from the FlexMojos plugin, the goals which are not highlights are standard goals from the Core Maven plugins.


Figure 13.8. The FlexMojos SWF Lifecycle


The FlexMojos contributed goals are:

flexmojos:compile-swf
This goal compiles all of the Actionscript and MXML files in the sourceDirectory into a SWF. A SWF is a file which contains an application that can be render by the Adobe Flash Player or Adobe AIR software.
flexmojos:test-compile
This goal compiles all of the Actionscript and MXML files in the testSourceDirectory.
flexmojos:test-run
This goal executes unit tests using the Flash Player. This goal can only run if the Flash Player has been configured as described in Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.
Prev : 13.3. Creating a Flex Mojos Project from an Archetype
TOC
Next : 13.5. FlexMojos Plugin Goals
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








234---->
Prev : 13.3. Creating a Flex Mojos Project from an Archetype
TOC
Next : 13.5. FlexMojos Plugin Goals
13.4. The FlexMojos Lifecycle

The FlexMojos Maven plugin customizes the lifecycle based on the packaging. If your project has a packaging of type swc or swf, the FlexMojos plugin with execute a customized lifecycle if your plugin configuration sets the extensions to true. Setting Plugin Extensions to True for Custom Flex Lifecycle shows the plugin configuration for the flexmojos-maven-plugin with the extensions set to true.

Setting Plugin Extensions to True for Custom Flex Lifecycle.


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
${flexmojos.version}
*true*


en_US





13.4.1. The SWC Lifecycle

When the packaging is swc, FlexMojos will execute the lifecycle shown in Figure 13.7, ?The FlexMojos SWC Lifecycle?. The highlighted goals are goals from the FlexMojos plugin, the goals which are not highlights are standard goals from the Core Maven plugins.


Figure 13.7. The FlexMojos SWC Lifecycle


The FlexMojos contributed goals are:

flexmojos:compile-swc
This goal compiles all of the Actionscript and MXML files in the sourceDirectory into a SWC. A SWC is an Adobe library or class file which contains components and resources used in Flex applications.
flexmojos:test-compile
This goal compiles all of the Actionscript and MXML files in the testSourceDirectory.
flexmojos:test-run
This goal executes unit tests using the Flash Player. This goal can only run if the Flash Player has been configured as described in Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.
13.4.2. The SWF Lifecycle

When the packaging is swf, FlexMojos will execute the lifecycle shown in Figure 13.8, ?The FlexMojos SWF Lifecycle?. The highlighted goals are goals from the FlexMojos plugin, the goals which are not highlights are standard goals from the Core Maven plugins.


Figure 13.8. The FlexMojos SWF Lifecycle


The FlexMojos contributed goals are:

flexmojos:compile-swf
This goal compiles all of the Actionscript and MXML files in the sourceDirectory into a SWF. A SWF is a file which contains an application that can be render by the Adobe Flash Player or Adobe AIR software.
flexmojos:test-compile
This goal compiles all of the Actionscript and MXML files in the testSourceDirectory.
flexmojos:test-run
This goal executes unit tests using the Flash Player. This goal can only run if the Flash Player has been configured as described in Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.
Prev : 13.3. Creating a Flex Mojos Project from an Archetype
TOC
Next : 13.5. FlexMojos Plugin Goals
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








235---->
Prev : 13.2. Configuring Build Environment for Flexmojos
TOC
Next : 13.4. The FlexMojos Lifecycle
13.3. Creating a Flex Mojos Project from an Archetype

Flexmojos has a set of archetypes which can be used to quickly create a new Flex project. The following archetypes are all in the org..flexmojos group with a version of ${flexmojos.version}:

flexmojos-archetypes-library
Creates a simple Flex Library project which produces a SWC
flexmojos-archetypes-application
Creates a simple Flex Application with produces a SWF
flexmojos-archetypes-modular-webapp
Creates a Multimodule project which consists of a project that produces a SWC which is consumed by a project which produces a SWF that is ultimately presented in a project that generates a WAR
13.3.1. Creating a Flex Library

To create a Flex Library Project, execute the following command at the command-line:

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-library \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-library+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-library
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
If you look in the directory sample-library/ you will see that the project consists of the directory structure shown in Figure 13.4, ?Flexmojo Library Archetype File Structure?.


Figure 13.4. Flexmojo Library Archetype File Structure


The product of the simple Flex library archetype only contains three files: a POM, one source, and a unit test. Let?s examine each of these files. First, the Project Object Model (POM).

Project Object Model for Flex Library Archetype.

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">
4.0.0

org..test
sample-library
1.0-SNAPSHOT
swc

sample-library Flex


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true






com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id='org.maven.ide.eclipse.configuration.flex.configurator' />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4







Project Object Model for Flex Library Archetype is very simple, the key to this POM is the flexmojos-maven-plugin configuration which sets extensions to true. This configuration customizes the lifecycle for the swc packaging which is defined in the flexmojos-maven-plugin. The archetype then includes the flex-framework dependency and the flexmojos-unittest-support test-scoped dependency. The flex-framework dependency is a POM which contains references to the SWC libraries and resources required to compile Flex applications.

In Project Object Model for Flex Library Archetype, the packaging is very critical. A POMs packaging type controls the lifecycle it uses to produce build output. The value swc in the packaging element is Maven?s cue to look for the Flex-specific lifecycle customizations which are provided by the flexmojos-maven-plugin. The other important part of this POM is the build element which specifies the location of the Flex source code and the Flex unit tests. Next, let?s take a quick look at Flex Library Archetype?s Sample App Class which contains the sample Actionscript which was created by this archetype.

Flex Library Archetype?s Sample App Class.

package org..test {
public class App {
public static function greeting(name:String):String {
return "Hello, " + name;
}
}
}
While this code is underwhelming, it does provide you with a quick model and a quick pointer: "Place More Code Here". While it might seem silly to test code this simple, a sample test named TestApp.as is provides in the src/test/flex directory. This test is shown in Unit Test for Library Archetype?s App Class.

Unit Test for Library Archetype?s App Class.

package org..test {

import flexunit.framework.TestCase;

public class TestApp extends TestCase {

/**
* Tests our greeting() method
*/
public function testGreeting():void {
var name:String = "Buck Rogers";
var expectedGreeting:String = "Hello, Buck Rogers";

var result:String = App.greeting(name);
assertEquals("Greeting is incorrect", expectedGreeting, result);
}
}
}
To run this build, go to the sample-library project directory and run mvn install.

$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building sample-library Flex
[INFO]task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] [flexmojos:compile-swc]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[WARNING] Nothing expecified to include. Assuming source and resources folders.
[INFO] Flex compiler configurations:
-compiler.headless-server=false
-compiler.keep-all-type-selectors=false
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex/\
3.2.0.3958...
-compiler.namespaces.namespace http://www.adobe.com/2006/mxml
target/classes/configs/mxml-manifest.xml
-compiler.optimize=true
-compiler.source-path src/main/flex
...
[INFO] [resources:testResources]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered \
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory src/test/resources
[INFO] [flexmojos:test-compile]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] Flex compiler configurations:
-compiler.include-libraries ~/.m2/repository/org//flexmojos/\
flexmojos-unittest-support...
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex
3.2.0.3958/flex-3.2.0....
-compiler.optimize=true
-compiler.source-path src/main/flex target/test-classes src/test/flex
-compiler.strict=true
-target-player 9.0.0
-use-network=true
-verify-digests=true -load-config=
[INFO] Already trust on target/test-classes/TestRunner.swf
[INFO] [flexmojos:test-run]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] flexunit setup args: null
[INFO] ------------------------------------------------------------------------
[INFO] Tests run: 1, Failures: 0, Errors: 0, Time Elpased: 0 sec
[INFO] [install:install]
Note

To execute Flex unit tests you will need to configure your PATH environment variable to include the Flash Player. For more information about configuring FlexMojos for unit tests, see Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.

When you ran mvn install on this project, you should notice in the output that Maven and Flexmojos plugin is take care of managing all of the libraries and the dependencies for the Flex compiler. Much like Maven excels at helping Java developers manage the contents of a Java classpath, Maven can help Flex developers manage the complex of compile paths. You also might have been shocked when the Flexmojos project started a web browser or the Flash Player and used it to execute the TestApp.as class against the project?s source code.

13.3.2. Creating a Flex Application

To create a Flex application from a Maven archetype, execute the following command:

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-application \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-application+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+
[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim/flex-sample
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-application
[INFO] BUILD SUCCESSFUL
If you look in the directory sample-application/ you will see the filesystem shown in Figure 13.5, ?Directory Structure for Flex Application Archetype?.


Figure 13.5. Directory Structure for Flex Application Archetype


Building an application from the Application archetype produces the following POM.

POM for Flex Application Archetype.

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">
4.0.0

org..test
sample-application
1.0-SNAPSHOT
swf

sample-application Flex


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true






com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id='org.maven.ide.eclipse.configuration.flex.configurator' />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








The difference between POM for Flex Application Archetype and Project Object Model for Flex Library Archetype is that the packaging element is swf instead of swc. By setting the packaging to swf, the project will produce a Flex application in target/sample-application-1.0-SNAPSHOT.swf. The sample application created by this archetype displays the Text "Hello World". Main.mxml can be found in src/main/flex.

Sample Application Main.mxml.




This application also creates a simple FlexUnit test that does nothing more than print out a trace message. The sample unit test is in src/test/flex/org//test.

Unit Test for Main.mxml.

package org..test
{

import flexunit.framework.TestCase;
import Main;

public class TestApp extends TestCase
{

public function testNothing():void
{
//TODO un implemented
trace("Hello test");
}
}
}
13.3.3. Creating a Multi-module Project: Web Application with a Flex

To create a multi-module project consisting of a Flex Library project referenced by a Flex Application, referenced by a Web Application.

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-modular-webapp \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-multimodule+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+
[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-multimodule
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
If you look in the sample-multimodule/ directory, you will see a directory structure which contains three projects swc, swf, and war.


Figure 13.6. Directory Structure for Flex Multimodule Archetype


The simple top-level POM in this multimodule project is shown in . It consists of module references to the swc, swf, and war modules.

Top-level POM Created by Modular Web Application Archetype.

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">
4.0.0
org..test
sample-multimodule
1.0-SNAPSHOT
pom


swc
swf
war


The swc project has a simple POM that resembles the POM shown in Project Object Model for Flex Library Archetype. Note that the artifactId in this POM differs from the name of the module directory and is swc-swc.

swc Module POM.

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">
4.0.0


org..test
sample-multimodule
1.0-SNAPSHOT


org..test
swc
1.0-SNAPSHOT
swc

swc Library


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true


en_US








com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id="org.maven.ide.eclipse.configuration.flex.configurator" />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








The swf module?s POM resembles the POM in POM for Flex Application Archetype adding a dependency on the swc-swc artifact. Note that the following POM defines an artifactId that differs from the directory that stores the module; the artifactId in the following POM is swf-swf.

swf module POM.

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">
4.0.0


org..test
sample-multimodule
1.0-SNAPSHOT


org..test
swf
1.0-SNAPSHOT
swf

swf Application


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true


en_US








com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test



org..test
swc
1.0-SNAPSHOT
swc





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id="org.maven.ide.eclipse.configuration.flex.configurator" />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








When you declare a dependency on a SWC, you?ll need to specify the type of the dependency so that Maven can locate the appropriate artifact in the remote or local repository. In this case, the swf-swf project depends upon the SWC that is generated by the swc-swc project. When you add the dependency to the swf-swf project, the FlexMojos plugin will add the appropriate SWC file to the Flex Compiler?s library path.

Next, take a look at the simple POM in the war module.

war module POM.

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">
4.0.0

sample-multimodule
org..test
1.0-SNAPSHOT


org..test
war
1.0-SNAPSHOT

war



org..flexmojos
flexmojos-maven-plugin
3.5.0



copy-flex-resources





org.mortbay.jetty
maven-jetty-plugin
6.1.17






org..test
swf
1.0-SNAPSHOT
swf




The POM shown in war module POM configures the FlexMojos plugin to execute the copy-flex-resources goal for this project. The copy-flex-resources goal will copy SWF application into the web application?s document root. In this project, running a build and creating a WAR will copy the swf-swf-1.0-SNAPSHOT.swf file to the web application?s root directory in target/war-war-1.0-SNAPSHOT.

To build the multimodule web application project, run mvn install from the top-level directory. This should build the swc-swc, swf-swf, and war-war artifacts and product a WAR file in war'/target/war-war-1.0-SNAPSHOT.war' which contains the swf-swf-1.0-SNAPSHOT.swf in the document root of the web application.

Note

To execute Flex unit tests you will need to configure your PATH environment variable to include the Flash Player. For more information about configuring FlexMojos for unit tests, see Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.

Prev : 13.2. Configuring Build Environment for Flexmojos
TOC
Next : 13.4. The FlexMojos Lifecycle
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








236---->
Prev : 13.2. Configuring Build Environment for Flexmojos
TOC
Next : 13.4. The FlexMojos Lifecycle
13.3. Creating a Flex Mojos Project from an Archetype

Flexmojos has a set of archetypes which can be used to quickly create a new Flex project. The following archetypes are all in the org..flexmojos group with a version of ${flexmojos.version}:

flexmojos-archetypes-library
Creates a simple Flex Library project which produces a SWC
flexmojos-archetypes-application
Creates a simple Flex Application with produces a SWF
flexmojos-archetypes-modular-webapp
Creates a Multimodule project which consists of a project that produces a SWC which is consumed by a project which produces a SWF that is ultimately presented in a project that generates a WAR
13.3.1. Creating a Flex Library

To create a Flex Library Project, execute the following command at the command-line:

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-library \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-library+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-library
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
If you look in the directory sample-library/ you will see that the project consists of the directory structure shown in Figure 13.4, ?Flexmojo Library Archetype File Structure?.


Figure 13.4. Flexmojo Library Archetype File Structure


The product of the simple Flex library archetype only contains three files: a POM, one source, and a unit test. Let?s examine each of these files. First, the Project Object Model (POM).

Project Object Model for Flex Library Archetype.

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">
4.0.0

org..test
sample-library
1.0-SNAPSHOT
swc

sample-library Flex


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true






com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id='org.maven.ide.eclipse.configuration.flex.configurator' />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4







Project Object Model for Flex Library Archetype is very simple, the key to this POM is the flexmojos-maven-plugin configuration which sets extensions to true. This configuration customizes the lifecycle for the swc packaging which is defined in the flexmojos-maven-plugin. The archetype then includes the flex-framework dependency and the flexmojos-unittest-support test-scoped dependency. The flex-framework dependency is a POM which contains references to the SWC libraries and resources required to compile Flex applications.

In Project Object Model for Flex Library Archetype, the packaging is very critical. A POMs packaging type controls the lifecycle it uses to produce build output. The value swc in the packaging element is Maven?s cue to look for the Flex-specific lifecycle customizations which are provided by the flexmojos-maven-plugin. The other important part of this POM is the build element which specifies the location of the Flex source code and the Flex unit tests. Next, let?s take a quick look at Flex Library Archetype?s Sample App Class which contains the sample Actionscript which was created by this archetype.

Flex Library Archetype?s Sample App Class.

package org..test {
public class App {
public static function greeting(name:String):String {
return "Hello, " + name;
}
}
}
While this code is underwhelming, it does provide you with a quick model and a quick pointer: "Place More Code Here". While it might seem silly to test code this simple, a sample test named TestApp.as is provides in the src/test/flex directory. This test is shown in Unit Test for Library Archetype?s App Class.

Unit Test for Library Archetype?s App Class.

package org..test {

import flexunit.framework.TestCase;

public class TestApp extends TestCase {

/**
* Tests our greeting() method
*/
public function testGreeting():void {
var name:String = "Buck Rogers";
var expectedGreeting:String = "Hello, Buck Rogers";

var result:String = App.greeting(name);
assertEquals("Greeting is incorrect", expectedGreeting, result);
}
}
}
To run this build, go to the sample-library project directory and run mvn install.

$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building sample-library Flex
[INFO]task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] [flexmojos:compile-swc]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[WARNING] Nothing expecified to include. Assuming source and resources folders.
[INFO] Flex compiler configurations:
-compiler.headless-server=false
-compiler.keep-all-type-selectors=false
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex/\
3.2.0.3958...
-compiler.namespaces.namespace http://www.adobe.com/2006/mxml
target/classes/configs/mxml-manifest.xml
-compiler.optimize=true
-compiler.source-path src/main/flex
...
[INFO] [resources:testResources]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered \
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory src/test/resources
[INFO] [flexmojos:test-compile]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] Flex compiler configurations:
-compiler.include-libraries ~/.m2/repository/org//flexmojos/\
flexmojos-unittest-support...
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex
3.2.0.3958/flex-3.2.0....
-compiler.optimize=true
-compiler.source-path src/main/flex target/test-classes src/test/flex
-compiler.strict=true
-target-player 9.0.0
-use-network=true
-verify-digests=true -load-config=
[INFO] Already trust on target/test-classes/TestRunner.swf
[INFO] [flexmojos:test-run]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] flexunit setup args: null
[INFO] ------------------------------------------------------------------------
[INFO] Tests run: 1, Failures: 0, Errors: 0, Time Elpased: 0 sec
[INFO] [install:install]
Note

To execute Flex unit tests you will need to configure your PATH environment variable to include the Flash Player. For more information about configuring FlexMojos for unit tests, see Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.

When you ran mvn install on this project, you should notice in the output that Maven and Flexmojos plugin is take care of managing all of the libraries and the dependencies for the Flex compiler. Much like Maven excels at helping Java developers manage the contents of a Java classpath, Maven can help Flex developers manage the complex of compile paths. You also might have been shocked when the Flexmojos project started a web browser or the Flash Player and used it to execute the TestApp.as class against the project?s source code.

13.3.2. Creating a Flex Application

To create a Flex application from a Maven archetype, execute the following command:

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-application \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-application+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+
[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim/flex-sample
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-application
[INFO] BUILD SUCCESSFUL
If you look in the directory sample-application/ you will see the filesystem shown in Figure 13.5, ?Directory Structure for Flex Application Archetype?.


Figure 13.5. Directory Structure for Flex Application Archetype


Building an application from the Application archetype produces the following POM.

POM for Flex Application Archetype.

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">
4.0.0

org..test
sample-application
1.0-SNAPSHOT
swf

sample-application Flex


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true






com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id='org.maven.ide.eclipse.configuration.flex.configurator' />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








The difference between POM for Flex Application Archetype and Project Object Model for Flex Library Archetype is that the packaging element is swf instead of swc. By setting the packaging to swf, the project will produce a Flex application in target/sample-application-1.0-SNAPSHOT.swf. The sample application created by this archetype displays the Text "Hello World". Main.mxml can be found in src/main/flex.

Sample Application Main.mxml.




This application also creates a simple FlexUnit test that does nothing more than print out a trace message. The sample unit test is in src/test/flex/org//test.

Unit Test for Main.mxml.

package org..test
{

import flexunit.framework.TestCase;
import Main;

public class TestApp extends TestCase
{

public function testNothing():void
{
//TODO un implemented
trace("Hello test");
}
}
}
13.3.3. Creating a Multi-module Project: Web Application with a Flex

To create a multi-module project consisting of a Flex Library project referenced by a Flex Application, referenced by a Web Application.

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-modular-webapp \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-multimodule+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+
[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-multimodule
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
If you look in the sample-multimodule/ directory, you will see a directory structure which contains three projects swc, swf, and war.


Figure 13.6. Directory Structure for Flex Multimodule Archetype


The simple top-level POM in this multimodule project is shown in . It consists of module references to the swc, swf, and war modules.

Top-level POM Created by Modular Web Application Archetype.

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">
4.0.0
org..test
sample-multimodule
1.0-SNAPSHOT
pom


swc
swf
war


The swc project has a simple POM that resembles the POM shown in Project Object Model for Flex Library Archetype. Note that the artifactId in this POM differs from the name of the module directory and is swc-swc.

swc Module POM.

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">
4.0.0


org..test
sample-multimodule
1.0-SNAPSHOT


org..test
swc
1.0-SNAPSHOT
swc

swc Library


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true


en_US








com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id="org.maven.ide.eclipse.configuration.flex.configurator" />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








The swf module?s POM resembles the POM in POM for Flex Application Archetype adding a dependency on the swc-swc artifact. Note that the following POM defines an artifactId that differs from the directory that stores the module; the artifactId in the following POM is swf-swf.

swf module POM.

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">
4.0.0


org..test
sample-multimodule
1.0-SNAPSHOT


org..test
swf
1.0-SNAPSHOT
swf

swf Application


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true


en_US








com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test



org..test
swc
1.0-SNAPSHOT
swc





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id="org.maven.ide.eclipse.configuration.flex.configurator" />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








When you declare a dependency on a SWC, you?ll need to specify the type of the dependency so that Maven can locate the appropriate artifact in the remote or local repository. In this case, the swf-swf project depends upon the SWC that is generated by the swc-swc project. When you add the dependency to the swf-swf project, the FlexMojos plugin will add the appropriate SWC file to the Flex Compiler?s library path.

Next, take a look at the simple POM in the war module.

war module POM.

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">
4.0.0

sample-multimodule
org..test
1.0-SNAPSHOT


org..test
war
1.0-SNAPSHOT

war



org..flexmojos
flexmojos-maven-plugin
3.5.0



copy-flex-resources





org.mortbay.jetty
maven-jetty-plugin
6.1.17






org..test
swf
1.0-SNAPSHOT
swf




The POM shown in war module POM configures the FlexMojos plugin to execute the copy-flex-resources goal for this project. The copy-flex-resources goal will copy SWF application into the web application?s document root. In this project, running a build and creating a WAR will copy the swf-swf-1.0-SNAPSHOT.swf file to the web application?s root directory in target/war-war-1.0-SNAPSHOT.

To build the multimodule web application project, run mvn install from the top-level directory. This should build the swc-swc, swf-swf, and war-war artifacts and product a WAR file in war'/target/war-war-1.0-SNAPSHOT.war' which contains the swf-swf-1.0-SNAPSHOT.swf in the document root of the web application.

Note

To execute Flex unit tests you will need to configure your PATH environment variable to include the Flash Player. For more information about configuring FlexMojos for unit tests, see Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.

Prev : 13.2. Configuring Build Environment for Flexmojos
TOC
Next : 13.4. The FlexMojos Lifecycle
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








237---->
Prev : 13.2. Configuring Build Environment for Flexmojos
TOC
Next : 13.4. The FlexMojos Lifecycle
13.3. Creating a Flex Mojos Project from an Archetype

Flexmojos has a set of archetypes which can be used to quickly create a new Flex project. The following archetypes are all in the org..flexmojos group with a version of ${flexmojos.version}:

flexmojos-archetypes-library
Creates a simple Flex Library project which produces a SWC
flexmojos-archetypes-application
Creates a simple Flex Application with produces a SWF
flexmojos-archetypes-modular-webapp
Creates a Multimodule project which consists of a project that produces a SWC which is consumed by a project which produces a SWF that is ultimately presented in a project that generates a WAR
13.3.1. Creating a Flex Library

To create a Flex Library Project, execute the following command at the command-line:

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-library \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-library+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-library
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
If you look in the directory sample-library/ you will see that the project consists of the directory structure shown in Figure 13.4, ?Flexmojo Library Archetype File Structure?.


Figure 13.4. Flexmojo Library Archetype File Structure


The product of the simple Flex library archetype only contains three files: a POM, one source, and a unit test. Let?s examine each of these files. First, the Project Object Model (POM).

Project Object Model for Flex Library Archetype.

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">
4.0.0

org..test
sample-library
1.0-SNAPSHOT
swc

sample-library Flex


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true






com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id='org.maven.ide.eclipse.configuration.flex.configurator' />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4







Project Object Model for Flex Library Archetype is very simple, the key to this POM is the flexmojos-maven-plugin configuration which sets extensions to true. This configuration customizes the lifecycle for the swc packaging which is defined in the flexmojos-maven-plugin. The archetype then includes the flex-framework dependency and the flexmojos-unittest-support test-scoped dependency. The flex-framework dependency is a POM which contains references to the SWC libraries and resources required to compile Flex applications.

In Project Object Model for Flex Library Archetype, the packaging is very critical. A POMs packaging type controls the lifecycle it uses to produce build output. The value swc in the packaging element is Maven?s cue to look for the Flex-specific lifecycle customizations which are provided by the flexmojos-maven-plugin. The other important part of this POM is the build element which specifies the location of the Flex source code and the Flex unit tests. Next, let?s take a quick look at Flex Library Archetype?s Sample App Class which contains the sample Actionscript which was created by this archetype.

Flex Library Archetype?s Sample App Class.

package org..test {
public class App {
public static function greeting(name:String):String {
return "Hello, " + name;
}
}
}
While this code is underwhelming, it does provide you with a quick model and a quick pointer: "Place More Code Here". While it might seem silly to test code this simple, a sample test named TestApp.as is provides in the src/test/flex directory. This test is shown in Unit Test for Library Archetype?s App Class.

Unit Test for Library Archetype?s App Class.

package org..test {

import flexunit.framework.TestCase;

public class TestApp extends TestCase {

/**
* Tests our greeting() method
*/
public function testGreeting():void {
var name:String = "Buck Rogers";
var expectedGreeting:String = "Hello, Buck Rogers";

var result:String = App.greeting(name);
assertEquals("Greeting is incorrect", expectedGreeting, result);
}
}
}
To run this build, go to the sample-library project directory and run mvn install.

$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building sample-library Flex
[INFO]task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] [flexmojos:compile-swc]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[WARNING] Nothing expecified to include. Assuming source and resources folders.
[INFO] Flex compiler configurations:
-compiler.headless-server=false
-compiler.keep-all-type-selectors=false
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex/\
3.2.0.3958...
-compiler.namespaces.namespace http://www.adobe.com/2006/mxml
target/classes/configs/mxml-manifest.xml
-compiler.optimize=true
-compiler.source-path src/main/flex
...
[INFO] [resources:testResources]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered \
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory src/test/resources
[INFO] [flexmojos:test-compile]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] Flex compiler configurations:
-compiler.include-libraries ~/.m2/repository/org//flexmojos/\
flexmojos-unittest-support...
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex
3.2.0.3958/flex-3.2.0....
-compiler.optimize=true
-compiler.source-path src/main/flex target/test-classes src/test/flex
-compiler.strict=true
-target-player 9.0.0
-use-network=true
-verify-digests=true -load-config=
[INFO] Already trust on target/test-classes/TestRunner.swf
[INFO] [flexmojos:test-run]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] flexunit setup args: null
[INFO] ------------------------------------------------------------------------
[INFO] Tests run: 1, Failures: 0, Errors: 0, Time Elpased: 0 sec
[INFO] [install:install]
Note

To execute Flex unit tests you will need to configure your PATH environment variable to include the Flash Player. For more information about configuring FlexMojos for unit tests, see Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.

When you ran mvn install on this project, you should notice in the output that Maven and Flexmojos plugin is take care of managing all of the libraries and the dependencies for the Flex compiler. Much like Maven excels at helping Java developers manage the contents of a Java classpath, Maven can help Flex developers manage the complex of compile paths. You also might have been shocked when the Flexmojos project started a web browser or the Flash Player and used it to execute the TestApp.as class against the project?s source code.

13.3.2. Creating a Flex Application

To create a Flex application from a Maven archetype, execute the following command:

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-application \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-application+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+
[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim/flex-sample
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-application
[INFO] BUILD SUCCESSFUL
If you look in the directory sample-application/ you will see the filesystem shown in Figure 13.5, ?Directory Structure for Flex Application Archetype?.


Figure 13.5. Directory Structure for Flex Application Archetype


Building an application from the Application archetype produces the following POM.

POM for Flex Application Archetype.

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">
4.0.0

org..test
sample-application
1.0-SNAPSHOT
swf

sample-application Flex


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true






com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id='org.maven.ide.eclipse.configuration.flex.configurator' />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








The difference between POM for Flex Application Archetype and Project Object Model for Flex Library Archetype is that the packaging element is swf instead of swc. By setting the packaging to swf, the project will produce a Flex application in target/sample-application-1.0-SNAPSHOT.swf. The sample application created by this archetype displays the Text "Hello World". Main.mxml can be found in src/main/flex.

Sample Application Main.mxml.




This application also creates a simple FlexUnit test that does nothing more than print out a trace message. The sample unit test is in src/test/flex/org//test.

Unit Test for Main.mxml.

package org..test
{

import flexunit.framework.TestCase;
import Main;

public class TestApp extends TestCase
{

public function testNothing():void
{
//TODO un implemented
trace("Hello test");
}
}
}
13.3.3. Creating a Multi-module Project: Web Application with a Flex

To create a multi-module project consisting of a Flex Library project referenced by a Flex Application, referenced by a Web Application.

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-modular-webapp \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-multimodule+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+
[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-multimodule
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
If you look in the sample-multimodule/ directory, you will see a directory structure which contains three projects swc, swf, and war.


Figure 13.6. Directory Structure for Flex Multimodule Archetype


The simple top-level POM in this multimodule project is shown in . It consists of module references to the swc, swf, and war modules.

Top-level POM Created by Modular Web Application Archetype.

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">
4.0.0
org..test
sample-multimodule
1.0-SNAPSHOT
pom


swc
swf
war


The swc project has a simple POM that resembles the POM shown in Project Object Model for Flex Library Archetype. Note that the artifactId in this POM differs from the name of the module directory and is swc-swc.

swc Module POM.

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">
4.0.0


org..test
sample-multimodule
1.0-SNAPSHOT


org..test
swc
1.0-SNAPSHOT
swc

swc Library


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true


en_US








com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id="org.maven.ide.eclipse.configuration.flex.configurator" />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








The swf module?s POM resembles the POM in POM for Flex Application Archetype adding a dependency on the swc-swc artifact. Note that the following POM defines an artifactId that differs from the directory that stores the module; the artifactId in the following POM is swf-swf.

swf module POM.

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">
4.0.0


org..test
sample-multimodule
1.0-SNAPSHOT


org..test
swf
1.0-SNAPSHOT
swf

swf Application


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true


en_US








com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test



org..test
swc
1.0-SNAPSHOT
swc





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id="org.maven.ide.eclipse.configuration.flex.configurator" />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








When you declare a dependency on a SWC, you?ll need to specify the type of the dependency so that Maven can locate the appropriate artifact in the remote or local repository. In this case, the swf-swf project depends upon the SWC that is generated by the swc-swc project. When you add the dependency to the swf-swf project, the FlexMojos plugin will add the appropriate SWC file to the Flex Compiler?s library path.

Next, take a look at the simple POM in the war module.

war module POM.

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">
4.0.0

sample-multimodule
org..test
1.0-SNAPSHOT


org..test
war
1.0-SNAPSHOT

war



org..flexmojos
flexmojos-maven-plugin
3.5.0



copy-flex-resources





org.mortbay.jetty
maven-jetty-plugin
6.1.17






org..test
swf
1.0-SNAPSHOT
swf




The POM shown in war module POM configures the FlexMojos plugin to execute the copy-flex-resources goal for this project. The copy-flex-resources goal will copy SWF application into the web application?s document root. In this project, running a build and creating a WAR will copy the swf-swf-1.0-SNAPSHOT.swf file to the web application?s root directory in target/war-war-1.0-SNAPSHOT.

To build the multimodule web application project, run mvn install from the top-level directory. This should build the swc-swc, swf-swf, and war-war artifacts and product a WAR file in war'/target/war-war-1.0-SNAPSHOT.war' which contains the swf-swf-1.0-SNAPSHOT.swf in the document root of the web application.

Note

To execute Flex unit tests you will need to configure your PATH environment variable to include the Flash Player. For more information about configuring FlexMojos for unit tests, see Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.

Prev : 13.2. Configuring Build Environment for Flexmojos
TOC
Next : 13.4. The FlexMojos Lifecycle
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








238---->
Prev : 13.2. Configuring Build Environment for Flexmojos
TOC
Next : 13.4. The FlexMojos Lifecycle
13.3. Creating a Flex Mojos Project from an Archetype

Flexmojos has a set of archetypes which can be used to quickly create a new Flex project. The following archetypes are all in the org..flexmojos group with a version of ${flexmojos.version}:

flexmojos-archetypes-library
Creates a simple Flex Library project which produces a SWC
flexmojos-archetypes-application
Creates a simple Flex Application with produces a SWF
flexmojos-archetypes-modular-webapp
Creates a Multimodule project which consists of a project that produces a SWC which is consumed by a project which produces a SWF that is ultimately presented in a project that generates a WAR
13.3.1. Creating a Flex Library

To create a Flex Library Project, execute the following command at the command-line:

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-library \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-library+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-library
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
If you look in the directory sample-library/ you will see that the project consists of the directory structure shown in Figure 13.4, ?Flexmojo Library Archetype File Structure?.


Figure 13.4. Flexmojo Library Archetype File Structure


The product of the simple Flex library archetype only contains three files: a POM, one source, and a unit test. Let?s examine each of these files. First, the Project Object Model (POM).

Project Object Model for Flex Library Archetype.

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">
4.0.0

org..test
sample-library
1.0-SNAPSHOT
swc

sample-library Flex


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true






com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id='org.maven.ide.eclipse.configuration.flex.configurator' />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4







Project Object Model for Flex Library Archetype is very simple, the key to this POM is the flexmojos-maven-plugin configuration which sets extensions to true. This configuration customizes the lifecycle for the swc packaging which is defined in the flexmojos-maven-plugin. The archetype then includes the flex-framework dependency and the flexmojos-unittest-support test-scoped dependency. The flex-framework dependency is a POM which contains references to the SWC libraries and resources required to compile Flex applications.

In Project Object Model for Flex Library Archetype, the packaging is very critical. A POMs packaging type controls the lifecycle it uses to produce build output. The value swc in the packaging element is Maven?s cue to look for the Flex-specific lifecycle customizations which are provided by the flexmojos-maven-plugin. The other important part of this POM is the build element which specifies the location of the Flex source code and the Flex unit tests. Next, let?s take a quick look at Flex Library Archetype?s Sample App Class which contains the sample Actionscript which was created by this archetype.

Flex Library Archetype?s Sample App Class.

package org..test {
public class App {
public static function greeting(name:String):String {
return "Hello, " + name;
}
}
}
While this code is underwhelming, it does provide you with a quick model and a quick pointer: "Place More Code Here". While it might seem silly to test code this simple, a sample test named TestApp.as is provides in the src/test/flex directory. This test is shown in Unit Test for Library Archetype?s App Class.

Unit Test for Library Archetype?s App Class.

package org..test {

import flexunit.framework.TestCase;

public class TestApp extends TestCase {

/**
* Tests our greeting() method
*/
public function testGreeting():void {
var name:String = "Buck Rogers";
var expectedGreeting:String = "Hello, Buck Rogers";

var result:String = App.greeting(name);
assertEquals("Greeting is incorrect", expectedGreeting, result);
}
}
}
To run this build, go to the sample-library project directory and run mvn install.

$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building sample-library Flex
[INFO]task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] [flexmojos:compile-swc]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[WARNING] Nothing expecified to include. Assuming source and resources folders.
[INFO] Flex compiler configurations:
-compiler.headless-server=false
-compiler.keep-all-type-selectors=false
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex/\
3.2.0.3958...
-compiler.namespaces.namespace http://www.adobe.com/2006/mxml
target/classes/configs/mxml-manifest.xml
-compiler.optimize=true
-compiler.source-path src/main/flex
...
[INFO] [resources:testResources]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered \
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory src/test/resources
[INFO] [flexmojos:test-compile]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] Flex compiler configurations:
-compiler.include-libraries ~/.m2/repository/org//flexmojos/\
flexmojos-unittest-support...
-compiler.keep-generated-actionscript=false
-compiler.library-path ~/.m2/repository/com/adobe/flex/framework/flex
3.2.0.3958/flex-3.2.0....
-compiler.optimize=true
-compiler.source-path src/main/flex target/test-classes src/test/flex
-compiler.strict=true
-target-player 9.0.0
-use-network=true
-verify-digests=true -load-config=
[INFO] Already trust on target/test-classes/TestRunner.swf
[INFO] [flexmojos:test-run]
[INFO] flexmojos ${flexmojos.version} - GNU GPL License (NO WARRANTY) - \
See COPYRIGHT file
[INFO] flexunit setup args: null
[INFO] ------------------------------------------------------------------------
[INFO] Tests run: 1, Failures: 0, Errors: 0, Time Elpased: 0 sec
[INFO] [install:install]
Note

To execute Flex unit tests you will need to configure your PATH environment variable to include the Flash Player. For more information about configuring FlexMojos for unit tests, see Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.

When you ran mvn install on this project, you should notice in the output that Maven and Flexmojos plugin is take care of managing all of the libraries and the dependencies for the Flex compiler. Much like Maven excels at helping Java developers manage the contents of a Java classpath, Maven can help Flex developers manage the complex of compile paths. You also might have been shocked when the Flexmojos project started a web browser or the Flash Player and used it to execute the TestApp.as class against the project?s source code.

13.3.2. Creating a Flex Application

To create a Flex application from a Maven archetype, execute the following command:

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-application \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-application+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+
[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim/flex-sample
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-application
[INFO] BUILD SUCCESSFUL
If you look in the directory sample-application/ you will see the filesystem shown in Figure 13.5, ?Directory Structure for Flex Application Archetype?.


Figure 13.5. Directory Structure for Flex Application Archetype


Building an application from the Application archetype produces the following POM.

POM for Flex Application Archetype.

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">
4.0.0

org..test
sample-application
1.0-SNAPSHOT
swf

sample-application Flex


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true






com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id='org.maven.ide.eclipse.configuration.flex.configurator' />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








The difference between POM for Flex Application Archetype and Project Object Model for Flex Library Archetype is that the packaging element is swf instead of swc. By setting the packaging to swf, the project will produce a Flex application in target/sample-application-1.0-SNAPSHOT.swf. The sample application created by this archetype displays the Text "Hello World". Main.mxml can be found in src/main/flex.

Sample Application Main.mxml.




This application also creates a simple FlexUnit test that does nothing more than print out a trace message. The sample unit test is in src/test/flex/org//test.

Unit Test for Main.mxml.

package org..test
{

import flexunit.framework.TestCase;
import Main;

public class TestApp extends TestCase
{

public function testNothing():void
{
//TODO un implemented
trace("Hello test");
}
}
}
13.3.3. Creating a Multi-module Project: Web Application with a Flex

To create a multi-module project consisting of a Flex Library project referenced by a Flex Application, referenced by a Web Application.

$ mvn archetype:generate \
-DarchetypeRepository=http://repository..org/content/groups/public\
-DarchetypeGroupId=org..flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-modular-webapp \
-DarchetypeVersion=${flexmojos.version}
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] com..maven.plugins: checking for updates from central
...
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype defined by properties
...
Define value for groupId: : +org..test+
Define value for artifactId: : +sample-multimodule+
Define value for version: 1.0-SNAPSHOT: : +1.0-SNAPSHOT+
Define value for package: org..test: : +org..test+
Confirm properties configuration:
groupId: org..test
artifactId: sample-library
version: 1.0-SNAPSHOT
package: org..test
Y: : +Y+
[INFO] Parameter: groupId, Value: org..test
[INFO] Parameter: packageName, Value: org..test
[INFO] Parameter: basedir, Value: /Users/Tim
[INFO] Parameter: package, Value: org..test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: sample-multimodule
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
If you look in the sample-multimodule/ directory, you will see a directory structure which contains three projects swc, swf, and war.


Figure 13.6. Directory Structure for Flex Multimodule Archetype


The simple top-level POM in this multimodule project is shown in . It consists of module references to the swc, swf, and war modules.

Top-level POM Created by Modular Web Application Archetype.

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">
4.0.0
org..test
sample-multimodule
1.0-SNAPSHOT
pom


swc
swf
war


The swc project has a simple POM that resembles the POM shown in Project Object Model for Flex Library Archetype. Note that the artifactId in this POM differs from the name of the module directory and is swc-swc.

swc Module POM.

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">
4.0.0


org..test
sample-multimodule
1.0-SNAPSHOT


org..test
swc
1.0-SNAPSHOT
swc

swc Library


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true


en_US








com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id="org.maven.ide.eclipse.configuration.flex.configurator" />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








The swf module?s POM resembles the POM in POM for Flex Application Archetype adding a dependency on the swc-swc artifact. Note that the following POM defines an artifactId that differs from the directory that stores the module; the artifactId in the following POM is swf-swf.

swf module POM.

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">
4.0.0


org..test
sample-multimodule
1.0-SNAPSHOT


org..test
swf
1.0-SNAPSHOT
swf

swf Application


src/main/flex
src/test/flex


org..flexmojos
flexmojos-maven-plugin
3.5.0
true


en_US








com.adobe.flex.framework
flex-framework
3.2.0.3958
pom



com.adobe.flexunit
flexunit
0.85
swc
test



org..test
swc
1.0-SNAPSHOT
swc





m2e


m2e.version





org.maven.ide.eclipse
lifecycle-mapping
0.9.9-SNAPSHOT

customizable

id="org.maven.ide.eclipse.configuration.flex.configurator" />



org.apache.maven.plugins:maven-resources-plugin::








org.apache.maven.plugins
maven-resources-plugin
2.4








When you declare a dependency on a SWC, you?ll need to specify the type of the dependency so that Maven can locate the appropriate artifact in the remote or local repository. In this case, the swf-swf project depends upon the SWC that is generated by the swc-swc project. When you add the dependency to the swf-swf project, the FlexMojos plugin will add the appropriate SWC file to the Flex Compiler?s library path.

Next, take a look at the simple POM in the war module.

war module POM.

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">
4.0.0

sample-multimodule
org..test
1.0-SNAPSHOT


org..test
war
1.0-SNAPSHOT

war



org..flexmojos
flexmojos-maven-plugin
3.5.0



copy-flex-resources





org.mortbay.jetty
maven-jetty-plugin
6.1.17






org..test
swf
1.0-SNAPSHOT
swf




The POM shown in war module POM configures the FlexMojos plugin to execute the copy-flex-resources goal for this project. The copy-flex-resources goal will copy SWF application into the web application?s document root. In this project, running a build and creating a WAR will copy the swf-swf-1.0-SNAPSHOT.swf file to the web application?s root directory in target/war-war-1.0-SNAPSHOT.

To build the multimodule web application project, run mvn install from the top-level directory. This should build the swc-swc, swf-swf, and war-war artifacts and product a WAR file in war'/target/war-war-1.0-SNAPSHOT.war' which contains the swf-swf-1.0-SNAPSHOT.swf in the document root of the web application.

Note

To execute Flex unit tests you will need to configure your PATH environment variable to include the Flash Player. For more information about configuring FlexMojos for unit tests, see Section 13.2.3, ?Configuring Environment to Support Flex Unit Tests?.

Prev : 13.2. Configuring Build Environment for Flexmojos
TOC
Next : 13.4. The FlexMojos Lifecycle
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








239---->
Prev : 13.1. Introduction
TOC
Next : 13.3. Creating a Flex Mojos Project from an Archetype
13.2. Configuring Build Environment for Flexmojos

Before you attempt to compile Flex libraries and applications with Maven, you will need to complete two configuration tasks:

Configure your Maven settings to reference a repository which contains the Flex framework
Add the Flash Player to your PATH to support Flex unit testing
(Optional) Configure your Maven Settings to include the plugin group
13.2.1. Referencing a Repository with the Flex Framework

To setup your Maven environment for Flexmojos, you have two options: you can reference the Flexmojos repository directly in a pom.xml, or you can install Nexus and add the Flexmojos repository as a proxy repository in your own repository manager. While the most straightforward option is to reference the repository directly, downloading and installing Nexus will give you the control and flexibility you need to cache and manage artifacts generated by your own build. If you are just interested in getting up and running with Flexmojos, read the section called ?Referencing ?s Flexmojos Repository in a POM? next. If you are interested in a long-term solution which can be deployed to support a development team, continue to the section called ?Proxying ?s Flexmojos Repository with Nexus?.

Note

If your organization is already using Nexus to proxy remote repositories, you may already have customized your ~/.m2/settings.xml file to point to a single Nexus group. If this is your situation, you should add a Proxy repository for the Flexmojos repository group at ${flexmojos.repository}[${flexmojos.repository}]. Add this new repository to the Nexus Repository Group that is referenced by your development team. Adding a proxy repository for this remote group and then adding this group to your Nexus installation?s public repository group will give clients of your Nexus instance access to the artifacts from the repository..org Nexus instance.

Referencing ?s Flexmojos Repository in a POM

Flexmojos depends on a few artifacts which are not currently available from the Central Maven repository. These artifacts are available from a Repository hosted by . To use Flexmojos, you will need to reference this repository from your project?s pom.xml. To do this, add the repositories element shown in Adding a Reference to ?s FlexMojos Repository in a POM to your project?s pom.xml.

Adding a Reference to ?s FlexMojos Repository in a POM.


4.0.0
test
test
1.0-SNAPSHOT
pom


swc
swf
war


*

flexmojos
${flexmojos.repository}

*


The XML shown in Adding a Reference to ?s FlexMojos Repository in a POM, will add this repository to the list of repositories Maven will consult when it attempts to download artifacts and plugins.

Proxying ?s Flexmojos Repository with Nexus

Instead of pointing directly at the Flexmojos repository, recommends that you install a repository manager and proxy the public repository. When you proxy a remote repository with a repository manager such as Nexus, you gain a level of control and stability not possible when your build relies directly on external resources. In addition to this control and stability, a repository manager also provides you with an deployment target for binary artifacts generated by your own builds. For instructions on downloading, installing, and configuring Nexus, refer to the Installation chapter in Repository Management with Nexus.

13.2.2. Configure a Flexmojos Proxy Repository in Nexus

Once Nexus is installed and started, complete the following steps to add a proxy repository for the public repository. To add a new proxy repository:

Click on the Repositories link under Views/Repositories in the Nexus menu on the left-hand side of the Nexus user interface.
Click on Repositories to load the Repositories panel.
In the Repositories panel, click on the Add.. button and select Proxy Repository as shown in Figure 13.1, ?Adding a Proxy Repository to Nexus?.

Figure 13.1. Adding a Proxy Repository to Nexus


Once you?ve created a new Proxy repository, you will need to configure it to point to the Flexmojos repository.

Select the new repository, and then
Select the Configuration tab in the lower half of the window.
Populate the following field with the values shown in Figure 13.2, ?Configuring the Flexmojos Proxy Repository?.

Repository ID is "-flexmojos"
Repository Name is " Flexmojos Proxy"
The Remote Storage Location is ${flexmojos.repository}[${flexmojos.repository}]

Figure 13.2. Configuring the Flexmojos Proxy Repository


Once you have populated the fields shown in Figure 13.2, ?Configuring the Flexmojos Proxy Repository? click the Save button to save the proxy repository and start proxying the Flexmojos repository.

Add the Flexmojos Proxy Repository to a Group

Nexus ships with a public repository group, which combines several repositories into a single URL for Maven clients. Add this new Flexmojos proxy repository to the Nexus public group. To do this:

Return to the list of repositories which should now be visible in the upper half of the Repositories panel as shown in Figure 13.2, ?Configuring the Flexmojos Proxy Repository?.
Click on the Public Repositories group, and then
Click on the Configuration tab in the lower half of the Repository panel. Clicking the Configuration tab will expose the Group configuration form shown in Figure 13.3, ?Adding the Flexmojos Proxy to the Public Repositories Group?.

Figure 13.3. Adding the Flexmojos Proxy to the Public Repositories Group


To add the Public Proxy to the Public Repositories group simply drag and drop the Public Proxy repository from the Available Repositories list to the Ordered Group Repositories list.
Click Save, and you have successfully added a proxy of the Flexmojos repository to your Nexus installation.
Whenever a client requests an artifact from this repository group, if Nexus has not already cached a matching artifact, it will query the Flexmojos repository at ${flexmojos.repository}[${flexmojos.repository}]. Your Nexus installation will maintain a local cache of all artifacts retrieved from the Flexmojos repository. This local cache gives you more control and contributes to a more stable build environment. If you are setting up a group of developers to rely upon artifacts from the public repository, you?ll have a completely self-contained build environment that won?t be subject to the availability of the repository once the necessary artifacts have been cached by your Nexus instance.

Configure Your Development Environment for Nexus

The final step is connecting your Maven installation to the Nexus instance you just configured. You will need to update your Maven Settings to use your Nexus repository group as a mirror for all repositories. To do this, you need to put the following XML in your ~/.m2/settings.xml file.

Settings XML for Local Nexus Instance.





nexus
*
http://localhost:8081/nexus/content/groups/public




nexus



central
http://central
true
true




central
http://central
true
true





nexus


This XML file configures Maven to consult a single public repository group for all configured repositories and plugin repositories. It is a simple way to guarantee that every request for an artifact is made through your Nexus installation.

13.2.3. Configuring Environment to Support Flex Unit Tests

Flexmojos expects to be able to launch the stand-alone Flash Player to execute unit tests. In order for this to work, you will need to add the stand-alone Flash Player to your PATH, or you will need to pass the location of the Flash Player executable to your build using the -DflashPlayer.command options. When executing a unit test, Flex Mojos expects to launch the following platform-specific executables for the stand-alone Flash Player:

Microsoft Windows
FlexMojos will attempt to launch the FlashPlayer.exe binary. To support execution of unit tests, add the directory containing FlashPlayer.exe to your PATH or pass in the location of the FlashPlayer.exe binary to Maven using the
Macintosh OSX
FlexMojos will attempt to launch the "Flash Player" application. To support the execution of unit tests, add the directory containing "Flash Player" to your PATH or pass the path to the executable to option.
Unix (Linux, Solaris, etc.)
FlexMojos will attempt to launch the flashplayer executable. To support the execution of unit tests, add the directory containing flashplayer to your PATH or pass the path to the executable to option.
Note

On a Linux machine, you will need to have X virtual framebuffer (Xvfb) installed to run unit tests in a headless build. For more information about Xvfb, click here.

If you have been developing Flash Applications with Adobe Flash CS4 or Adobe Flex Builder or if you have been viewing flash content in a browser, you probably have the Flash Player installed somewhere on your workstation. While it is possible to configure Maven to use one of these players for Flex unit tests, you?ll want to make sure that you are running the debug version of the Flash Player. To minimize the potential for incompatibility, you should download one of the Flash Player?s listed below and install it on your local workstation. To download the standalone Flash Player for you environment:

Windows: http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.exe
Mac OSX: http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.app.zip
Linux: http://download.macromedia.com/pub/flashplayer/updaters/10/flash_player_10_linux_dev.tar.gz
To install this player and add it to your PATH on an OSX machine, run the following commands:

$ wget http://download.macromedia.com/pub/flashplayer/updaters/10/\
flashplayer_10_sa_debug.app.zip
$ unzip flashplayer_10_sa_debug.app.zip
$ sudo cp -r Flash\ Player.app /Applications/
$ export PATH=/Applications/Flash\ Player.app/Contents/MacOS:${PATH}
Instead of adding the path for the Flash Player to your PATH on the command-line, you should configure your environment to automatically configure these variables. If you are using bash, you would add the last export command to your ~/.bash_profile.

13.2.4. Adding FlexMojos to Your Maven Settings' Plugin Groups

If you need to run FlexMojos goals from the command-line, it will be more convenient if you add the Plugin groups to your Maven Settings. To do this, open up ~/.m2/settings.xml and add the following plugin groups:

Adding Plugins to Maven Settings.


com..maven.plugins
org..plugins

Once you?ve added these plugin groups to your Maven Settings you can invoke a FlexMojos goal using the plugin prefix flexmojos. Without this configuration, calling the flexbuilder goal would involve the following command-line:

$ mvn org..flexmojos:flexmojos-maven-plugin:${flexmojos.version}:flexbuilder
With the org..plugins group in your Maven settings, the same goal can be invoked with:

$ mvn flexmojos:flexbuilder
Prev : 13.1. Introduction
TOC
Next : 13.3. Creating a Flex Mojos Project from an Archetype
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI








240---->
Prev : 13.1. Introduction
TOC
Next : 13.3. Creating a Flex Mojos Project from an Archetype
13.2. Configuring Build Environment for Flexmojos

Before you attempt to compile Flex libraries and applications with Maven, you will need to complete two configuration tasks:

Configure your Maven settings to reference a repository which contains the Flex framework
Add the Flash Player to your PATH to support Flex unit testing
(Optional) Configure your Maven Settings to include the plugin group
13.2.1. Referencing a Repository with the Flex Framework

To setup your Maven environment for Flexmojos, you have two options: you can reference the Flexmojos repository directly in a pom.xml, or you can install Nexus and add the Flexmojos repository as a proxy repository in your own repository manager. While the most straightforward option is to reference the repository directly, downloading and installing Nexus will give you the control and flexibility you need to cache and manage artifacts generated by your own build. If you are just interested in getting up and running with Flexmojos, read the section called ?Referencing ?s Flexmojos Repository in a POM? next. If you are interested in a long-term solution which can be deployed to support a development team, continue to the section called ?Proxying ?s Flexmojos Repository with Nexus?.

Note

If your organization is already using Nexus to proxy remote repositories, you may already have customized your ~/.m2/settings.xml file to point to a single Nexus group. If this is your situation, you should add a Proxy repository for the Flexmojos repository group at ${flexmojos.repository}[${flexmojos.repository}]. Add this new repository to the Nexus Repository Group that is referenced by your development team. Adding a proxy repository for this remote group and then adding this group to your Nexus installation?s public repository group will give clients of your Nexus instance access to the artifacts from the repository..org Nexus instance.

Referencing ?s Flexmojos Repository in a POM

Flexmojos depends on a few artifacts which are not currently available from the Central Maven repository. These artifacts are available from a Repository hosted by . To use Flexmojos, you will need to reference this repository from your project?s pom.xml. To do this, add the repositories element shown in Adding a Reference to ?s FlexMojos Repository in a POM to your project?s pom.xml.

Adding a Reference to ?s FlexMojos Repository in a POM.


4.0.0
test
test
1.0-SNAPSHOT
pom


swc
swf
war


*

flexmojos
${flexmojos.repository}

*


The XML shown in Adding a Reference to ?s FlexMojos Repository in a POM, will add this repository to the list of repositories Maven will consult when it attempts to download artifacts and plugins.

Proxying ?s Flexmojos Repository with Nexus

Instead of pointing directly at the Flexmojos repository, recommends that you install a repository manager and proxy the public repository. When you proxy a remote repository with a repository manager such as Nexus, you gain a level of control and stability not possible when your build relies directly on external resources. In addition to this control and stability, a repository manager also provides you with an deployment target for binary artifacts generated by your own builds. For instructions on downloading, installing, and configuring Nexus, refer to the Installation chapter in Repository Management with Nexus.

13.2.2. Configure a Flexmojos Proxy Repository in Nexus

Once Nexus is installed and started, complete the following steps to add a proxy repository for the public repository. To add a new proxy repository:

Click on the Repositories link under Views/Repositories in the Nexus menu on the left-hand side of the Nexus user interface.
Click on Repositories to load the Repositories panel.
In the Repositories panel, click on the Add.. button and select Proxy Repository as shown in Figure 13.1, ?Adding a Proxy Repository to Nexus?.

Figure 13.1. Adding a Proxy Repository to Nexus


Once you?ve created a new Proxy repository, you will need to configure it to point to the Flexmojos repository.

Select the new repository, and then
Select the Configuration tab in the lower half of the window.
Populate the following field with the values shown in Figure 13.2, ?Configuring the Flexmojos Proxy Repository?.

Repository ID is "-flexmojos"
Repository Name is " Flexmojos Proxy"
The Remote Storage Location is ${flexmojos.repository}[${flexmojos.repository}]

Figure 13.2. Configuring the Flexmojos Proxy Repository


Once you have populated the fields shown in Figure 13.2, ?Configuring the Flexmojos Proxy Repository? click the Save button to save the proxy repository and start proxying the Flexmojos repository.

Add the Flexmojos Proxy Repository to a Group

Nexus ships with a public repository group, which combines several repositories into a single URL for Maven clients. Add this new Flexmojos proxy repository to the Nexus public group. To do this:

Return to the list of repositories which should now be visible in the upper half of the Repositories panel as shown in Figure 13.2, ?Configuring the Flexmojos Proxy Repository?.
Click on the Public Repositories group, and then
Click on the Configuration tab in the lower half of the Repository panel. Clicking the Configuration tab will expose the Group configuration form shown in Figure 13.3, ?Adding the Flexmojos Proxy to the Public Repositories Group?.

Figure 13.3. Adding the Flexmojos Proxy to the Public Repositories Group


To add the Public Proxy to the Public Repositories group simply drag and drop the Public Proxy repository from the Available Repositories list to the Ordered Group Repositories list.
Click Save, and you have successfully added a proxy of the Flexmojos repository to your Nexus installation.
Whenever a client requests an artifact from this repository group, if Nexus has not already cached a matching artifact, it will query the Flexmojos repository at ${flexmojos.repository}[${flexmojos.repository}]. Your Nexus installation will maintain a local cache of all artifacts retrieved from the Flexmojos repository. This local cache gives you more control and contributes to a more stable build environment. If you are setting up a group of developers to rely upon artifacts from the public repository, you?ll have a completely self-contained build environment that won?t be subject to the availability of the repository once the necessary artifacts have been cached by your Nexus instance.

Configure Your Development Environment for Nexus

The final step is connecting your Maven installation to the Nexus instance you just configured. You will need to update your Maven Settings to use your Nexus repository group as a mirror for all repositories. To do this, you need to put the following XML in your ~/.m2/settings.xml file.

Settings XML for Local Nexus Instance.





nexus
*
http://localhost:8081/nexus/content/groups/public




nexus



central
http://central
true
true




central
http://central
true
true





nexus


This XML file configures Maven to consult a single public repository group for all configured repositories and plugin repositories. It is a simple way to guarantee that every request for an artifact is made through your Nexus installation.

13.2.3. Configuring Environment to Support Flex Unit Tests

Flexmojos expects to be able to launch the stand-alone Flash Player to execute unit tests. In order for this to work, you will need to add the stand-alone Flash Player to your PATH, or you will need to pass the location of the Flash Player executable to your build using the -DflashPlayer.command options. When executing a unit test, Flex Mojos expects to launch the following platform-specific executables for the stand-alone Flash Player:

Microsoft Windows
FlexMojos will attempt to launch the FlashPlayer.exe binary. To support execution of unit tests, add the directory containing FlashPlayer.exe to your PATH or pass in the location of the FlashPlayer.exe binary to Maven using the
Macintosh OSX
FlexMojos will attempt to launch the "Flash Player" application. To support the execution of unit tests, add the directory containing "Flash Player" to your PATH or pass the path to the executable to option.
Unix (Linux, Solaris, etc.)
FlexMojos will attempt to launch the flashplayer executable. To support the execution of unit tests, add the directory containing flashplayer to your PATH or pass the path to the executable to option.
Note

On a Linux machine, you will need to have X virtual framebuffer (Xvfb) installed to run unit tests in a headless build. For more information about Xvfb, click here.

If you have been developing Flash Applications with Adobe Flash CS4 or Adobe Flex Builder or if you have been viewing flash content in a browser, you probably have the Flash Player installed somewhere on your workstation. While it is possible to configure Maven to use one of these players for Flex unit tests, you?ll want to make sure that you are running the debug version of the Flash Player. To minimize the potential for incompatibility, you should download one of the Flash Player?s listed below and install it on your local workstation. To download the standalone Flash Player for you environment:

Windows: http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.exe
Mac OSX: http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.app.zip
Linux: http://download.macromedia.com/pub/flashplayer/updaters/10/flash_player_10_linux_dev.tar.gz
To install this player and add it to your PATH on an OSX machine, run the following commands:

$ wget http://download.macromedia.com/pub/flashplayer/updaters/10/\
flashplayer_10_sa_debug.app.zip
$ unzip flashplayer_10_sa_debug.app.zip
$ sudo cp -r Flash\ Player.app /Applications/
$ export PATH=/Applications/Flash\ Player.app/Contents/MacOS:${PATH}
Instead of adding the path for the Flash Player to your PATH on the command-line, you should configure your environment to automatically configure these variables. If you are using bash, you would add the last export command to your ~/.bash_profile.

13.2.4. Adding FlexMojos to Your Maven Settings' Plugin Groups

If you need to run FlexMojos goals from the command-line, it will be more convenient if you add the Plugin groups to your Maven Settings. To do this, open up ~/.m2/settings.xml and add the following plugin groups:

Adding Plugins to Maven Settings.


com..maven.plugins
org..plugins

Once you?ve added these plugin groups to your Maven Settings you can invoke a FlexMojos goal using the plugin prefix flexmojos. Without this configuration, calling the flexbuilder goal would involve the following command-line:

$ mvn org..flexmojos:flexmojos-maven-plugin:${flexmojos.version}:flexbuilder
With the org..plugins group in your Maven settings, the same goal can be invoked with:

$ mvn flexmojos:flexbuilder
Prev : 13.1. Introduction
TOC
Next : 13.3. Creating a Flex Mojos Project from an Archetype
Nexus Professional

Access a live demo of the Pro Suite Install a trial version of Nexus Professional on your own machine Purchase a license for Nexus Professional
Recent Posts

Last Chance To Register: Insight for CI Demo

Insight for CI Demo: Additional Session Added

When Licenses Meet Reality, the Result is Often Confusing

How does Insight handle conflicting OSS licenses?

New Webinar: Gain Visibility & Control At Build Time with Insight for CI







null



Enter you DOB ,Time and Place


SEO Schemes

Comments

Popular posts from this blog

[Inside AdSense] Understanding your eCPM (effective cost per thousand impress...