Maven with Flex

Post on 13-May-2015

2,844 views 0 download

Tags:

transcript

Maven, a Yiddish word meaning accumulator of knowledge.

Maven is a tool that provides an uniform and easy build process for your projects› you describe your project in one xml file

and Maven reads this information to compile and package your project.

Maven essentially is Project Management and comprehension tool allows you to do,› Continuous Integration› Builds› Testing› Dependencies› Documentation› Distribution › Reporting etc..

It comes with default templates that are Widely adopted as the best practices

Convention over configuration Get everything on-demand from their

repositories› All the plugins required for your build are

taken from a common repository and put into your local repository

The basic concept of Maven is a project Any directory that has a project.xml in it is

a project. Another concept in Maven is that of a repository

The repository holds the artifacts (a jar, swf, swc, war, pom etc) on which your project depends. There are two kinds of repository: local and remote

The local repository is created in a special directory called ".maven/repository". In Windows, this directory is created in C:\Documents And Settings\<username>\.m2

Instead of each project having its own copies of third party libraries, the repository helps developers across projects to share the libraries.

Each project can also in turn generate its artifacts and publish it into the remote repository. The process of publishing a jar into the repository is called "install" in Maven lingo.

The project.xml is divided into four main parts namely› Project Management Section.› Project Dependency Section.› Project Build Section› Project Reports Section.

Has general information on the organization, its web site, project web site, location of SCM, deployment and issue tracking site, developer list, mailing lists to name a few.

Describes the location of source, test and resource files

The target audience of the reports can vary from other developers in the same project to sponsors, stakeholders or users from other projects

Key to every project For eg. If you want your Junit Test cases

to run you need a junit “jar” file. For this you need to specify a <dependency> tag, that describes your artifact.

Let build a flex project which uses› Cairngorm› BlazeDS› Locale for Internationalization

Install Cairngorm SWC into our local repository (Optional). If it (Maven repository) does not find it in their remote repository

mvn install:install-file –Dfile=Cairngorm.swc –Dpackaging=swc –Dversion=2.2.1 –DgroupId=com.adobe.cairngorm -DartifactId=cairngorm

mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.companyname.module -DartifactId=modulename-DpackageName=com.companyname.module -Dversion=1.0

mvn archetype:create -DarchetypeArtifactId=maven-archetype-flex -DarchetypeVersion=1.0 -DarchetypeGroupId=dk.jacobve.maven.archetypes -DgroupId=com.companyname.module -DartifactId=moduleFlex -DpackageName=com.companyname.module –Dversion=1.0

This would generate the war and the contents would be copied from the flex application

mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=com.companyname.module -DartifactId=moduleWeb -DpackageName=com.companyname.module -Dversion=1.0

Copy the following <project

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion><groupId>com.companyname.module</groupId><artifactId>module</artifactId><packaging>pom</packaging><version>1.0</version><name>module</name><url>http://maven.apache.org</url><modules><module>../moduleFlex</module><module>../moduleWeb</module></module>

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.companyname.module</groupId> <artifactId>moduleFlex</artifactId> <packaging>swf</packaging> <version>1.0-SNAPSHOT</version> <name>multiModuleProjectArtifactIdFlex Maven Flex</name> <url>http://maven.apache.org</url> − <properties> − <flex.home>${env.FLEX_HOME} </flex.home> </properties> − <build> <sourceDirectory>src/main/flex</sourceDirectory> − <plugins> − <plugin> <groupId>net.israfil.mojo</groupId> <artifactId>maven-flex2-plugin</artifactId> <extensions>true</extensions> − <configuration> <flexHome>${flex.home}</flexHome> <useNetwork>true</useNetwork> <main>Main.mxml</main> <!-- For including the locale folder into our application --> <extraParameters> <parameter> <name>compiler.source-path</name> <values> <value>${basedir}/locale</value> </values> </parameter> </extraParameters> </configuration> </plugin> </plugins> <defaultGoal>install</defaultGoal> </build> </project>

Go to your Parent module project Open cmd and go to the parent project

folder› Mvn install› Should copy the details and you should

have your first flex application build with

Hope you find this information helpful Comment/Contact me on

priyankomnipotent@gmail.com Download Maven 2 from

http://maven.apache.org/download.html For basics on Maven read

› http://www.theserverside.com/tt/articles/article.tss?l=MavenMagic