Disabling Ganymede Plugins

November 20th, 2008 by jeff

In Ganymede, the Manage Configuration option Eclipse users were used to using is gone. Help->Software Updates is for just that now.

So how do you go about disabling a plugin now? Well the good news is you no longer have to wait 5 minutes for the Manage Configuration window to load!

Ganymede Eclipse now provides a view, the Plug-In Registry, where you can disable crappy plugins like ajdt.

In my case, I was unable to run unit tests in Eclipse until I disabled org.eclipse.ajdt.ui. Why on earth I would need ajdt to run a unit test I have no idea.

FYI, there is a new AJDT update site here. Ajdt 1.6.1 fixed the problem.

EasyMock IllegalStateException

November 18th, 2008 by jeff

I had a case this morning reworking a test after I’d modified a method signature, from:

        expect(mockRestProxy.getProxiedResource((String) anyObject()))
            .andReturn("{policies}");

to

        expect(mockRestProxy.getProxiedResource((String) anyObject(), userIdentity))
            .andReturn("{policies}");

I received a stacktrace like this:

java.lang.IllegalStateException: 2 matchers expected, 1 recorded.
	at org.easymock.internal.ExpectedInvocation.createMissingMatchers(ExpectedInvocation.java:41)
	at org.easymock.internal.ExpectedInvocation.<init>(ExpectedInvocation.java:33)
	at org.easymock.internal.ExpectedInvocation.<init>(ExpectedInvocation.java:26)
	at org.easymock.internal.RecordState.invoke(RecordState.java:64)
	at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:24)
	at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:45)
	at $Proxy0.getProxiedResource(Unknown Source)
...

To quote the easymock documentation,

To match an actual method call on the Mock Object with an expectation, Object arguments are by default compared with equals(). This may lead to problems.

this describes the problem.

The solution appears to be here:

If you would like to use matchers in a call, you have to specify matchers for all arguments of the method call.
There are a couple of predefined argument matchers available.

My solution was in fact to use one of the predefined matchers:

        expect(mockRestProxy.getProxiedResource((String) anyObject(), (UserIdentity) anyObject()))
            .andReturn("{policies}");

One thing I don’t really understand is why EasyMock wouldn’t allow you to match the method signature with a combination of matchers and objects. I wouldn’t think the logic for a heterogenous object equals check would be that terribly complex.

The EasyMock Mockumentation (just a play on words, it’s really not too bad).

Hat Tip to Marcels Javanotes

OpenSuse

November 12th, 2008 by jeff

I have officially started working with OpenSuse. Bluetooth, wireless, and sound all worked after the install, which was great. The flash plugin was easy to install. I’ve added a repository to Yast for software management, although I wasn’t able to find emacs via Yast and resorted to an unmanaged rpm.

I added jdk1.6 and eclipse without any issues.

Next steps;

  • add mpeg support,
  • load up my emacs environment.

Moving On From Windows

November 9th, 2008 by jeff

I can’t stand the thought of using Vista. I am an XP user; by which I mean to say I get by using cygwin and some of the Windows apps. But I’ve used Vista enough for me to know that I must draw the proverbial line in the sand there.

XP will be the last Windows OS I will ever use.

That’s a big statement for me. I’ve been running GNU/Linux servers and some desktop OS for years, but I’ve never gone completely Windows-free. But it is definitely time. Aside: I know many readers use Macs. And I will concede there is a strong argument to be made to do that. But look, I’ll be honest- I just don’t have that kind of money to spend on a computer right now.

So it’s time to say hello to the GNU/Linux desktop.

Now, after thinking about this a little bit, I realized my goal is not to mimic Windows, and I’m not really interested in a rich UI look and feel. I don’t need to be “wowed” by the graphics; I want a new computing experience. In light of that, I decided to skip Ubuntu. I also didn’t want a million packages I knew nothing about. I wanted more control over my computing, and in light of that I decided to skip Fedora and Suse. In the end I installed Blag, which claims to use 100% free software, with the exception I suppose of the Linux kernel.

Anyway, it seems like a good place to start. I immediately tarnished this image by installing my jdk. I installed emacs, which for some reason worked via yum install emacs but not via the package manager. I’ve also installed easyeclipse expert java version.

I’ve had trouble getting the wireless working on my laptop, and also don’t seem to have any sound at the moment. I’ll let you know how it goes…

UPDATE
BLAG didn’t last long. I wanted to run eclipse, but the distribution I wanted to use required GTK+ 2.2.1. The only GTK+ reference I could find, the GTK+ website, had GTK 1.2 as the latest release. I fished around on a few different yum repositories without any luck. Also, the sound didn’t work in BLAG.

I’ve since installed Suse, and now have bluetooth, wireless, and sound. I’m using the KDE desktop instead of Gnome.

UPDATE
I just realized I was reading the latest gtk+ release as 2.1.4 instead of what it really is, 2.14. Wow, that really threw me off!

Django on Dreamhost

September 28th, 2008 by jeff

It doesn’t take much searching to suspect that Django on Dreamhost maby not be an ideal environment, but it does work. Running Django on Dreamhost involves using Fastcgi, which is officially supported by Django, but not a recommended configuration.

I found following the official tutorial sufficient in setting up Django on Dreamhost.

A couple of notes from this install:

  1. There are a several sites that mention what to do after you make code changes, and have already accessed the site. I have found that “touch ~/mysite/dispatch.fcgi” is sufficient to reload my changes. But several sites mention performing a pkill or pkill -9 python2.5. I can see there are a couple of dispatch.fcgi processes running, but I haven’t seen a need to kill them yet, so I’m sticking with the touch command at this point.
  2. I had to uncheck Extra Web Security for my Django domain in the dreamhost panel to get it to run correctly. I’ll double check this as I get development going, as it looks like others have Django running with extra web security enabled.

References:

Upgrading Python on a Dreamhost Account

September 28th, 2008 by jeff

Java is just my day job. In fact, it’s pretty dull too sometimes. I like to venture out when I can and work with other technologies. In this case, I’ve been messing around with Django on my Dreamhost account. This short tutorial is intended to be the first of several related to Python and Django.

Ssh to your DH account, from the base dir…

$ mkdir opt
$ mkdir downloads
$ cd downloads
$ wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
$ tar xvzf Python-2.5.2.tgz
$ cd Python-2.5.2
$ ./configure --prefix=$HOME/opt/ --enable-unicode=ucs4
$ make
$ make install

If that completes correctly, you can remove the tarball and the Python2.5.2 directory.

Next, update your path by adding:

export PATH=$HOME/opt/bin/:$PATH

to your .bash_profile. Then test:

$ source .bash_profile
$ python -V
Python 2.5.2

If you don’t see Python 2.5.2 after typing python -V then you’ve already done something wrong.

Next, update MySql-Python (from the downloads directory):

$ wget http://internap.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
$ tar xvzf MySQL-python-1.2.2.tar.gz
$ cd MySQL-python-1.2.2
$ python setup.py install

Make sure the files extract into the ~/opt/lib/python2.5/site-packages/ directory as an egg file.

Now that we have everything upgraded nicely, we can move on to installing Django.

References:

Custom Python Install by LocalKineGrinds

Bringing the Browser To The Server (Just Discovered This)

September 13th, 2008 by jeff

John Resig posted an awesome article a little over a year ago, and I’m just getting to it. I’ve been developing a javascript presentation, primarily focusing on scope and functions, to a group of Java developers. I’ve used JSUnit and Firebug to work with javascript quite a bit, but frankly, I don’t really like either one of them that much. I wanted something to execute examples in the simplest way possible, and for me, as primarily a Java developer, that’s the command line with as little code as possible.

What Resig’s done, in a nutshell is port the native browser environment to Rhino. So you can take his environment script load it in Rhino, and run your examples. It’s perfect, and exactly what I was looking for.

Taking a look at Resig’s article, it’s trivial to get an environment set up. I used a standard project directory structure,

/
/lib/js.jar <-- Rhino jar
/src/env.js <-- Resig's env script
/src/prototype.js <-- Prototype
/src/assert.js <-- my assert script
/src/start.js <-- my start script
/tests/example1.html <-- an html page to work with

To run this, execute java -jar ./lib/js.jar, to start up the Rhino shell.

Next,

$ java -jar ./lib/js.jar
Rhino 1.7 release 1 2008 03 06
js> load('src/start.js');
js> write tests

Here’s what I put into the start script:

load('./src/env.js');
window.location='tests/example1.html';
load('./src/prototype.js');
load('./src/assert.js');

This loads the environment (env.js), then an html page for the DOM, then the prototype libraries, and finally an assertion script I wrote:

function assert(condition, affirmative, negative) {
        if(!condition) {
                return negative;
        }
        return affirmative;
}

And now I’m ready to execute my example scripts!

Generating Excel reports without a single line of java code using Seam

September 9th, 2008 by Priyatam

I still cannot reiterate enough, how much Seam is productive in developing rich web mvc apps. Take for example, a very common requirement where a rich datatable is present and users would want a “export to excel” functionality right next to each of these tables. With Seam, this is as simple as one line of facelets tag

<h:commandLink
	action="#{org.jboss.seam.excel.excelExporter.export('form:dataTable')}">
	<h:graphicImage value="/img/excel.gif" />
 </h:commandLink>

where form is the form id and ‘datatable’ is the id of the datatable in that form. Thats as simple as it can get! If you want a customized excel, then writing the excel layout, formatting by hand does not use java code at all! Everything can be coded on plain facelet tags. To demonstrate how easy it is, to create excel spreadsheets on the fly, look at this example

 <e:workbook type="jxl" xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:e="http://jboss.com/products/seam/excel"
    xmlns:f="http://java.sun.com/jsf/core"
    autoFilterDisabled="false">

    <e:cellTemplate name="cellStyles">
        <e:background color="gray_25" pattern="solid"/>
        <e:font fontName="Lucida Grande" bold="true"/>
    </e:cellTemplate>  

   <e:worksheet name="Search Criteria" value="#{searchCriteriaList}" var="criteria">
    <e:column autoSize="true">
        <f:facet name="header">
            <e:cell value="Time Period" templates="cellStyles"/>
        </f:facet>
        <e:cell value="#{criteria.timePeriod}" />
    </e:column>
    <e:column autoSize="true">
        <f:facet name="header">
            <e:cell value="Foo name" templates="cellStyles"/>
        </f:facet>
        <e:cell value="#{criteria.foo.name}" />
    </e:column>
    <e:column autoSize="true">
        <f:facet name="header">
            <e:cell value="Bar Name" templates="cellStyles"/>
        </f:facet>
        <e:cell value="#{criteria.bar.name}"/>
    </e:column>
</e:worksheet> 

<e:worksheet name="Matrix" value="#{searchResults}" var="res"  headerMargin="5"
	verticalFreeze="1" selected="true" showGridLines="true" topMargin="5">
	<e:column autoSize="true">
		<f:facet name="header">
			<e:cell value="FooName" templates="cellStyles"/>
		</f:facet>
		<e:cell value="#{res.foo.name}" />
	</e:column>
	<e:column autoSize="true">
		<f:facet name="header">
			<e:cell value="Bar name" templates="cellStyles"/>
		</f:facet>
		<e:cell value="#{res.bar.name}"/>
	</e:column>
</e:worksheet>
</e:workbook>                                                                                                                                                                                                                         	         		 			           		 		 	 	 		 			                      		 		 		     

The syntax is so simple, even a layman can understand. As you’ve seen, I’ve created two worksheets, the first one displaying the search criteria and the second one displaying the results (List : foo, bar, timePeriod). For common formatting features, you can use a feature called “templates” (see “cellStyles” above). he formatting of excel goes way beyond simple example like above to things like built in formulas, auto filters etc.

The Seam-excel support is built in the 2.1 beta release

The Prototype Dollar

September 7th, 2008 by jeff

I have been slowly picking up javascript recently. I’m, well, not really impressed, but sometimes I find things I like about it. Here’s something I like; the Prototype library adds a function, the dollar function, that looks like this:

function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

// Sample Usage:
var obj1 = document.getElementById('element1');
var obj2 = document.getElementById('element2');
function alertElements() {
  var i;
  var elements = $('a','b','c',obj1,obj2,'d','e');
  for ( i=0;i

Dustin Diaz describes it perfectly:

Short not only by name, but by reference. It not only takes in strings, it takes objects too. You can pass it one argument, or pass it many!

Running JSLint From Within Eclipse Using Rhino

September 5th, 2008 by jeff

Mikko Ohtamaa provides a nice explanation of how to execute JSLint on a javascript file from within eclipse, using Rhino.

Grails Multiple Datasource Plugin

September 5th, 2008 by jeff

Burt Beckwith discusses his new plugin - one I’ve been needing for a while!

Dirt Simple EXTJS Grid on Grails

August 25th, 2008 by jeff

At my current contract, I’ve been using the popular EXTJS javascript library. In order to get up to speed faster, I’ve started a small project to assist my learning.

I thought about using a number of back ends to support my project, but decided on Grails after reading about the built-in JSON converters.

Getting started note: Since this is a dirt simple example, I copied extjs into the web-app/js directory. James Lorenzen looks like he has a better way, and there might be a plugin some day.

I started with a simple GORM object, Media, which looks like this:

class Media {

	static constraints = {
		releaseDate(nullable: true)
	}

	String title
	Date releaseDate
	Date dateCreated
	Date lastUpdated
}

Next I added some startup data by adding it to to Bootstrap.groovy class:

     	def m = new Media(releaseDate:null, title: 'Test')
     	m.save()

And added a controller:

import grails.converters.*

class MediaController {

    def view = { 

    }

    def list = {
   	def listResult = [ total: Media.count(), items: Media.list(params)]
        render listResult as JSON
    }
}

And I now have a Grails back end that will deliver JSON to extjs! Off to the front end!

First I modified my layout, main.gsp, to add the extjs js and css files:

<html>
    <head>
        <title><g:layoutTitle default="Grails" /></title>	

		<link rel="stylesheet" href="${createLinkTo(dir:'js',file:'ext-2.2/resources/css/ext-all.css')}"></link>
		<link rel="stylesheet" href="${createLinkTo(dir:'js',file:'ext-2.2/resources/css/theme-aero.css')}"></link>
		<script type="text/javascript" src="${createLinkTo(dir:'js',file:'ext-2.2/adapter/ext/ext-base.js')}"></script>
		<script type="text/javascript" src="${createLinkTo(dir:'js',file:'ext-2.2/ext-all-debug.js')}"></script>
		<script type="text/javascript" charset="utf-8">
			Ext.BLANK_IMAGE_URL = "${createLinkTo(dir:'js',file:'ext-2.2/resources/images/default/s.gif')}";
		</script>
		<g:layoutHead />

	</head>
	<body>
		<div id="container">
			<div id="content">
				<div id="include">
					<g:layoutBody />
				</div>
			</div>
		</div>
	</body>
</html>

and added my view.gsp:

<html>
	<head>
		<meta name="layout" content="main" />
		<title>Decorated</title>
		<script type="text/javascript" src="${createLinkTo(dir:'js',file:'oscar.js')}"></script>
	</head>
	<body>
		<div id="center-div"></div>
	</body>
</html>

and lastly, my js file, taken nearly verbatim from an extjs example:

/*
 * Ext JS Library 2.0 Beta 1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 *
 * http://extjs.com/license
 */

Ext.onReady(function(){

    // create the Data Store
    var ds = new Ext.data.Store({
       autoLoad: true,
       proxy: new Ext.data.HttpProxy({
       url: 'http://localhost:8080/oscar/media/list'}),
       reader: new Ext.data.JsonReader({
       	results: 'total',
       	root:'items',
       	id:'id'
       },
       [
               {name: 'title'},
               {name: 'dateCreated'},
               {name: 'lastUpdated'},
               {name: 'releaseDate'}
          ]
       )
    });  

    var cm = new Ext.grid.ColumnModel([
	    {header: "Title", width: 120, dataIndex: 'title'},
		{header: "Created Date", width: 180, dataIndex: 'dateCreated'},
		{header: "Last Updated", width: 115, dataIndex: 'lastUpdated'},
		{header: "releaseDate", width: 100, dataIndex: 'releaseDate'}
	]);
    cm.defaultSortable = true;

    // create the grid
    var grid = new Ext.grid.GridPanel({
        ds: ds,
        cm: cm,
        renderTo:'center-div',
        width:540,
        height:200
    });
});

My code is checked in here.

Agile development with JBoss Seam & Oracle 10g XE

August 21st, 2008 by Priyatam

Most of us working in corporates, use Oracle mostly. It probably has a uptime of 99%. But sometimes, it does go down and when it does, it’s frustrating for the developer, especially when you’re in the middle of something.

We can’t have a local database instance running and having a hsqldb or mysql database would not really give us the confidence of working in the “actual world.” So, How can you have a local Oracle database without all that fuss?

Here is an alternative that I tried and it worked like a charm for me.

1) Install Oracle 10G XE . Its a light-weight version of 10G and its *free*. There is no configuration whatsoever, just the password for admin username, “system”

2) After installation you’re basically done. I use Open Oracle SQLDeveloper for the client. I think its simple and does everything you need. And its *free*. Make a new connection with
host - localhost, port - 1521, SID - xe

Surprisingly, all the above are provided by default! Now, setup a new user for your application. Grant “all” rights.

3) In my web application, I use a top-down approach with a rich domain model with JBoss Seam Framework where the schema is 100% generated by hbm2ddl. For static data, I have an import.sql in the web-inf. All I need to do is, change the hibernate.hbm2ddl.auto value back to “create” (it was “validate” before)

And change the datasource connection to jdbc:oracle:thin:@localhost:1521/xe in the jndi datasource in jboss server.

4) Change the jboss http port from 8080 to 8081 from here
jboss-4.2.2\server\default\deploy\jboss-web.deployer\server.xml
(as oracle server uses the same)

5) Start JBoss server

That’s it. All in all, it took around 20-25 minutes. (including the installation)

I now have a new oracle database installed, new tables created, new static data setup and most importantly — I did not add any configuration file(s) whatsoever and nothing in my app was changed except the ds file (which again is outside the ear file). I did not run any ruby scripts, nor groovy scripts and No — I didn’t call my DBA to setup the database or run some data scripts for me.

And the application deployed SUCCESSFULLY.

All this in less than 25 minutes.

This,, I think is agile Domain Driven Development using Seam framework.

I’m wondering if I could’ve done this 5 years ago. Not without hiring a consultant for a project named “database migration.” and not without changing so many files.

Custom taglibs with facelets

August 20th, 2008 by Priyatam

Creating tag libraries using facelets might be cool but needs more redundant infrastructure than the new JSP tag libs (which doesn’t need tld declaration or web.xml context params). However once your done, building reusable tags on the fly (with no java code) can be pretty slick.

Here are the steps for creating a simple tag - iconButton, which decorates a button with an icon image and other misc useful attributes.

taglib descriptor: your-taglib.xml (place it in WEB-INF)

<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "facelet-taglib_1_0.dtd">
<facelet-taglib>
    <namespace>http://yourUrlHere</namespace>
    <tag>
       <tag-name>iconButton</tag-name>
       <source>view/tags/iconButton.xhtml</source>
     </tag>
</facelet-taglib>

iconButton.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<button title="#{title}" class="#{styleClass}"
    onclick="#{empty onclick ? '' : onclick}">
    <img src="#{iconSrc}" border="0" align="top"
    style="padding-top:1px;padding-bottom:1px;"/>
   #{text}
</button>
</ui:composition>

Usage (in other facelets)
somepage.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:myTags="http://yourUrlHere"

    <myTags:iconButton title=" Search "
                                styleClass="iconButton" style="vertical-align:top;"
                                iconSrc="./img/magnifying-glass.png"
                                text="Search "/>

Note the inclusion of the namespace (”yoururl”) above.

web.xml

<context-param>
    <param-name>facelets.LIBRARIES</param-name>
    <param-value>/WEB-INF/tomahawk-taglib.xml;/WEB-INF/my-taglib.xml</param-value>
</context-param>

You may get the following error: -

Caused by: java.io.FileNotFoundException: <jboss-home>\bin\facelet-taglib_1_0.dtd

That’s probably because you haven’t declared the taglib in WEB-INF, as shown above.

Maven Jetty Plugin

August 20th, 2008 by jeff

It’s a common occurrence in the Java consulting world, as ridiculous as it is, I see it all the time. I do into a new development shop to help build a large webapp. Since it’s a large webapp, someone has decided they needed to buy licenses for Web* app server. And since they’re using the Web* app server for production, they decide to get developer licenses too. So, the development cycle looks like this:

Write some code, deploy to local Web* instance, wait 5 minutes for it to restart, and test.
Repeat.

The end result is that for every 2 minutes of coding, I wait 5 minutes for the local server instance to recycle. Now granted, many places have hot deploy set up, and many places do debugging. But the reality is for 80% of the enterprise web development going on today, local Web* instances are not needed, and not only are they not needed, they slow down development… a lot!

I’m on my third gig where I’ve come in and found this mode of development. And each time, I’ve been able to move the developers to a lightweight servlet container, Tomcat and/or Jetty. You can do all the things you’d do in the average development scenario, without the 5 minute wait.

Most recently, I’ve added the Jetty Plugin to a project managed by Maven. Here is the configuration I added to the pom.xml to use the plugin:

    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <inherited>true</inherited>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <archiveClasses>false</archiveClasses>
          <archive>
            <manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
          </archive>
          <webResources>
            <resource>
              <directory>${project.build.directory}</directory>
              <includes>
                <include>js/ext-rtc.js</include>
              </includes>
            </resource>
          </webResources>
        </configuration>
      </plugin>
     <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.11</version>
                <configuration>
                        <scanIntervalSeconds>10</scanIntervalSeconds>
                        <contextPath>/rtc-ui</contextPath>

<tmpDirectory>${project.build.directory}/tmp</tmpDirectory>

<webApp>${project.build.directory}/${project.artifactId}-${project.version}</webApp>

<webXml>${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/web.xml</w
ebXml>
                        <stopPort>9980</stopPort>
                <stopKey>rtc-ui</stopKey>
                        <systemProperties>
                                <systemProperty>
                                        <name>rtc.env.runtime</name>
                                        <value>dev</value>
                                </systemProperty>
                        </systemProperties>
                </configuration>
          </plugin>
    </plugins>
  </build>
  < ... />
   <profile>
      <id>js</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>javascript-maven-plugin</artifactId>
            <version>1.0-alpha-1-SNAPSHOT</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <goals>
                  <goal>compile</goal>
                </goals>
                <configuration>
                  <excludes>
                    <exclude>extjs/**</exclude>
                  </excludes>
                  <descriptor>src/main/assemble/rtc-js.xml</descriptor>

<outputDirectory>${project.build.directory}/js</outputDirectory>
                </configuration>
              </execution>
              <execution>
                <id>war-package</id>
                <goals>
                  <goal>war-package</goal>
                </goals>
               <configuration>
                  <includes>
                    <include>extjs/**</include>
                  </includes>
                  <scriptsDirectory>js</scriptsDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        < ... />
    <profile>
      <id>js-compress</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>javascript-maven-plugin</artifactId>
            <version>1.0-alpha-1-SNAPSHOT</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <id>compression</id>
                <goals>
                  <goal>compress</goal>
                </goals>
                <configuration>
                  <compressor>jsmin</compressor>
                  <optimizationLevel>9</optimizationLevel>
                  <scripts>js</scripts>
                <webappDirectory>${project.build.directory}</webappDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>

There are a few things going on here:

One, the project I’m working on is using extjs for the UI. There is a lot of javascript to copy around for deployment, so for conveince sake and performance, this project assembles all the javascript into one file. For production, it also compresses it. I’ve added that configuration in this example.
Because of the javascript configuration, I can’t just have the jetty plugin copy directly from a js directory, I have to make sure the js file is assembled and copy that one. This is accomplished using the -Pjs argument.

Secondly, notice the systemproperty element in the jetty configuration. env.rtc.runtime refers to which runtime properties file to use. It can be set to dev, prod, or qa, etc.

References:

This configuration guide is probably the most useful website.

This one has some useful info.

Eclipse debugging with this plugin

Jetty Plugin

Javascript Maven Plugin