Archive

Archive for December, 2008

Intro to flex mojo’s for maven

December 19th, 2008
Comments Off

Velo has put together some nice mojo’s for compiling flex with maven. Here is some quick tips on quickly settings up and using them. Note that you don’t even have to download the mojo’s to use them. They will be automatically downloaded the first time you compile your project.

The first thing to understand is that the mojo’s use the standard maven way of doing things and only use jar files and library files from a maven repository. That means that they don’t look in the flex sdk directory for the necessary files, so these need to be installed in your repository. Also I ran into the problem that compiling on a remote server I ended up needing the data visualization libraries?

First be sure you have the current version of maven, which is 2.0.9:

mvn -version

On the Mac OSX, maven 2.0.6 is installed be default. To upgrade just overwrite the files in /usr/share/maven

Now install all the necessary dependencies in your local repository. These are propietary jar files, so they can be distributed from a central repository.

First cd to your flex sdk directory and the under the lib directory. In there you should a whole bunch of jar files. Then run the following commands:

mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=license -Dversion=3.0.0.477 -Dpackaging=jar -Dfile=license.jar

mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=aglj32 -Dversion=3.0.0.477 -Dpackaging=jar -Dfile=aglj32.jar

mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=flex-fontkit -Dversion=3.0.0.477 -Dpackaging=jar -Dfile=flex-fontkit.jar

mvn install:install-file -DgroupId=com.adobe.flex -DartifactId=rideau -Dversion=3.0.0.477 -Dpackaging=jar -Dfile=rideau.jar

Now it is likely that you will end up needing the data visualization libraries, so do the following.

cd to the flex frameworks dir flex-sdk-3.0.0/frameworks/libs and run the following commands:

mvn install:install-file -DgroupId=com.adobe.flex.sdk -DartifactId=datavisualization -Dversion=3.0.0.477 -Dpackaging=swc -Dfile=datavisualization.swc

then cd to the flex locale dir flex-sdk-3.0.0/frameworks/locale/en_US and run the following commands:

mvn install:install-file -DgroupId=com.adobe.flex.sdk -DartifactId=datavisualization -Dversion=3.0.0.477 -Dclassifier=en_US -Dpackaging=swc -Dfile=datavisualization_rb.swc

Now you are all set to run the flex compiler on your project! I have put a sample pom file here.

Here are a couple of tips to setting up your compile process:

1 – To configure all the different options of the compiler find the option you need on this page and then in your pom add it to the build -> plugins -> plugin (flex-compiler-mojo) -> configuration. For example I set the name of the sourceFile in there.

2 – To add library dependencies, for example swc libraries first add them to your repository. For example to use the flexlib files use the following command similar to this :

mvn install:install-file -DgroupId=com.googlecode.flexlib -DartifactId=flexlib -Dversion=2.4 -Dpackaging=swc -Dfile=flexlib.swc

Then add a dependency tag to your pom. In the sample it is the dependency with the flexlib artifact id.

The types can be one of the following:

external to -compiler.external-library-path

internal to -compiler.include-libraries

merged to -compiler.library-path

rsl to -runtime-shared-library-path for SWF files

caching to -runtime-shared-library-path for SWZ files

test to -compiler.library-path only for test running

Good luck!

Ryan Knight flex

Java and Flex Setup Tips

December 19th, 2008
Comments Off

I have put together fairly extensive instructions on setting up a complete development environment for flex, java and ant. You can read about after the jump.

Jump to Tips on Flex, Java, Tomcat, Ant, Mac OS X and Windows.

OVERVIEW

1) I like to install all the development tools under a common apps directory so they are easier to access from the command line. (i.e. apps on Unix systems or c:apps on Windows). Also there can be problems when accessing the Flex SDK from a directory with spaces in the path.

2) Environment variables on Unix systems (i.e. Mac OS X or Linux) are set with the export NAME=value. For example:

export JAVA_HOME=/apps/jdk1.6.0_04

Here is sample script that sets up all the necessary envrionment variables.

You can set the environment variables for the current window by running the following command:

. ./setjava.sh

FLEX SDK SETUP

The Flex SDK is only needed if your a building the project from the command line. On windows be sure there are no spaces in the path where flex is installed. This will break the build! We are currently using Flex SDK 3.

There are two ways you can set it up:

1) Download it from Adobe.

2) Use the Flex SDK that comes with Flex Builder.

After you have setup the Flex SDK you need to set the FLEX_HOME environment variable:

FLEX_HOME=c:appsflex_sdk_300477

or FLEX_HOME=/apps/flex_sdk_300477

JAVA TIPS

Anvil has been developed with Java 1.6 and is compatabile with 1.5 with some small changes.

When you install the JDK be sure to do a custom setup, so you can install in another directory other than the default which is c:progam files. I recommend using apps for everything.

After installing Java be sure to:

1) Set the JAVA_HOME environment variable to the home directory of java.

2) Add the Java bin directory to the FIRST of the PATH environment variable. There is often several versions of Java on your machine, so it needs to be at the first of the PATH environment variable.

3) From the command line test to be sure the right version of Java is running with the following commands:

a. java –version — This should return Java 1.6

b. on cygwin or Linux you can also run which java to be sure it was installed in the right directory.

SETTING UP TOMCAT

Installing Tomcat is as simple as unzipping it. Be sure to use Tomcat 5 or Later.

See the notes below about using the Tomcat server bundled with Adobe BlazeDS.

1) Download the Tomcat Core zip or tar file.

2) Unzip it into your apps directory (or the directory where you are putting all of your development tools).

3) Set the CATALINA_HOME environment variable to the home directory of where tomcat is. Catalina is just another name for tomcat.

4) To make Tomcat easier to run add the tomcat bin directory to the PATH environment variable. i.e.

export PATH=$PATH:$CATALINA_HOME/bin

or on Windows – %CATALINA_HOME%bin

5) You should now be able to go to the command line and run either:

Linux / Mac OS X varieties – <a href=”http://catalina.sh/”>catalina.sh</a> version

Windows – catalina.bat version

6) To run the Tomcat manager application you need to add an administrative user:

Under the tomcat home directory is a conf directory. In there modify the tomcat-users.xml file.

Add the following line to the file:

&lt;user username=”admin” password=”admin” roles=”manager,tomcat,role1″/&gt;

7) Sometimes when you run Tomcat you will get a conflict with the port it listens on. By default this is port 8080. On Blaze DS the port is changed to 8400. To change this modify the server.xml file in the conf directory.

Modify the line that starts with:

&lt;Connector port=”8080″ Also modify the shutdown port:

&lt;Server port=”8005″ shutdown=”SHUTDOWN”&gt;

Start tomcat from the command line by running:

Linux / Unix vareties – <a href=”http://catalina.sh/”>catalina.sh</a> run

Windows – catalina.bat run

9) You can also start tomcat in a new window by running <a href=”http://catalina.sh/”>catalina.sh</a> start. Tomcat will output the log file to the catalina.out file in the logs directory.

10) To connect to the tomcat manager use the URL:

<a href=”http://localhost:8080/manager/html”>http://localhost:8080/manager/html</a>

Adobe BlazeDS comes with a bundled Tomcat Server. Some things should be noted when using it with Anvil.

1) Under the Blaze DS Tomcat directory is a lib directory. Under there is an activemq4.1.1 directory. The libraries in this directory conflict with the anvil libraries. So this directory either needs to be deleted or moved out of the tomcat directory.

2) BlazeDS Tomcat runs on port 8400 so the URL is localhost:8400

3) Be sure to set the catalina home environment variable to the BlazeDS Tomcat Server, i.e. CATALINA_HOME= C:appsblazeds_b1_121307tomcat

SETTING UP ANT

Installing Ant is as easy as unzipping it. Ant is only needed if you want to build from the source

1) Download Ant and unzip it. It is recommended to put it in the apps directory.

2) Set the ANT_HOME environment variable, i.e. ANT_HOME= C:appsapache-ant-1.7.0

3) Add the ant bin to the PATH environment variable, i.e. %ANT_HOME%bin or $ANT_HOMEbin

4) You should now be able to test ant by running ant -version

JAVA ON MAC OS X TIPS

The latest Mac OS X now has Java 1.6 included, but it is not enabled by default.

2) Java on the Mac OS X is installed into the directory:

/System/Library/Frameworks/JavaVM.framework/Versions

From there you need to specify the version you want to use.

3) The Java binaries are in the Commands directory, instead of the usual bin directory. This breaks a lot of scripts. A simple fix is to cd to the Java home directory and run:

sudo ln -s Commands bin

sudo causes the command to be run with root permissions. ln -s creates a soft link from Commands to bin.

You can then modify the <a href=”http://setup.sh/”>setup.sh</a> script to point to the version of Java you want. Here is my file.

WINDOWS SETUP TIPS

The first tip for setting up Windows would be simply don’t! Move to another platform such as Ubuntu or Mac OS X if at all possible, it makes development so much easier!

1) Setting environment variables on Windows:

a. Right click on my computer or go to control panel and select system.

b. On the dialog box select the advance tab and then select environment variables.

c. Add a new environment variable

d. For example on my machine JAVA_HOME= C:appsjdk1.5.0_07

e. You can reference other environment variables using %NAME%. For example to add the Java bin directory related to the JAVA_HOME environment variable to PATH, you would add – %JAVA_HOME%bin to the FIRST of the PATH environment variable.

2) For Windows I recommend using Cygwin which provides a Linux-Like environment.

a. Download Cygwin and run the installer.

b. When you install cygwin you can change the view in the upper right from packages to full. Some optional packages that are worth installing are:

Subversion

OpenSSH

Ryan Knight flex