<?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>Jayway Team Blog &#187; maven</title>
	<atom:link href="http://blog.jayway.com/tag/maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayway.com</link>
	<description>Sharing Experience</description>
	<lastBuildDate>Sat, 11 Feb 2012 10:33:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How you list the available goals for a maven plugin</title>
		<link>http://blog.jayway.com/2012/02/11/how-you-list-the-available-goals-for-a-maven-plugin/</link>
		<comments>http://blog.jayway.com/2012/02/11/how-you-list-the-available-goals-for-a-maven-plugin/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 10:18:47 +0000</pubDate>
		<dc:creator>Tobias Södergren</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[goals]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=11976</guid>
		<description><![CDATA[I've been attending an excellent lab by Sune Simonsen which was about how to create a Javascript twitter client. The lab utilizes the maven-lab-plugin, which can be used to create step-by-step labs using Maven. During the lab, i wanted to know which step I was at and I figured that there should be a goal [...]]]></description>
			<content:encoded><![CDATA[<p>I've been attending an excellent lab by <a href="https://twitter.com/#!/sunesimonsen">Sune Simonsen</a> which was about how to create a Javascript twitter client.</p>
<p/>
The lab utilizes the <a href="https://github.com/jayway/maven-lab-plugin">maven-lab-plugin</a>, which can be used to create step-by-step labs using Maven.</p>
<p/>
During the lab, i wanted to know which step I was at and I figured that there should be a goal for that. To list the available goals for a maven plugin you can use the goal <code>help:describe</code> like this:</p>
<pre>
  $ maven help:describe -DgroupId=com.jayway.maven.plugins.lab -DartifactId=maven-lab-plugin
</pre>
<p>This will give you an output like:</p>
<pre>
Name: maven-lab-plugin Maven Mojo
Description: Maven plugin used to create labs that provide more code once a
  step has been completed. Labs are a useful way to learn new technologies,
  frameworks and tools.
Group Id: com.jayway.maven.plugins.lab
Artifact Id: maven-lab-plugin
Version: 1.0.0.RELEASE
Goal Prefix: lab

This plugin has 7 goals:

lab:create
  Description: Goal to chunkify

lab:currentStep
  Description: Get the current step no

lab:findMax
  Description: Goal to find the max version

lab:init
  Description: Goal to create and initialize a lab.

lab:next
  Description: Change to next step

lab:reset
  Description: Goal to create and initialize a lab.

lab:setStep
  Description: Change version to versionNo

For more information, run 'mvn help:describe [...] -Ddetail'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2012/02/11/how-you-list-the-available-goals-for-a-maven-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create &#8216;native&#8217; Java applications on OS X and Windows using Maven plugins</title>
		<link>http://blog.jayway.com/2011/08/15/create-native-java-applications-on-os-x-and-windows-using-maven-plugins/</link>
		<comments>http://blog.jayway.com/2011/08/15/create-native-java-applications-on-os-x-and-windows-using-maven-plugins/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 09:07:21 +0000</pubDate>
		<dc:creator>Tobias Södergren</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[native]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=9190</guid>
		<description><![CDATA[When building a desktop application, the target audience usually expects an executable to when launching it. If the application is written in Java you have the options to create a batch file to launch it, create an executable jar file, compile the application as a native application or wrap the application using a native 'launcher'. [...]]]></description>
			<content:encoded><![CDATA[<p>When building a desktop application, the target audience usually expects an executable to when launching it. If the application is written in Java you have the options to create a batch file to launch it, create an executable jar file, compile the application as a native application or wrap the application using a native 'launcher'. This post will result in a maven pom for dealing with the last option, it may be used in both Windows and OS X environments.</p>
<p>The pom is configured to use two different plugins depending on which operating system that is executing it.<br />
On Windows, a <a href="http://launch4j.sourceforge.net/">Launch4j</a> project <a href="http://alakai.org/reference/plugins/launch4j-plugin-usage.html">plugin</a> will be used. On OS X the <a href="http://mojo.codehaus.org/osxappbundle-maven-plugin/">osxappbundle</a> plugin is used, which creates an OS X application directory structure and uses the JavaApplicationStub binary for launching the application.</p>
<p>The <code>&lt;profile&gt;</code> tag is used for deciding which plugin to use depending on operating system.</p>
<p>The pom also points out different application icons for the binaries, OS X requires the icon to be in the <a href="http://en.wikipedia.org/wiki/Apple_Icon_Image_format">icns</a> and windows in the <a href="http://en.wikipedia.org/wiki/ICO_(file_format)">ico</a> format.</p>
<p>The wrapped application has a main class in the file <code>com.jayway.wrappedapplication.Launcher</code></p>
<h2>The pom.xml</h2>
<pre class="brush:xml">
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
  <modelversion>4.0.0</modelversion>
  <groupid>com.jayway.wrappedapplication</groupid>
  <artifactid>launcher</artifactid>
<packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>launcher</name>
  <url>http://maven.apache.org</url>
<profiles>
<profile>
      <id>windows-deploy</id>
      <activation>
        <os>
          <family>Windows</family>
        </os>
      </activation>
      <build>
<plugins>
<plugin>
            <groupid>org.bluestemsoftware.open.maven.plugin</groupid>
            <artifactid>launch4j-plugin</artifactid>
            <version>1.5.0.0</version>
            <executions>
              <execution>
                <id>launch4j</id>
<phase>verify</phase>
                <goals>
                  <goal>launch4j</goal>
                </goals>
                <configuration>
                  <dontwrapjar>false</dontwrapjar>
<headertype>gui</headertype>
                  <outfile>${project.build.directory}/relauncher-${project.version}.exe</outfile>
                  <jar>${project.build.directory}/${project.build.finalName}.jar</jar>
                  <errtitle>Launcher</errtitle>
                  <jre>
                    <minversion>1.6.0</minversion>
                  </jre>
                  <classpath>
                    <mainclass>com.jayway.wrappedapplication.Launcher</mainclass>
                    <adddependencies>false</adddependencies>
<precp>anything</precp>
                  </classpath>
                  <icon>${basedir}/build-resources/win/icons/application.ico</icon>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
<profile>
      <activation>
        <os>
          <family>mac</family>
        </os>
      </activation>
      <build>
<plugins>
<plugin>
            <groupid>org.codehaus.mojo</groupid>
            <artifactid>osxappbundle-maven-plugin</artifactid>
            <version>1.0-alpha-2</version>
            <configuration>
              <mainclass>com.jayway.wrappedapplication.Launcher</mainclass>
              <iconfile>${basedir}/build-resources/osx/icons/application.icns</iconfile>
            </configuration>
            <executions>
              <execution>
<phase>package</phase>
                <goals>
                  <goal>bundle</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
</pre>
<p>And that's it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/08/15/create-native-java-applications-on-os-x-and-windows-using-maven-plugins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Developing Minecraft Plugins</title>
		<link>http://blog.jayway.com/2011/05/22/developing-minecraft-plugins/</link>
		<comments>http://blog.jayway.com/2011/05/22/developing-minecraft-plugins/#comments</comments>
		<pubDate>Sun, 22 May 2011 15:03:21 +0000</pubDate>
		<dc:creator>Jan Kronquist</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=8507</guid>
		<description><![CDATA[Minecraft is the most interesting gaming concept I've seen in many years. It is sort of a digital equivalent of Lego and allows people to build and experience amazing worlds. With well over 2 million copies sold and 1.2 million YouTube videos you quickly realize that people like this kind of game. Using just the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.minecraft.net/">Minecraft</a> is the most interesting gaming concept I've seen in many years. It is sort of a digital equivalent of Lego and allows people to build and experience amazing worlds. With well over <a href="http://www.minecraft.net/stats.jsp">2 million copies sold</a> and <a href="http://www.youtube.com/results?search_query=minecraft">1.2 million YouTube videos</a> you quickly realize that people like this kind of game. Using just the basic game is enough to create all kinds of cool stuff, for example <a href="http://www.youtube.com/watch?v=7sNge0Ywz-M">this computer</a>. </p>
<p>What is my interest in all this except that I'm really into cool gaming ideas? Well, Minecraft is written in Java and it is easy to write plugins. Currently there is no official support for mods or plugins, although there <a href="http://notch.tumblr.com/post/4955141617/the-plan-for-mods">probably will be in the future</a>. However, there is lots of unofficial mods and the most promising server side mod seems to be <a href="http://bukkit.org/">Bukkit</a> which supports plugins. Their wiki includes <a href="http://wiki.bukkit.org/Setting_Up_Your_Workspace">descriptions how to setup your workspace</a> and <a href="http://wiki.bukkit.org/HUGE_Plugin_Tutorial">how to write a plugin</a>. The best way to learn is probably to take a look at the source of one of the many <a href="http://plugins.bukkit.org/">existing plugins</a>. </p>
<p>There is a sample project available called <a href="https://github.com/Bukkit/SamplePlugin">SamplePlugin</a> which you can use to get started quickly. <a href="https://github.com/Bukkit/SamplePlugin/pull/7/files">I have added a simple maven profile</a> that makes it even easier to get started:<br />
<code><br />
git clone https://github.com/jankronquist/SamplePlugin.git<br />
cd SamplePlugin<br />
mvn package -Pstart-server<br />
</code></p>
<p>Happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/05/22/developing-minecraft-plugins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The state of iOS Open Source &#8211; and what to do about it!</title>
		<link>http://blog.jayway.com/2011/05/16/the-state-of-ios-open-source-and-what-to-do-about-it/</link>
		<comments>http://blog.jayway.com/2011/05/16/the-state-of-ios-open-source-and-what-to-do-about-it/#comments</comments>
		<pubDate>Mon, 16 May 2011 14:43:28 +0000</pubDate>
		<dc:creator>Fredrik Olsson</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=8432</guid>
		<description><![CDATA[There is a vibrant community of open source projects for iOS. You need a calendar UI components or a JSON parser? No problem, the projects are out there. Most code out there is of very high quality. Unfortunately the distribution of the code is generally very crude, barely half a step away from sharing code [...]]]></description>
			<content:encoded><![CDATA[<p>There is a vibrant community of <a href="https://github.com/search?q=iphone">open source projects for iOS</a>. You need a calendar UI components or a JSON parser? No problem, the projects are out there. Most code out there is of very high quality. Unfortunately the distribution of the code is generally very crude, barely half a step away from sharing code on disks or uploading a ZIP-archive to a BBS.</p>
<h3>The Current State of Affairs</h3>
<p>Most Open Source projects for iOS are distributed as a source code repository with an <a href="http://developer.apple.com/library/ios/featuredarticles/XcodeConcepts/Concept-Projects.html">Xcode projec</a>t. But here the good news stop for most projects. The Xcode project usually only has one <a href="http://developer.apple.com/library/ios/featuredarticles/XcodeConcepts/Concept-Targets.html">target</a>, a sample project, mixing the reusable code in the same bucket as the sample/incubator code around it.</p>
<p>The usage instructions suggest you drag and drop a directory, or even worse a collection of files, into your own project. This is a very primitive solution, passable in the '80s when all we had was disks and BBS:es, not good enough today. All history and connection back to the source is lost, any value added by source control systems is lost the second you decide to use an open source component this way. Any bug-fix or improvement you make will require a manual merge back to the original project. You also loose all tracking information the moment you copy a file, what version of project X did you use, some special branch?</p>
<h3>This Need To Change</h3>
<p>This affair also highly discourages re-use. Almost every open source project out there that involves network connectivity also uses <a href="http://developer.apple.com/library/ios/samplecode/Reachability/">Apple's Reachability example</a> code as a base for determining network status. Apple's code is not complete for all use-cases, and not free of bugs, so almost every project has a more or less modified variant of the same code causing compiler errors. Ensuring that using several open source project in one application is bound to end up with conflicts. Leaving it up to you to determine which projects version of Reachability that is the master version, often you end up writing a third version of Reachability for your project. And none of these changes and improvements will ever end up in a re-usable way for the iOS community as a whole.</p>
<p>This is not an impossible problem to solve, in the Java world there is for example <a href="http://maven.apache.org/">Maven</a> that solves this very well. Maven is a huge tool, and re-inventing that wheel for iOS would be a mammoth task. Fortunately that is not needed; Xcode already has the basics that we need in order to create iOS projects that are highly extendable and re-usable.</p>
<h3>There is a Solution Today</h3>
<p>One Xcode project can have one or more targets, usually the target is your application, sometimes you have one target for iPhone and a separate target for iPad. Targets are not limited to applications, you can also have a Unit-test targets, and more importantly static library targets.</p>
<p>A static library target yield a static library that can be linked into any other target, so be applications or other static libraries. A static library is a cruder version of a Framework, like UIKit and Core Data that Apple provide us. Crude as they are, it is still good enough to use for sharing re-usable Open Source project components.</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/05/sub-projects.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/05/sub-projects.png" alt="" title="Xcode sub projects" width="299" height="303" align="right" /></a>A Xcode project has the notion of sub-projects. A Xcode sub-project is a reference to another Xcode project. You can set the sub-project's Targets as direct dependencies for your targets, and instruct the sub-projects products to be linked with your products. In essence say "Use what that other Xcode project creates to build my project".</p>
<p>The idea of Xcode's sub-projects has a logical one-on-one mapping to sub-modules in Git. Meaning that exposing re-usable iOS Open Source projects as static libraries on for example github is as easy as can be.</p>
<h3>Eating Your Own Dogfood</h3>
<p>This is actually what I have done for years, ever since I released HessianKit in 2008. Most of the code you write will be re-usable for the next project, having an easy way group your re-usable components into a growing library will save you a lot of work.</p>
<p>Firstly I never have to start with a blank canvas for any project. But more importantly, when working on many applications, any bug fixes and improvements I make to my shared components immediately trickles out to all other projects as well. If I add animated insert of cells in my column table view for project <em>A</em>, then all other projects is only one git pull away from benefiting from this new feature as well.</p>
<p>Jayway have since a few weeks begun the process of publishing our re-usable components for iOS. So far this has resulted in three projects on github:</p>
<ul>
<li><a href="https://github.com/jayway/CWFoundation">CWFoundation</a> - a collection of new classes and categories to add functionality that is commonly missing from Foundation framework.</li>
<li><a href="https://github.com/jayway/CWUIKit">CWUIKit</a> - a collection of classes and categories that do the same for UIKit. CWUIKit requires CWFoundation.</li>
<li><a href="https://github.com/jayway/CWCoreData">CWCoreData</a> - A collection of categories for Core Data that makes using Core Data in a multithreaded application a breeze.</li>
</ul>
<p>These are living projects and will be updated with new functionally over time, and large enough to warrant a blog-post for each on their own. There are also a few <i>Componentized</i> forks of popular iOS open source projects at <a href="https://github.com/jayway">Jayway's github page</a>. </p>
<h3>Tutorial for Using a Sub-Project from a Sub-Module</h3>
<p>Working with an environment like this have many benefits, but also requires some knowledge of both Xcode and git. There are a few gotchas to be aware of, limitation of Xcode and the linker, best explained with a short tuturial.</p>
<p>CWUIKit has additions to UIAlertView that allows an alert to be created directly from a <code>NSError</code> instance, just like AppKit do on Mac OS X. Lets walk through how to create a new project that uses this functionality from CWUIKit to display the error message from a faulty URL request.</p>
<blockquote><p>This tutorial is for Xcode 3.2, but works with minor modifications for Xcode 4. Changes for Xcode 4 are written in block quotes like this.</p></blockquote>
<h4>1. Create new "Window-based Application" from Xcode.</h4>
<p>   I chose a Window-based app because it contains the least amount of template code, and fits the purpose of an example well.</p>
<h4>2. Initialize the project directory as a git repo.</h4>
<pre class="brush:shell">git init</pre>
<p>We need to initialize the project directory as a proper git-repo in order to use git's sub-modules.</p>
<blockquote><p>Skip this step if project is created with git-repo in Xcode 4.</p></blockquote>
<h4>3. Add sub-module</h4>
<pre class="brush:shell">git submodule add git@github.com:jayway/CWUIKit.git Components/CWUIKit</pre>
<p>This will create a sub directory named <em>Components</em>, this is where I by convention put all my sub-modules/sub-projects, it is not a hard requirement.</p>
<h4>4. Update and initialize all submodules</h4>
<pre class="brush:shell">git submodule update --init --recursive</pre>
<p>A git-submodule is by default not initialized, this is to avoid downloading large amount of data for a sub-modules you do not need, such as a test project. This is why we must update and initialize the sub-projects to realize them when starting a new repo or cloning an old one.</p>
<h4>5. Add sub-project</h4>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/05/target-membership.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/05/target-membership.png" alt="" title="Target Membership" width="265" height="163" align="right" /></a><br />
Locate <em>CWUIKit.xcodeproj</em> and drag and drop into your project.<br />
Highlight the <em>CWUIKit.xcodeproj</em> item and ensure the <em>"Target Membership"</em> column, that has a bullet as symbol, is checked for the libCWUIKit.a product. This is the static library to link against.<br />
  Also add the CWUIKit target as a direct dependency to your applications target so that CWUIKit is automatically build before building your application.</p>
<blockquote><p>It is not required to setup target membership in Xcode 4, only set Target as Target Dependency in Build Phases tab, and add the Product to be linked in the same tab.</p></blockquote>
<h4>6. Recursive Sub-Projects</h4>
<p>Static libraries are by their nature linked into your binary, this means that if <em>static lib A</em> and <em>static lib B</em> both define the same <em>global symbol C</em> you will get a duplicate symbol <em>‘C’</em> error when linking you app.<br />
CWUIKit uses functionality from CWFoundation, but because of this limitation of the linker it can not explicitly add this functionality to itself. Doing so would make it impossible to use CWUIKit side-by-side with other projects that also uses CWFoundation, such as CWCoreData.<br />
The work around is that any project that includes CWUIKit must also include CWFoundation. So repeat step 5 with the <em>CWFoundation.xcodeproj</em> from <em><Your Appl Directory>/Components/CWUIKit/Components/CWFoundation</em>.</p>
<blockquote><p>Xcode 4 has full knowledge of recursive sub-projects, so this step can be skipped. Only add CWFoundation sub-projects product to be linked.</p></blockquote>
<h4>7. Add QuartzCore and OpenGLES frameworks to your target.</h4>
<p>Static libraries can not enforce linking of frameworks on it’s own, so building the app in it’s current state would result in missing symbols errors.<br />
Using CWUIKit requires the app to be linked against QuartzCore and OpenGLES frameworks for CoreAnimation and OpenGL additions.</p>
<h4>8. Setup header search paths.</h4>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/05/header-search.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/05/header-search.png" alt="" title="Header Search Path" width="304" height="91" align="right" /></a>Unfortunately sub-projects headers are not automatically added to the search path of your projects. So you must add <em>"Components/**"</em> as a header search path for your project.</p>
<blockquote><p>Xcode 4 considers header search baths to be an advanced setting, to change the build settings display for Basic to All if you can not find it.</p></blockquote>
<h4>9. Setup linker flags</h4>
<p>Add "-all_load" to other linker flags.<br />
The GCC and LLVM linker also has a limitation/bug for static libraries that will strip out any methods for categories on a class that is not defined in the static library. For example any method extending <code>UIAlertView</code> in libCWUIKit.a will be stripped out by this bug.</p>
<h4>10. Add <code>#import "CWUIKit.h"</code> to you application delegate. And add this small code to the <code>application:didFinishLaunchingWithOptions:</code> method</h4>
<pre class="brush:objc">NSError* error = nil;
[NSData dataWithContentsOfFile:@"wrong path!"
                       options:nil
                         error:&error];
[[UIAlertView alertViewWithError:error] show];</pre>
<h4>11. There is no step 11.</h4>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/05/error-alert.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/05/error-alert.png" alt="" title="UIAlertView with NSError additions" width="198" height="372" align="right" /></a><br />
But there is a screenshot of the running app.</p>
<h3>Conclusions</h3>
<p>This method of using Xcode sub-projects and git sub-modules for managing shared components works very well, and scales to be even better the more sub-projects and developers you have. The greatest benefit is without any doubt that bug-fixes and new features by default always trickles back to their source and become re-usable for all.</p>
<p>All the downsides are in the limitations of static libraries themselves, and can unfortunately not be overcome unless Apple introduces proper support for third party frameworks in iOS SDK. The two major gotchas are missing symbols caused by missing frameworks required by dependencies, and duplicate symbols caused by implicit inclusion of dependencies from dependencies. I have found that the best solution is to always have a README with your project where you explicitly name each Framework and Component that is required.</p>
<p>Using Xcode sub-project to manage your builds solves the problem of dependency resolution without the need to write a new system, works on the developer's desktop as well as on a build server. Using git sub-modules to manage your dependencies solves the problem of including all recursive dependencies as well as versioning. Any sub-module can by locked at a particular stable version by commit or tag as required, with full history. But best of all; you as a developer is free to just code away knowing that you can later commit and push your changes back, independently of how or where the code originates.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/05/16/the-state-of-ios-open-source-and-what-to-do-about-it/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Maven, FindBugs and Dashboard Reports</title>
		<link>http://blog.jayway.com/2010/01/29/maven-findbugs-and-dashboard-reports/</link>
		<comments>http://blog.jayway.com/2010/01/29/maven-findbugs-and-dashboard-reports/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 20:02:59 +0000</pubDate>
		<dc:creator>Davor Crnomat</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=4571</guid>
		<description><![CDATA[There are a few simple steps to get nice graphic presentations of FindBugs results using Maven.

First, to enable FindBugs reporting in Maven, just add report section to your pom files, something like example below, but of course, you can do your own configuration.]]></description>
			<content:encoded><![CDATA[<p>There are a few simple steps to get nice graphic presentations of FindBugs results using Maven.</p>
<p>First, to enable FindBugs reporting in Maven, just add report section to your pom files, something like example below, but of course, you can do your own configuration.</p>
<pre class="brush:xml">
&lt;reporting&gt;
  &lt;plugins&gt;
    &lt;plugin&gt;
      &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
      &lt;artifactId&gt;findbugs-maven-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.3&lt;/version&gt;
      &lt;configuration&gt;
        &lt;excludeFilterFile&gt;exclude.xml&lt;/excludeFilterFile&gt;
        &lt;findbugsXmlOutput&gt;true&lt;/findbugsXmlOutput&gt;
        &lt;findbugsXmlWithMessages&gt;true&lt;/findbugsXmlWithMessages&gt;
        &lt;threshold&gt;Low&lt;/threshold&gt;
        &lt;effort&gt;Max&lt;/effort&gt;
        &lt;xmlOutput&gt;true&lt;/xmlOutput&gt;
      &lt;/configuration&gt;
    &lt;/plugin&gt;
  &lt;/plugins&gt;
&lt;/reporting&gt;
</pre>
<p>Then you can just use command <strong>mvn site </strong>if you want to generate<strong> </strong>more comprehensive project information or <strong>mvn findbugs:findbugs </strong>for only FindBugs reports.</p>
<p>Finally use <strong>mvn dashboard:dashboard</strong> to generate charts.</p>
<p>Voila. We have got nice graphic reports.<br />
Well, not so nice. We have bugs we need to fix.</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2010/01/findbugs_report.jpg" rel="lightbox"><img class="size-full wp-image-4572 alignleft" title="findbugs_report" src="http://blog.jayway.com/wordpress/wp-content/uploads/2010/01/findbugs_report.jpg" alt="FindBugs report charts" width="621" height="686" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2010/01/29/maven-findbugs-and-dashboard-reports/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Maven, the new Elephant on the Block</title>
		<link>http://blog.jayway.com/2010/01/23/maven-the-new-elephant-on-the-block/</link>
		<comments>http://blog.jayway.com/2010/01/23/maven-the-new-elephant-on-the-block/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 15:39:11 +0000</pubDate>
		<dc:creator>Anders Janmyr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[build systems]]></category>
		<category><![CDATA[buildr]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=4500</guid>
		<description><![CDATA[Some of you may remember the article, by Bruce Tate, Don't Make Me Eat the Elephant Again. It was an article about EJB, and Bruce was begging Sun not to make the same mistakes with EJB3 as they had done with EJB, and EJB2. They didn't, Spring came along as better alternative and forced EJB3 [...]]]></description>
			<content:encoded><![CDATA[<p>Some of you may remember the article, by Bruce Tate, <a href="http://today.java.net/pub/a/today/2004/06/15/ejb3.html">Don't Make Me Eat the Elephant Again</a>.<br />
It was an article about EJB, and Bruce was begging Sun not to make the same mistakes with EJB3 as they had done with EJB, and EJB2. They didn't, Spring came along as better alternative and forced EJB3 to become slimmer and better. If not for Spring, EJB3 would probably look very different from what it looks like today.<br />
Well, guess what, there is a new elephant on the block and its name Maven2.</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/_ELioussa2vo/S1sVp6WDq8I/AAAAAAAAAbU/Vsll0_5GjII/s1600-h/maven2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox"><img border="0" height="289" src="http://4.bp.blogspot.com/_ELioussa2vo/S1sVp6WDq8I/AAAAAAAAAbU/Vsll0_5GjII/s320/maven2.png" width="320" /></a></div>
<p>
Just like EJB2, Maven2 was born out of something so unbearable that anything else was bliss. <a href="http://commons.apache.org/jelly/">Jelly</a> anyone!</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/_ELioussa2vo/S1sWI6lm3KI/AAAAAAAAAbc/A6a_3zHxpsc/s1600-h/Maven.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox"><img border="0" height="246" src="http://3.bp.blogspot.com/_ELioussa2vo/S1sWI6lm3KI/AAAAAAAAAbc/A6a_3zHxpsc/s320/Maven.png" width="320" /></a></div>
<p>
But just as EJB was fundamentally flawed, so is Maven2. Build systems, even advanced ones like Maven is fundamentally about two things.</p>
<ol>
<li>Check if something that something else depends on has changed</li>
<li>If so, do something.</li>
</ol>
<p>That's it, that is what is important.<br />
The checking may contain various sophisticated methods for detecting if files, subsets of files, all files, web pages, twitter feeds, etc, has changed, but that is really it.<br />
And the doing can be anything, Copy files, commit files, build websites, run tests, generate code, launch missiles, whatever!<br />
But the key to doing this efficiently is a programming language with easy access to system commands and the ability to create simple abstractions, with methods, variables, and objects. The language should also, preferably, be one without a lot of ceremony, like Ruby, Javascript or Python.<br />
There are already build systems like this out there, <a href="http://buildr.apache.org/">Buildr</a>, <a href="http://www.scons.org/">SCons</a>, and <a href="http://rake.rubyforge.org/">Rake</a> come to mind, but they do not have the momentum of Maven, so a merger between Maven and Buildr would be wonderful.</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/_ELioussa2vo/S1sWTI-SneI/AAAAAAAAAbk/Z0AI_sUPXMs/s1600-h/Maven3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" rel="lightbox"><img border="0" src="http://4.bp.blogspot.com/_ELioussa2vo/S1sWTI-SneI/AAAAAAAAAbk/Z0AI_sUPXMs/s320/Maven3.png" /></a></div>
<p>So, Jason, hear my plea, Don't make me eat the elephant again!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2010/01/23/maven-the-new-elephant-on-the-block/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>One artifact with multiple configurations in Maven</title>
		<link>http://blog.jayway.com/2010/01/21/one-artifact-with-multiple-configurations-in-maven/</link>
		<comments>http://blog.jayway.com/2010/01/21/one-artifact-with-multiple-configurations-in-maven/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 17:54:52 +0000</pubDate>
		<dc:creator>Henrik Larne</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=4363</guid>
		<description><![CDATA[Problem When working on www.beertoplist.com I ran into a Maven problem, that is fairly common: Having a project that should be configured differently for different environments. That is for instance you want one configuration for development, one for test and one for production. I wanted a solution that allowed me to make changes to all [...]]]></description>
			<content:encoded><![CDATA[<h3>Problem</h3>
<p>When working on <a href="http://www.beertoplist.com">www.beertoplist.com</a> I ran into a Maven problem, that is fairly common: Having a project that should be configured differently for different environments. That is for instance you want one configuration for development, one for test and one for production. I wanted a solution that allowed me to make changes to all kind of configuration files, for instance property files, Spring context files and Tomcat context files. </p>
<h3>Poor solution</h3>
<p>Googling on the problem I found that most people suggested that you should use a set of Maven profiles, one for each environment. So when you want to build the project for test environment you enable the test profile and get all the test configuration. At first glance this might seem like a good solution, but there is a major problem with this solution. </p>
<p>When you have your artifact, how do tell which environment it is configured for? Even worse what if you forget to enable the production profile when releasing or maybe enable the test profile instead. Then you have released a test version of the project and there is no way you can tell except for checking the details in the artifact. Further more you commonly want to deploy the released version to a test environment, but you can not do that out of the box, because the released artifact in the Maven repository is configured for production (if you enabled the right profile). Thus you need to check out the release tag and build a new version with the test profile enabled. Now you end up with two files with the same name and version, that are configured differently. Not a very appealing solution.</p>
<h3>My solution</h3>
<p>My suggestion is to instead let Maven build one artifact for each configuration and label them accordingly, so when looking at a specific version in the Maven repository you find, one development artifact, one test artifact and one production artifact, each clearly labeled. Then you never run into the problems listed above. So how can we accomplish this?</p>
<p>Maven have the concept of classifiers. This is a suffix that is appended to the name of the artifact to distinguish it from the main artifact. This is used for instance by the source plugin that creates a source jar file for a Maven project, resulting in a file with the name &lt;artifact id&gt;-&lt;version&gt;-sources.jar. The classifier for this file is "sources". The same concept can be used to build a development, a test and a production artifact, which is the solution I choose in <a href="http://www.beertoplist.com">www.beertoplist.com</a>. </p>
<p>I decided to put all the environment specific configuration in a special source tree, with the following structure:</p>
<pre>
+-src/
  +-env/
    +-dev/
    +-test/
    +-prod/
</pre>
<p>Then I configured the maven-war-plugin to have three different executions (the default plus two extra), one for each environment, producing three different war files: beer-1.0-dev.war, beer-1.0-test.war and beer-1.0-prod.war. Each of these configurations used the standard output files from the project and then copied the content from the corresponding src/env/ directory on to the output files, enabling an override file to be placed in the corresponding src/env/ directory. It also supported copying a full tree structure into the output directory. Thus if you for instance wanted to replace the web.xml in test you simply created the following directory:</p>
<p>src/env/test/WEB-INF/</p>
<p>and placed your test specific web.xml in this directory and if you wanted to override a db.property file placed in the classpath root directory for the test environment you created the following directory: </p>
<p>src/env/test/WEB-INF/classes</p>
<p>and placed your test specific db.property file in this directory.</p>
<p>I kept the src/main directory configured for development environment. The reason for this was to be able to use the maven-jetty-plugin without any extra configuration.</p>
<h3>Configuration</h3>
<p>Below you find the maven-war-plugin configuration that I used to accomplish this:</p>
<pre class="brush:xml">
&lt;plugin&gt;
  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
  &lt;configuration&gt;
    &lt;classifier&gt;prod&lt;/classifier&gt;
    &lt;webappDirectory&gt;${project.build.directory}/${project.build.finalName}-prod&lt;/webappDirectory&gt;
    &lt;webResources&gt;
      &lt;resource&gt;
        &lt;directory&gt;src/env/prod&lt;/directory&gt;
      &lt;/resource&gt;
    &lt;/webResources&gt;
  &lt;/configuration&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;id&gt;package-test&lt;/id&gt;
      &lt;phase&gt;package&lt;/phase&gt;
      &lt;configuration&gt;
        &lt;classifier&gt;test&lt;/classifier&gt;
        &lt;webappDirectory&gt;${project.build.directory}/${project.build.finalName}-test&lt;/webappDirectory&gt;
        &lt;webResources&gt;
          &lt;resource&gt;
            &lt;directory&gt;src/env/test&lt;/directory&gt;
          &lt;/resource&gt;
        &lt;/webResources&gt;
      &lt;/configuration&gt;
      &lt;goals&gt;
        &lt;goal&gt;war&lt;/goal&gt;
      &lt;/goals&gt;
    &lt;/execution&gt;
    &lt;execution&gt;
      &lt;id&gt;package-dev&lt;/id&gt;
      &lt;phase&gt;package&lt;/phase&gt;
      &lt;configuration&gt;
        &lt;classifier&gt;dev&lt;/classifier&gt;
        &lt;webappDirectory&gt;${project.build.directory}/${project.build.finalName}-dev&lt;/webappDirectory&gt;
        &lt;webResources&gt;
          &lt;resource&gt;
            &lt;directory&gt;src/env/dev&lt;/directory&gt;
          &lt;/resource&gt;
        &lt;/webResources&gt;
      &lt;/configuration&gt;
      &lt;goals&gt;
        &lt;goal&gt;war&lt;/goal&gt;
      &lt;/goals&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
&lt;/plugin&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2010/01/21/one-artifact-with-multiple-configurations-in-maven/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Load-time weaving, Spring and Maven.</title>
		<link>http://blog.jayway.com/2009/12/15/load-time-weaving-spring-and-maven/</link>
		<comments>http://blog.jayway.com/2009/12/15/load-time-weaving-spring-and-maven/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 11:42:58 +0000</pubDate>
		<dc:creator>Mattias Ask</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[javaagent]]></category>
		<category><![CDATA[load-time weaving]]></category>
		<category><![CDATA[ltw]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=3951</guid>
		<description><![CDATA[As some of you might have read in my earlier post, I'm using load-time weaving in the project that I'm working on. Lately I've run in to some problems with getting the tests to play nice with Maven. So what was the problem? Well, I've been using @Configurable and @Autowired to inject stuff in my [...]]]></description>
			<content:encoded><![CDATA[<p>As some of you might have read in my <a href="http://blog.jayway.com/2009/05/26/spring-and-load-time-weaving-of-neo4j-based-domain-objects/">earlier post</a>, I'm using load-time weaving in the project that I'm working on. Lately I've run in to some problems with getting the tests to play nice with Maven. </p>
<p>So what was the problem? Well, I've been using <em>@Configurable</em> and <em>@Autowired</em> to inject stuff in my domain object which I create in code. To get this working when running <em>mvn test</em> you have to pass in spring-agent.jar as javaagent. When you do this, everything worked great! To to this with Maven you have to do the following:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;plugin<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>maven-surefire-plugin<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>2.4<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;forkMode<span style="font-weight: bold; color: black;">&gt;</span></span></span>once<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/forkMode<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;argLine<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        -javaagent:${settings.localRepository}/org/springframework/spring-agent/${spring.version}/spring-agent-${spring.version}.jar
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/argLine<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;useSystemClassloader<span style="font-weight: bold; color: black;">&gt;</span></span></span>true<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/useSystemClassloader<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/plugin<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>Now, that's all cool, and it worked like a charm... for a while. When I added <em>@Configurable</em> to another class to autowire in a new dependency, I could not get that specific class to get weaved properly. Believe me, I tried everything I could think of, but nothing worked... until I found a hint on a thread with a related problem. By passing in a second javaagent, aspectjweaver.jar, the problem was solved! To do this in Maven you just add the second javaagent after the first, like this:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;plugin<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>maven-surefire-plugin<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>2.4<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;forkMode<span style="font-weight: bold; color: black;">&gt;</span></span></span>once<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/forkMode<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;argLine<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        -javaagent:${settings.localRepository}/org/springframework/spring-agent/${spring.version}/spring-agent-${spring.version}.jar -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/1.6.1/aspectjweaver-1.6.1.jar
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/argLine<span style="font-weight: bold; color: black;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;useSystemClassloader<span style="font-weight: bold; color: black;">&gt;</span></span></span>true<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/useSystemClassloader<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/configuration<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/plugin<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p><em><strong>Note:</strong> If you add a line-break between the two javaagents, it doesn't work.</em></p>
<p>What was the problem I had? I have no idea! Why does this solution work? I have no idea! All I know is that I get a green light from my tests, and that I don't need this solution when running live in Tomcat or whatever, since the classloader there has <em>addTransformer(ClassFileTransformer)</em>. </p>
<p>Still, if anyone has any idea of why I, <strong>after everything worked with only spring-agent.jar</strong>, needed to add aspectjweaver I am all ears! Don't get me wrong! I can live with not knowing, but I would get peace of mind from knowing...</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/12/15/load-time-weaving-spring-and-maven/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Maven automatic build versioning and Git against Subversion</title>
		<link>http://blog.jayway.com/2009/06/04/maven-automatic-build-versioning-and-git-against-subversion/</link>
		<comments>http://blog.jayway.com/2009/06/04/maven-automatic-build-versioning-and-git-against-subversion/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 14:36:13 +0000</pubDate>
		<dc:creator>Erik Ogenvik</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[version controlling]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=1869</guid>
		<description><![CDATA[If you use Git locally against a Subversion repository you might run into problems if your project is set up to generate automatic build numbers through the buildnumber-maven-plugin, since the plugin might be setup to get the build numbers from Subversion. Through some use of additional profiles you can work around this.]]></description>
			<content:encoded><![CDATA[<p>One of the nicest features of Git is that it's possible to use it locally against a Subversion server. For many this is a crucial selling point as it allows individual developers to take advantage of Git while not requiring that the entire project switches version control from Subversion. On your local Git repository you're then free to do as many branches as you like, or otherwise take advantage of the many nice features in Git.<span id="more-1869"></span></p>
<p>However, if your project is set up to use the Maven automatic build versioning as provided by the buildnumber-maven-plugin you will run into problems if it is set to get the build numbers from the Subversion revision number. Since your local checkout is against Git, and not Subversion, the build will fail since the Subversion commands won't work.<br />
One solution for this could be to alter the plugin configuration to get the build number from the date or something similar, but that's not always possible. You might have a build server setup that depends on the build number matching the revision number, and imposing such a change might break other functionality or processes.</p>
<p>Instead you can add an additional profile to the Maven POM which will only be triggered in the absence of a .svn directory (i.e. when not using Subversion). In this profile you can override the default configuration for the build number generator to instead use the date for build numbers. This means that your builds will have different build numbers from the integration builds, but at least it will compile on your git checkout.</p>
<p>The profile will look like this:</p>
<pre>&lt;profile&gt;
  &lt;!--
  This profile is here for triggering when another scm than svn is
  used (for example git). Instead of getting the version build number
  from svn we will use the build date and the user name.
  --&gt;
  &lt;id&gt;buildnumber-git&lt;/id&gt;
  &lt;activation&gt;
    &lt;file&gt;
      &lt;missing&gt;.svn&lt;/missing&gt;
    &lt;/file&gt;
  &lt;/activation&gt;
  &lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
        &lt;artifactId&gt;buildnumber-maven-plugin&lt;/artifactId&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;phase&gt;generate-resources&lt;/phase&gt;
            &lt;goals&gt;
              &lt;goal&gt;create&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
        &lt;configuration&gt;
          &lt;doCheck&gt;false&lt;/doCheck&gt;
          &lt;doUpdate&gt;false&lt;/doUpdate&gt;
          &lt;format&gt;{0,date,yyyy-MM-dd_HH-mm}_{1}&lt;/format&gt;
          &lt;items&gt;
            &lt;item&gt;timestamp&lt;/item&gt;
            &lt;item&gt;${user.name}&lt;/item&gt;
          &lt;/items&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/profile&gt;</pre>
<p>This way Subversion and Git users can live happily together in the same project.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/06/04/maven-automatic-build-versioning-and-git-against-subversion/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Executable .jar, with onejar-maven-plugin</title>
		<link>http://blog.jayway.com/2009/03/22/executable-jar-with-onejar-maven-plugin/</link>
		<comments>http://blog.jayway.com/2009/03/22/executable-jar-with-onejar-maven-plugin/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 18:00:10 +0000</pubDate>
		<dc:creator>Hugo Josefson</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[executable]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[onejar]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=972</guid>
		<description><![CDATA[Onejar-maven-plugin collects your application including dependencies, into one executable jar. It's both easy and works well!

(UPDATED for version 1.3.0. See below.)

It lets all your dependency jars stay jars, and your code is in its own jar. All of those jars are put in a bigger jar, which is made executable.

<h4>Configuration</h4>
It may sound weird, but it's quite elegant! Just put this in your <code>pom.xml</code>'s <code>&#60;plugins&#62;</code> tag to make it work:[...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://onejar-maven-plugin.googlecode.com/">Onejar-maven-plugin</a> collects your application including dependencies, into one executable jar. It's both easy and works well!</p>
<p><strong>(UPDATED for version 1.3.0. See below.)</strong></p>
<h3>Problem</h3>
<p>If you have ever tried doing this before with Maven, you have probably used <a href="http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies">maven-assembly-plugin</a>, which would leave the door open for classpath problems!</p>
<p>It would extract all your dependency jars in one directory together with all your class files and all other classpath resources. The problem is that everything ended up in a big mix, with classpath resources possibly overwriting each other. For example, if two dependencies each had a <code>log4j.properties</code> file in their jar, one <code>log4j.properties</code> would overwrite the other.</p>
<p>No more of that mess!</p>
<h3>Solution</h3>
<p>Enter maven-onejar-plugin. It lets all your dependency jars stay jars, and your code is in its own jar. All of those jars are put in a bigger jar, which is made executable.</p>
<h4>Configuration</h4>
<p>It may sound weird, but it's quite elegant! Just put this in your <code>pom.xml</code>'s <code>&lt;plugins&gt;</code> tag to make it work:</p>
<pre>&lt;plugin&gt;
  &lt;groupId&gt;org.dstovall&lt;/groupId&gt;
  &lt;artifactId&gt;onejar-maven-plugin&lt;/artifactId&gt;
  &lt;version&gt;<strong>1.3.0</strong>&lt;/version&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;configuration&gt;
        &lt;mainClass&gt;<strong>your.package.YourMainClass</strong>&lt;/mainClass&gt;
      &lt;/configuration&gt;
      &lt;goals&gt;
        &lt;goal&gt;one-jar&lt;/goal&gt;
      &lt;/goals&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
&lt;/plugin&gt;</pre>
<p>You also need to add this to the pom:</p>
<pre>&lt;pluginRepositories&gt;
  &lt;pluginRepository&gt;
    &lt;id&gt;onejar-maven-plugin.googlecode.com&lt;/id&gt;
    &lt;url&gt;http://onejar-maven-plugin.googlecode.com/svn/mavenrepo&lt;/url&gt;
  &lt;/pluginRepository&gt;
&lt;/pluginRepositories&gt;</pre>
<p><em>Please note the new Maven repository URL. Me and onejar-maven-plugin founder Drew Stovall just recently moved the project to Google Code to make it more open and easier for others (like me!) to pitch in. <del datetime="2009-03-22T18:02:51+00:00">Yesterday, I released version 1.2.3 of onejar-maven-plugin to our new Maven repo at Google Code.</del> <strong>UPDATE: Just released version 1.3.0 with optional support for including and autoloading native libraries such as .dll files. <a href="http://onejar-maven-plugin.googlecode.com/svn/mavensite/usage.html">(detailed usage instructions.)</a></strong></p>
<p>Make sure you get the <code>&lt;pluginRepository&gt;</code> URL right so that the latest version will be available to you!</em></p>
<h4>Use</h4>
<p>Then do this to build everything:</p>
<pre>mvn install</pre>
<p>That will build both your normal jar, as well as another jar. You will get these:</p>
<div id="attachment_1152" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2009/03/onejar-maven-plugin-screenshot.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2009/03/onejar-maven-plugin-screenshot-300x150.png" alt="Standalone one-jar.jar file, along with the original .jar file." title="onejar-maven-plugin-screenshot" width="300" height="150" class="size-medium wp-image-1152" /></a><p class="wp-caption-text">Standalone one-jar.jar file, along with the original .jar file.</p></div>
<p><code>myApp.one-jar.jar</code> is the big executable that includes both <code>myApp.jar</code>, and all dependency jars.</p>
<p>You can run it standalone without any extra files, like this:</p>
<pre>java -jar target/myApp.one-jar.jar</pre>
<p><em>If you found this interesting, you might find <a href="/2008/11/28/executable-war-with-winstone-maven-plugin/">my post about winstone-maven-plugin</a> enlightning as well. It shows you how to make an executable .war file.</em></p>
<h4>Credits</h4>
<p>Thank you <a href="http://dstovall.com/">Drew Stovall</a> for creating this Maven plugin in the first place, and thank you to the <a href="http://onejar-maven-plugin.googlecode.com/svn/mavensite/history.html">other contributors</a> who have also submitted patches.</p>
<p>Project homepage: <a href="http://onejar-maven-plugin.googlecode.com/">http://onejar-maven-plugin.googlecode.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/03/22/executable-jar-with-onejar-maven-plugin/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Mavenizing the Liferay Plugin SDK</title>
		<link>http://blog.jayway.com/2009/03/14/mavenizing-the-liferay-plugin-sdk/</link>
		<comments>http://blog.jayway.com/2009/03/14/mavenizing-the-liferay-plugin-sdk/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 08:58:00 +0000</pubDate>
		<dc:creator>Henrik Bernström</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[archetype]]></category>
		<category><![CDATA[artifact]]></category>
		<category><![CDATA[liferay]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[portlet]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=1094</guid>
		<description><![CDATA[Liferay is the leading Open Source enterprise portal platform in the Java market. It's certainly an impressive piece of software. I've been following it for some time now and the product is improving a great deal in many areas, perhaps most in end user usability. One area that, in my opinion, could still be improved [...]]]></description>
			<content:encoded><![CDATA[<p>Liferay is the leading Open Source enterprise portal platform in the Java market. It's certainly an impressive piece of software. I've been following it for some time now and the product is improving a great deal in many areas, perhaps most in end user usability.</p>
<p>One area that, in my opinion, could still be improved is the development environment. It may be a heck of a good build system <a href="http://www.liferay.com">Liferay</a> has come up with, but at the bottom line it takes time to learn it and to just start studying it you easily become a bit uncertain. It consists of homegrown ant scripts. To have a flatter learning curve for newcomers <a href="http://maven.apache.org/">Maven 2</a> might be suitable.</p>
<p>Anyway, I sat down one evening some time ago and looked into how Maven 2 could be used for creating Jsp Portlets for Liferay. Some hours later the work had resulted in a new archetype for creating Liferay Jsp Portlets. </p>
<p><a href="http://svn.liferay.com/browse/plugins/trunk/tools/portlet_tmpl">The structure and content of the standard Liferay Jsp Portlet can be viewed here.</a></p>
<h3>So, what did I do?</h3>
<p>1. I followed these instructions to manipulate the Jsp Portlet part of Liferay's plugin SDK into a maven archetype:</p>
<p><a href="http://maven.apache.org/guides/mini/guide-creating-archetypes.html">http://maven.apache.org/guides/mini/guide-creating-archetypes.html</a></p>
<p>This involved editing these property and xml files:</p>
<pre>liferay-plugin-package.properties
name=${artifactId}
module-group-id=liferay
module-incremental-version=1
tags=
short-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=MIT
</pre>
<pre class="xml">portlet.xml
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-app</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>jspPortlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;display-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/display-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-class<span style="font-weight: bold; color: black;">&gt;</span></span></span>${groupId}.JSPPortlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-class<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;init-param<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>view-jsp<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;value<span style="font-weight: bold; color: black;">&gt;</span></span></span>/view.jsp<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/value<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/init-param<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;expiration-cache<span style="font-weight: bold; color: black;">&gt;</span></span></span>0<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/expiration-cache<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;supports<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mime-type<span style="font-weight: bold; color: black;">&gt;</span></span></span>text/html<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mime-type<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/supports<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-info<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;title<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/title<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;short-title<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/short-title<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;keywords<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/keywords<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-info<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>administrator<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>guest<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>power-user<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>user<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-app<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>to insert ${artifactId} and ${groupId} for the portlet name and package structure. These files are part of the file list finally being wrapped up within the archetype and used to generate the resulting portlet from Maven 2.</p>
<p>2. I ran '<strong>mvn install</strong>' on that particular archetype to have it installed in my local repository.</p>
<p>3. I used the archetype to create a new Liferay Jsp Portlet artifact:</p>
<pre>
mvn archetype:create -DarchetypeGroupId=com.liferay.maven.archetypes.portlet.jsp
  -DarchetypeArtifactId=liferay-jsp-portlet
  -DarchetypeVersion=1.0-SNAPSHOT
  -DgroupId=[my.package]
  -DartifactId=[MyFirstLiferayJspPortlet]
</pre>
<p>4. I stepped into the artifact and ran '<strong>mvn install</strong>' on it which generated my MyFirstLiferayJspPortlet-1.0-SNAPSHOT.war.</p>
<p>5. I then uploaded the war file to my portal instance via the Liferay admin GUI Plugin Installer.</p>
<p>6. Et voila. It worked, showing up in the portal.</p>
<p>And of course, worth mentioning, to have a development environment up and running in eclipse in seconds this is all you have to do:</p>
<pre>
1. mvn eclipse:add-maven-repo -Declipse.workspace=[full-path-to-workspace]

2. mvn eclipse:eclipse
</pre>
<p>To have the archetype play with the existing build situation of Liferay it would probably need to be generated from some ant target and be based on the portlet template in subversion located at "plugins/tools/portlet_tmpl/" to have it follow updates of Liferay.</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2009/03/jspportlet-archetype.zip">Here you can download the final result, as a zipped archetype.</a></p>
<p>If a generated archetype like this was to be uploaded to a public maven repository, working from above point #3 and down is what would be necessary for a developer to have a project and all the necessary property and xml files (correctly edited with package structures and all) in place for a Liferay Jsp Portlet development environment. It could at least become a complement to the Plugins SDK. And yes, it could for sure still be enhanced. For example, there is no JSPPortletTest class generated for the JSPPortlet class.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/03/14/mavenizing-the-liferay-plugin-sdk/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Executable .war with winstone-maven-plugin</title>
		<link>http://blog.jayway.com/2008/11/28/executable-war-with-winstone-maven-plugin/</link>
		<comments>http://blog.jayway.com/2008/11/28/executable-war-with-winstone-maven-plugin/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 14:37:26 +0000</pubDate>
		<dc:creator>Hugo Josefson</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[executable]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[war]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=484</guid>
		<description><![CDATA[You don't need to install Tomcat, JBoss or any other web server in order to run a Java web application (.war file)! If your project is configured with a Maven pom.xml and the module has &#60;packaging&#62;war&#60;/packaging&#62;, you can just add this little piece of XML inside the pom's &#60;plugins&#62; tag: &#60;plugin&#62; &#60;groupId&#62;net.sf.alchim&#60;/groupId&#62; &#60;artifactId&#62;winstone-maven-plugin&#60;/artifactId&#62; &#60;executions&#62; &#60;execution&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>You don't need to install Tomcat, JBoss or any other web server in order to run a Java web application (.war file)!</p>
<p>If your project is configured with a Maven <code>pom.xml</code> and the module has <code>&lt;packaging&gt;war&lt;/packaging&gt;</code>, you can just add this little piece of XML inside the pom's <code>&lt;plugins&gt;</code> tag:</p>
<pre>&lt;plugin&gt;
    &lt;groupId&gt;net.sf.alchim&lt;/groupId&gt;
    &lt;artifactId&gt;winstone-maven-plugin&lt;/artifactId&gt;
    &lt;executions&gt;
        &lt;execution&gt;
            &lt;goals&gt;
                &lt;goal&gt;embed&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;phase&gt;package&lt;/phase&gt;
        &lt;/execution&gt;
    &lt;/executions&gt;
&lt;/plugin&gt;
</pre>
<p>Then, when you run...</p>
<pre>mvn install</pre>
<p>...winstone-maven-plugin will automatically create a <code>*-standalone.jar</code> file for you, which contains your web application.</p>
<div id="attachment_501" class="wp-caption alignright" style="width: 310px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2008/11/winstone-maven-plugin-screenshot2.png" rel="lightbox"><img class="size-medium wp-image-501" title="winstone-maven-plugin-screenshot2" src="http://blog.jayway.com/wordpress/wp-content/uploads/2008/11/winstone-maven-plugin-screenshot2-300x150.png" alt="Standalone .jar file, along with the .war file." width="300" height="150" /></a><p class="wp-caption-text">Standalone .jar file, along with the .war file.</p></div>
<p>You can run that .jar file as a standalone application, which runs your included web application on port 8080 by default:</p>
<pre>java -jar target/*-standalone.jar</pre>
<p>No web server installation necessary! No external files required! (You don't even need the .war file anymore.)</p>
<p>The resulting .jar file is actually <a href="http://winstone.sourceforge.net/">the servlet container Winstone</a>, with your .war file deployed inside it.</p>
<p>There are more configuration options on <a href="http://alchim.sourceforge.net/winstone-maven-plugin/usage.html">winstone-maven-plugin's usage page</a>.</p>
<p>I want to disable some default features of Winstone for security reasons, because they are not needed: ajp13 listener on a separate port, servlet invoker and directory listings. This is the complete plugin configuration I usually use myself:</p>
<pre>&lt;plugin&gt;
    &lt;groupId&gt;net.sf.alchim&lt;/groupId&gt;
    &lt;artifactId&gt;winstone-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;1.2&lt;/version&gt;
    &lt;configuration&gt;
        &lt;cmdLineOptions&gt;
            &lt;property&gt;
                &lt;name&gt;httpPort&lt;/name&gt;
                &lt;value&gt;8080&lt;/value&gt;
            &lt;/property&gt;
            &lt;property&gt;
                &lt;name&gt;ajp13Port&lt;/name&gt;
                &lt;value&gt;-1&lt;/value&gt;
            &lt;/property&gt;
            &lt;property&gt;
                &lt;name&gt;controlPort&lt;/name&gt;
                &lt;value&gt;-1&lt;/value&gt;
            &lt;/property&gt;
            &lt;property&gt;
                &lt;name&gt;directoryListings&lt;/name&gt;
                &lt;value&gt;false&lt;/value&gt;
            &lt;/property&gt;
            &lt;property&gt;
                &lt;name&gt;useInvoker&lt;/name&gt;
                &lt;value&gt;false&lt;/value&gt;
            &lt;/property&gt;
        &lt;/cmdLineOptions&gt;
    &lt;/configuration&gt;
    &lt;executions&gt;
        &lt;execution&gt;
            &lt;goals&gt;
                &lt;goal&gt;embed&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;phase&gt;package&lt;/phase&gt;
        &lt;/execution&gt;
    &lt;/executions&gt;
&lt;/plugin&gt;</pre>
<p>You can temporarily override these configuration parameters if you like, using command-line options when executing the standalone .jar file. Find them with <code>--help</code> when you run the .jar.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2008/11/28/executable-war-with-winstone-maven-plugin/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

