<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>byte bohemian &#187; Maven</title>
	<atom:link href="http://nicl.net/category/technology/maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://nicl.net</link>
	<description></description>
	<lastBuildDate>Sat, 15 May 2010 20:51:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Contemporary Software Development: Building</title>
		<link>http://nicl.net/2010/05/contemporary-software-development-building/</link>
		<comments>http://nicl.net/2010/05/contemporary-software-development-building/#comments</comments>
		<pubDate>Sat, 15 May 2010 20:51:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Agile software development]]></category>
		<category><![CDATA[Ant]]></category>
		<category><![CDATA[Buildr]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[SCM]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=68</guid>
		<description><![CDATA[The subject of my first post of the series "Contemporary Software Development" will be building. How to build your software project is a decision which is made quite early when you start developing.
Unfortunately in a lot of projects this very important topic does not get the appreciation it deserves. On one hand side it's a [...]]]></description>
			<content:encoded><![CDATA[<p>The subject of my first post of the series "Contemporary Software Development" will be building. How to build your software project is a decision which is made quite early when you start developing.</p>
<p>Unfortunately in a lot of projects this very important topic does not get the appreciation it deserves. On one hand side it's a very sad story of suffering and endurance. On the other hand side we are talking about a lot of wasted money.<span id="more-68"></span>In my career as software engineer I experienced some different approaches to the project setup and the build process.</p>
<p>It started with something like <code>find . -name '*.java' | xargs javac</code>, which worked quite well for the first weeks of my professional career. But with a couple of software developer working on a project <em>you want something more standardized.</em></p>
<p>So we went on with <code>make</code><a href="http://www.gnu.org/software/make/">(*)</a>. I guess most of the software engineers will know this build tool which still is a standard tool in the Unix/Linux world. <code>make</code> is a very powerful tools but has its peculiarities also. The <code>make</code> grammar is very delicate when it comes to white spaces. I quess quite a few people sat over a broken <code>make</code> build when a <code>TAB</code> char wasted your build script.</p>
<p>In the Java world <a href="http://ant.apache.org/">Apache Ant</a> was the successor to <code>make</code> in my career. The problem with <code>make</code> and the Java world is, that make is not really platform independent. There are <code>make</code> ports for Microsoft Windows but (at least when I made the jump from <code>make</code> to Ant) it does not work very well. So if you have a heterogeneous environment e.g. you develop on Microsoft Windows and you deploy into a Linux based cloud, <em>you want your build to to be platform independent.</em></p>
<p>A nice story about platform independence. I did some consulting in a project for the Deutsche Bank Italy and a very large (and expensive) consulting company provided the BEA Weblogic build and setup. I am not 100% sure but I guess it was an <a href="http://ant.apache.org/">Apache Ant</a> based build. One major issue was the application server integration integration. To solve it, the complete project was placed and build in the application server which was committed in to the CVS source control management system. The delivery artifact was - of course - delivered without the application server. But this leads to another wish I have when I am using a build. <em>You want the build to credit the current  environment.</em> If you are building for your local development environment you may have different requirements concerning the built artifact as when you are creating an artifact that will be deployed on staging or productive environment.</p>
<p>Back on memory lane: <a href="http://ant.apache.org/">Apache Ant</a> worked pretty well for some years and a couple of projects. But one thing that started to annoy me. Every project was using a slightly build setup so in the daily business there were always searching for artifacts or checking library versions.</p>
<p>Some former colleagues introduced me to <a href="http://maven.apache.org/">Apache Maven</a>. I started with <a href="http://maven.apache.org/maven-1.x/index.html">Maven 1</a> which is a quite interesting mixture of <a href="http://ant.apache.org/">Ant</a> with a framework that offered the possibility to manipulate the Ant build file during the runtime. But <a href="http://maven.apache.org/">Apache Maven</a> had some features which I hat to get used to.<br />
An example is the rigid directory structure defined in a Maven build: Why do I have to follow them? I want my special directory names! But nowadays I love this structure which is equal in every project. You find your files so fast now and even in foreign project. That's another thing that you want: <em>You want your builds to follow standards, so you can get familiar with the project in very short time.</em> If you are working in the software business a couple of years, may have already realized that you will see very much projects during a professional career and standard projects and processes will make your life much more easy.</p>
<p>Let's talk about some goodies now which modern build system offer. I will use <a href="http://maven.apache.org/">Apache Maven</a> as example but other systems like <a href="http://rake.rubyforge.org/">rake</a> or <a hef="http://buildr.apache.org/">buildr</a> offer similar functions.</p>
<p>One thing I love/hate is dependency management. When I started with make or ant, we where committing all libraries into our CVS. Which worked quite well, in most cases you could check our the project, performed the initial build and started to work. But there where lots of minor but very nasty problems. Starting from which library version is really used to incompatibilities of the build tool version. </p>
<p>With the <a href="http://maven.apache.org/">Apache Maven</a> dependency resolution mechanism a new area begun. If you are having one independent project the mechanism is pretty easy to use. You define the libraries you want to use in your <code>pom.xml</code> and maven takes care of the rest. Okay if you want to use libraries which are not in the maven central repository it's a little more complicated <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>If you are having a multi module/project environment things will get messy pretty easy, but: They would also if you don't use the dependency management mechanism. You ask why? When you don't use this mechanism you'll normally have a huge monolithic project in your SCM system which will get even more difficult to manage or build. So you <em>want to have a transparent dependency management in your build system</em>. With <a href="http://ant.apache.org/ivy/">Ivy</a> for example you'll have an add-on which offers the possibility to have an dependency management when you are using <a href="http://ant.apache.org/">Ant</a>.</p>
<p>Another goodie is release management. It's very handy if you start a build to create your release artifact and your tag (or something similar) in the SCM system of your choice. <em>You want your release process embedded in your build system, so you can perform the build when you are creating your release.</em></p>
<p>Another important topic is testing. You <em>really want your build tool to support your testing facilities.</em> At least when you create your release or deployment artifact you want your build to automatically run your test suite.</p>
<p>I have only one topic left in this post, that is IDE support. Unfortunately most modern IDE like <a href="http://www.eclipse.org/">Eclipe</a>, <a href="http://netbeans.org/">Netbeans</a> or <a href="http://www.jetbrains.com/idea/">Intellij IDEA</a> offer a IDE specific build. This this very comfortable if you have a small project and what to deal only with your IDE. But you'll grow really beyond this (my experience). But integration into other build tools is sometimes really poor. So you have to check how you can bridge the gap between your IDE and the build tool. E.g. the maven directory structure troubles some IDE<br />
standard configurations. Fortunatly more and more projects provide solutions for this.</p>
<p>So let's have a quick resume. This is what you should want in your build system:</p>
<ul>
<li>standardized process</li>
<li>platform indipendence (if your need it)</li>
<li>credit current environment</li>
<li>standardized structures</li>
<li>dependency management</li>
<li>embeddable release process (including SCM support)</li>
<li>support of your test tools</li>
<li>IDE support</li>
</ul>
<p>I think this list is not too lang and offers some major improvements for your daily work. So if your build process is missing some items from this list, you maybe should think about your build process. And remember: Your development resources are far to valuable to be wasted in an inefficient build process <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2010/05/contemporary-software-development-building/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Temporal coincidence or news on maven builds</title>
		<link>http://nicl.net/2009/11/temporal-coincidence-or-news-on-maven-builds/</link>
		<comments>http://nicl.net/2009/11/temporal-coincidence-or-news-on-maven-builds/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 21:31:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=51</guid>
		<description><![CDATA[A few weeks ago I wrote a blog entry about building applications with Apache Maven and where I see the most demanding problems with Maven builds.
Coincidentally Jason van Zyl a mastermind behind the Apache Maven Project wrote a series of articles on the  blog at Sonartype, which are describing the future road map of [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I wrote a <a href="/2009/11/some-thoughts-about-building/">blog entry</a> about building applications with <a href="http://maven.apache.org">Apache Maven</a> and where I see the most demanding problems with Maven builds.</p>
<p>Coincidentally <a href="http://twitter.com/jvanzyl">Jason van Zyl</a> a mastermind behind the <a href="http://maven.apache.org">Apache Maven</a> Project wrote a series of articles on the  <a href="http://www.sonatype.com/people/author/jason/">blog</a> at <a href="http://www.sonatype.com">Sonartype</a>, which are describing the future road map of Maven 3.0.</p>
<p><span id="more-51"></span>It was quite funny: On the friday after I wrote my article I had a discussion on the lunch break with a <a href="https://www.xing.com/profile/Bjorn_Stachmann">colleague</a> just about this topic. On sunday evening I stumbled accidentally across the first article from <a href="http://twitter.com/jvanzyl">Jason van Zyl</a> with the title <a href="http://www.sonatype.com/people/2009/11/maven-3x-paving-the-desire-lines-part-one-2/">"Maven 3.x: Paving the desire lines — Part One"</a>. In this article Jason describes how the Maven development team tried to figure which way to go with Maven 3.0. Besides the fascinating informations the article is also fun to read, very nice. A few days later the <a href="http://www.sonatype.com/people/2009/11/maven-3x-paving-the-desire-lines-part-two/">second part</a> was published. Which was great, too.</p>
<p>After reading these articles I was some kind of reconciled and excited about the future of Maven. But I had also a lot of work to do to prepare the new Release of <a href="http://www.scoyo.de">scoyo</a>. So the only thing I could to was to add the Sonartype blog to my RSS reader.</p>
<p>So it happens that I didn't miss the <a href="http://www.sonatype.com/people/2009/11/maven-30-alpha-3-released/">announcement of the first public alpha version</a> of Maven 3.0. I had not enough time so far to check it out, but I will follow the events eagerly.</p>
<p>So sometimes things happen parallel and my complaints about building and Maven came along with the start of the 3.0 series of the <a href="http://maven.apache.org">Apache Maven</a> project.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/11/temporal-coincidence-or-news-on-maven-builds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some thoughts  about building</title>
		<link>http://nicl.net/2009/11/some-thoughts-about-building/</link>
		<comments>http://nicl.net/2009/11/some-thoughts-about-building/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 13:31:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Agile software development]]></category>
		<category><![CDATA[Flex-mojo]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://nicl.net/?p=49</guid>
		<description><![CDATA[Over the last few days I had some thoughts about building your project. I am using Apache Maven for quite a while now. At my current employer we use Maven for all our components even our learn portal which is build entirely in Adobe Flex, using the Flexmojos.
The bottom line is that we have approximately [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last few days I had some thoughts about building your project. I am using <a href="http://maven.apache.org">Apache Maven</a> for quite a while now. At my <a href="http://www.scoyo.de">current employer</a> we use Maven for all our components even our learn portal which is build entirely in <a href="http://www.adobe.com/products/flex/">Adobe Flex</a>, using the <a href="http://flexmojos.sonatype.org/">Flexmojos</a>.</p>
<p>The bottom line is that we have approximately 100 projects build with maven to build our entire platform. You don't need much imagination that we have a couple of challenges to meet.<span id="more-49"></span>I started with <a href="http://maven.apache.org/maven-1.x/index.html">Maven 1</a> which was a astonishing mixture of <a href="http://ant.apache.org/">Apache Ant</a> and <a href="http://ant.apache.org/">Jelly</a>. But I never really liked the idea of executable XML. In my opinion XML is not a good programming language at all but this would be a blog posting of its own <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Back to to the builds. A couple of days ago a read some <a href="https://twitter.com/hlship/status/5408252622">tweets</a> from the <a href="https://twitter.com/hlship">the man behind tapestry</a> to remind me about <a href="http://buildr.apache.org/">Apache Buildr</a>. This lead to rethink some experiences I made with <a href="http://maven.apache.org">Maven2</a> in the last couple of month...</p>
<p>This lead to certain discoveries what I started to really dislike on Maven2:</p>
<ol>
<li><i>The XML</i> - The <code>pom.xml</code> which defines the central project object model os getting really cluttered. When you have a small project there is almost no problem but if you have an enterprise scale project (almost evereything after an example project) the <code>pom.xml</code> is getting huge and you don't find the things you need.
<p>Okay, there are "helpers" to maintain the <code>pom.xml</code>, but e.g. if you use <a href="http://www.eclipse.org">Eclipse</a> with a POM file the XML editor starts to parse it. If the file is no very small - even a small open source project like <a href="http://jaev.googlecode.com">jaev</a> has an approx. 140 lines <code>pom.xml</code> - it'll make Eclipse somewhat slow. If you use the <a href="http://m2eclipse.sonatype.org/">m2eclipse</a> plugin it will get even worse. The <a href="http://m2eclipse.sonatype.org/">m2eclipse</a> offers some very nice tools for POM handling and it got really good compared to the early versions. But I know a couple of guys who refuse to use it because of the negative impact on your development environment.
</li>
<li><i>Reuse by inheritance</i> - The only way (so far I know <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ) to reuse settings in Maven2 is POM inheritance. This works like prototypic inheritance (like in Javascript). You may define prototypic plugin settings in the parent POM and all POMs which inherit from this parent POM will use this settings as a default.
<p>So far so good, but in most object oriented programming languages inheritance to reuse code is considered to be a bad design pattern. In Maven2 you may stumble across the same bad issues as e.g. in Java when you use the POM inheritance. As a matter of fact you may only inherit from one parent POM, so your inheritance tree will get cluttered with settings and overrides.
</li>
<li><i>Insufficient version and dependency management</i> - The dependency management is one of Maven2 strongpoints, no doubt about it. But if you really start to use it you'll get to it's limits very fast.
<p>I guess Maven2 did some awesome pioneer work to version handling. Due to the fact that every artifact has a version number. Unfortunately the version numbers in Maven do not have an ordinal structure and admits special indicators like <code>SNAPSHOT</code>, <code>alpha</code> or <code>LATEST</code> which are adding a whole new level of complexity. So maven can't tell if a version is greater than another version, e.g. is <code>1.4-SNAPSHOT</code> greater than <code>1.4</code>?. This is very problematic when use version ranges and transitive dependencies. When you'll get a dependency from different sources (e.g. the commmons-lang library) there is always some magic involved which version you'll get. This leads to next next issue:
</li>
<li><i>The build does not break early enough.</i> - Maven2 tries to be very clever in some situations like the dependency resolution. If a problem occurs maybe a log message will be provided but the build will continue even if you have contradictory dependency declarations. So the only "hint" you'll get, if the dependency tree is faulty, are compile errors if you're lucky. If you have runtime dependencies you'll get some funny effects in your application
</li>
<li><i>No separation of concerns.</i> - The POM includes all concerns of a build like:
<ul>
<li>Dependency management</li>
<li>Compiling</li>
<li>Tesing</li>
<li>Packaging</li>
<li>Reporting</li>
<li>Deployment</li>
</ul>
<p>You'll have different sections in the <code>pom.xml</code> like <code>&lt;build/&gt;</code>,  <code>&lt;dependencies/&gt;</code>, <code>&lt;profiles/&gt;</code> or  <code>&lt;reporting/&gt;</code> which group the declarations a little bit. But if you take a closer look at the <code>&lt;build/&gt;</code> section you'll soon realize that it works quite different that e.g. the <code>&lt;dependencies/&gt;</code> section. In the <code>&lt;build/&gt;</code> you are more on a programming level to specify the compile and packaging issues of your build. The <code>&lt;dependencies/&gt;</code> is only declarative.</li>
<li><i>Only one file</i> - To make the lack of separation more painful you are not able to break the different concerns into separate files. There are some Maven plugins which use other files like the assembly plugin, but this an exception. It would be really nice if out could include files into your <code>pom.xml</code>. This really could have positive effects on the inheritance issue too.
</li>
</ol>
<p>Okay to straighten this a little bit. I guess the Apache Maven did some of the most innovative work on the build sector in the last few years. And I don't  consider to switch to <code>make</code> or <a href="http://ant.apache.org/">Apache Ant</a>. It makes many things a lot easier and most of my critique may be corrected in further versions <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  I already had a peek into the Maven3 source code and I'll guess the Maven/<a href="http://www.sonatype.com/">Sonartype</a> guys will level some of this issues. I 'am very curious about Maven3 and I hope it will ease some of my pain related to the Version 2 of Maven.</p>
<p>So, it was great to get some thoughts clear about what is important when you build a project and what are the different facets when you use a build tool. I had a first look on <a href="http://buildr.apache.org/">Apache Buildr</a> maybe I get enough stuff together to create a blog entry about it ...</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/11/some-thoughts-about-building/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven and Flex hoodoo</title>
		<link>http://nicl.net/2009/05/maven-and-flex-hoodoo/</link>
		<comments>http://nicl.net/2009/05/maven-and-flex-hoodoo/#comments</comments>
		<pubDate>Fri, 15 May 2009 16:11:56 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Flex-mojo]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://87.106.3.237/?p=33</guid>
		<description><![CDATA[
The last time when I blogged about the Flex mojos I was still quite frustrated and thought I had a better solution. Now some time passed and on April the 3rd the new version (3.1) of the flex mojos was released and me and some of my colleges made some interesting discoveries.


The last time when [...]]]></description>
			<content:encoded><![CDATA[<p>
The last time <a href="/2009/03/mavenizing-a-flex-build/">when I blogged about the Flex mojos</a> I was still quite frustrated and thought I had a better solution. Now some time passed and on April the 3rd the <a href="http://flex-mojos.info/2009/04/03/ann-flexmojos-31-released/">new version (3.1) of the flex mojos was released</a> and me and some of my colleges made some interesting discoveries.</p>
<p><span id="more-33"></span>
<p>
The last time <a href="/2009/03/mavenizing-a-flex-build/">when I blogged about the Flex mojos</a> I was still quite frustrated and thought I had a better solution. Now some time passed and on April the 3rd the <a href="http://flex-mojos.info/2009/04/03/ann-flexmojos-31-released/">new version (3.1) of the flex mojos was released</a> and me and some of my colleges made some interesting discoveries.</p>
<p>
Well, but in the last few weeks I often thought about the meaning and the source of the word mojo. Lets take a closer look at <a href="http://en.wikipedia.org/wiki/Mojo_(African_American_culture)">wikipedia.</a></p>
<blockquote cite="http://de.selfhtml.org/">
<p>
Mojo (pronounced /ˈmoʊdʒoʊ/) is a term commonly encountered in the African-American folk belief called hoodoo. A mojo is a type of magic charm, often of red flannel cloth and tied with a drawstring, containing botanical, zoological, and/or mineral curios, petition papers, and the like. It is typically worn under clothing.</p>
</blockquote>
<p>Okay, hoodoo! That explains quite a lot. Sometimes maven and the flex-mojos are a kind of magic.
</p>
<p>
But let's get back on topic <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  The boys from the Flex mojos where quite busy and created with the 3.x release very usable platform for flex builds in the maven world. It took us (mainly a <a href="http://www.peter-jacobsen.de/">freelance colleague</a>) two more weeks to adapt our build process form various ant scripts into a multi-module maven2 build. But now it looks quite nice, the build is even faster and we were able to fix a problem with our Flex Builder configuration.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/05/maven-and-flex-hoodoo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mavenizing a Flex build</title>
		<link>http://nicl.net/2009/03/mavenizing-a-flex-build/</link>
		<comments>http://nicl.net/2009/03/mavenizing-a-flex-build/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 12:54:51 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Flex-mojo]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://nicl.net/2009/03/21/mavenizing-a-flex-build/</guid>
		<description><![CDATA[In the last week the release 1.0 platform release of scoyo came close and we were tying up some loose ends. One of these ends was the integration of the scoyo Flash/Flex portal build process  into the platform build process.
The platform build process is realized with Apache Maven, which is, in humble my opinion, [...]]]></description>
			<content:encoded><![CDATA[<p>In the last week the release 1.0 platform release of <a href"http://www.scoyo.de">scoyo</a> came close and we were tying up some loose ends. One of these ends was the integration of the scoyo Flash/Flex portal build process  into the platform build process.</p>
<p>The platform build process is realized with <a href="http://maven.apache.org">Apache Maven</a>, which is, in humble my opinion, still the first choice for <a href="http://java.sun.com">Java</a> based software projects, but integrating other project types into maven is a kind of challenging due to the nature of Maven. You may summarize this in: If you do it the maven way it's very easy, if you don't it is up to you ...</p>
<p>Luckily there was already an existing build with <a href="http://ant.apache.org">Ant</a> and a dysfunctional Maven variant with the Maven <a href="http://code.google.com/p/flex-mojos/">Flex-mojos</a> plugin. So it stated  my journey to insanity an back ...<br />
<span id="more-22"></span><br />
In the last week the release 1.0 platform release of <a href"http://www.scoyo.de">scoyo</a> came close and we were tying up some loose ends. One of these ends was the integration of the scoyo Flash/Flex portal build process  into the platform build process.</p>
<p>The platform build process is realized with <a href="http://maven.apache.org">Apache Maven</a>, which is, in humble my opinion, still the first choice for <a href="http://java.sun.com">Java</a> based software projects, but integrating other project types into maven is a kind of challenging due to the nature of Maven. You may summarize this in: If you do it the maven way it's very easy, if you don't it is up to you ...</p>
<p>Luckily there was already an existing build with <a href="http://ant.apache.org">Ant</a> and a dysfunctional Maven variant with the Maven <a href="http://code.google.com/p/flex-mojos/">Flex-mojos</a> plugin. So it stated  my journey to insanity an back.</p>
<p>My first attempts started  with reactivating the Flex-mojos maven build. I already had some experience with Flex-mojos when preparing the build for the <a href="http://jaev.googlecode.com">jaev</a> Flex example. This example Project for the <a href="http://jaev.googlecode.com">jaev</a> framework also uses the Flex-mojos maven plugin to create the example <code>.swf</code> and uses the infrastructure of maven to assemble the web application with the HTML and the <a href="http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/">BlazeDS</a> services. Took me some time and a quite nice <a href="http://sebastien-arbogast.com/2008/04/10/flex-spring-and-blazeds-the-full-stack/">tutorial</a> from <a href="http://sebastien-arbogast.com/">Sébastien Arbogast</a> but finally it worked!</p>
<p>So I thought I was prepared for the task and nothing could stop me. There is no law against being wrong, at least in Germany <code> <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </code>.</p>
<p>The main problems was finding all the required libraries in various maven repositories. Additionally there were some foul libraries. Some yahoo uploaded HTML files as <code>.pom</code> and <code>.jar</code> file in a repository. It took me quite a moment to realize this. Unfortunately the current <a href="http://www.adobe.com/products/flex/flexdownloads/">Flex SDK 3.3</a> was not available at all in any maven repository. At least I did not find any.</p>
<p>So after wasting some hours I changed the strategy: My new Idea was to call the Flex <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html">Ant tasks</a> provided by <a href="http://www.adobe.com">Adobe</a> from the maven build using the <a href="http://maven.apache.org/plugins/maven-antrun-plugin/">maven-antrun-plugin</a>. The antrun-plugin is quite nice if you have to perform some tasks not covered by maven. So you can execute some <a href="http://ant.apache.org">Ant</a><a> tasks to enrich your build.</p>
<p>But things where going to be worse. A couple of very "unsatisfying" hours later I discovered a bug or incompatibility of the maven </a><a href="http://maven.apache.org/plugins/maven-antrun-plugin/">maven-antrun-plugin</a> and the Adobe <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html">Ant tasks</a>. So it was time to rethink my strategy again. Should I switch back to the Flex-mojo approach? I went for a minor adjustment first: Instead of using the the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html">Ant tasks</a> I went for the compilers (<code>mxmlc</code> for Flex applications and <code>compc</code> for Flex libraries) directly. Calling them with the Ant <a href="http://ant.apache.org/manual/CoreTasks/exec.html"><code>&lt;exec /&gt;</code></a> task, which executes a command on the command line. Then use the <a href="http://maven.apache.org/plugins/maven-assembly-plugin/">maven-assembly-plugin</a> to create a ZIP file of the compiled artifact and install/deploy it into the repository.</p>
<p>Let's sum this up:
<ol>
<li>start JVM and execute maven</li>
<li>execute the maven-antrun-plugin to execute ant tasks</li>
<li>use some Ant tasks to assemble the Flex build path (external and included libraries)</li>
<li>use the Ant <code>&lt;exec /&gt;</code> task to execute the flex compiler (let's share a secret: The Flex compilers are written in Java. Welcome back home <code> <img src='http://nicl.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </code>)</li>
<li>use the maven-assembly-plugin</li>
<p> to create a ZIP file</p>
<li>install the ZIP file into the local repository</li>
<li>(optionally deploy the artifact into a remote repository)</li>
</ol>
<p>That does not sound like a simple build process. And let me amend something: If you a using shared libraries in the build (yepp we have a couple of them) you may add another step before invoking the maven-antrun plugin. You'll have to use the maven dependency plugin to copy and uncompress the libraries from the local (remote) repository to your build environment, so they can be accessed/found by the build. You'll imagine I was not satisfied at all with this build variant ...</p>
<p>Again my old friend came along, the question:"What to do?"</p>
<p>The Flex-mojo approach obliged my to upload the whole Flex SDK into our local <a href="http://archiva.apache.org/">archiva</a> installation which hosts out company maven repository. This includes the minimum 54 libraries supplied by the Flex SDK. Okay most of them are quite common, but when a new Flex SDK is released (which happens on a quite regular basis) you'll have to recheck all dependencies. No thanks ...<br />
The maven/Ant/Flex compiler variant emerged as juggernaut with bad performance and a loads of catches. No improvement at all ...</p>
<p>So I decided to take a closer look at the Flex-mojo plugin itself. Why do I need to have all this dependencies? The major advantages to the Flex-mojo plugin are the special packaging types <code>swf</code> and <code>swc</code> for Flash movies and libraries. Using this packaging types maven will use a special life cycle and offer the possibility to install/deploy the artifacts directly into the repository. To my relief only a <a href="http://svn.sonatype.org/flexmojos/trunk/flexmojos-maven-plugin/src/main/resources/META-INF/plexus/components.xml">quite simple XML file</a> (a plexus component definition) was necessary to achieve this.</p>
<p>So desperate as I was, I decided to write a maven plugin on my own. I must confess it was not my first time. I already wrote a simple maven plugin for the <a href="http://www.sinnerschrader.de">SinnerSchrader commerce framework</a>, a library developed by my former employer. I really do not like to reinvent software on my own. But I was curious and I want to give it a shot. My goal was to combine the two approaches I tried before and use the best of both. So the plugin should be able to manage the <code>swc</code> dependencies, the flex compiler configuration (via <code>-load-config</code>) and the direct deployment of <code>swc</code> and <code>swf</code> artifacts.</p>
<p>The approach was simple:
<ol>
<li>check the maven dependencies for libraries to reference or to include</li>
<li>check for a configured compiler configuration</li>
<li>create the compiler command line and all options like <code>-load-config</code>, <code>-compile.debug</code>, <code>-compiler.include-libraries</code> or <code>-compiler.external-library-path</code>, etc. </li>
<li>invoke the compiler via the<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ProcessBuilder.html"><code>java.lang.ProcessBuilder</code></a></li>
<li>install the artifact into the local repository</li>
</ol>
<p>It took me not an hour to build a working proof of concept and only approx. four more hours to mavenize almost the entire build. This was really fun after two days of trying and failing. There are still some minor adjustments to make on monday, but I am really looking forward to finish the build. And if all works out as I want, there might be a 15-20% speed improvements for a complete build. But this also reduces the necessity to perform complete builds, because some shared libraries are rarely changing at all, so we can deploy them into our company maven repository.</p>
<p>As I went to bed last night, I was wondering why the Flex-mojo approach failed and the home-grown maven plugin approach succeeded. Under the shower this morning it was quite obvious to me. The Flex-mojo plugin stores the whole Flex SDK in maven repositories, so you don't even have to download the Flex SDK to compile your Flex application. My home-grown plugin needs the Flex SDK installed on the build computer and the <code>FLEX_HOME</code> environment variable set. But that is okay, because the <a href="http://maven.apache.org/plugins/maven-compiler-plugin/">maven-compiler-plugin</a> does the same. It does not work without the <code>JAVA_HOME</code> set and it does not try to deploy the Java SDK into maven repositories. Maybe the Flex-mojo guys will also realize the difference. It seems to be a quite nice piece of software but with too much unnecessary complexity and very "clustered" documentation.</p>
<p>After tying up this loose end me and a very experienced Flex development colleague already discovered some further TODOs relating to the maven and <a href="http://www.adobe.com/products/flex/features/flex_builder">Flex Builder</a> integration. There is still lots of work to do, so I am exited. My <a href="http://www.scoyo.de">new job</a> is different as I expected but a am very confident that it will offer some exiting further challenges for me ...</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2009/03/mavenizing-a-flex-build/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
