Monday, September 24

documentation for the maven-inherit-plugin

I've uploaded some documentation for the maven-inherit-plugin in the usual format:

http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin

and improved the code to use custom Javadoc tags to get the extended plugin details.

For example:


/**
* @extendsPlugin archetype
* @extendsGoal create
* @goal create-project
* @requiresProject false
*/
public class OSGiProjectArchetypeMojo extends MavenArchetypeMojo
{
// if you override member fields, remember to propagate the values using reflection
}

Tuesday, September 18

Simple Maven Plugin Inheritance

Pax Construct extends a number of other maven mojos from the archetype, compiler and eclipse plugins. Extending maven mojos is a bit of a pain at the moment, because plexus (the component manager used by maven) relies on javadoc comments to generate the plugin XML. Unfortunately when the parent mojo is provided by an external project, the javadoc isn't available to plexus.

At first I relied on duplicating parameters in the sub-mojo to trick plexus into creating the right plugin XML, then used reflection to forcibly update any private fields in the parent mojo.

Maintaining these parameters was a bit of a nightmare, so I developed a new plugin called the maven-inherit-plugin to help with the plugin XML. It attempts to merge the various plugin XML fragments and warns about any potential field clashes that would require reflection.

To use it in your plugin pom, add the following XML:

<plugin>
<groupid>org.ops4j.pax.construct.ng</groupid>
<artifactid>maven-inherit-plugin</artifactid>
<executions>
<execution>
<goals>
<goal>inherit</goal>
</goals>
</execution>
</executions>
</plugin>

...

<pluginRepositories>
<pluginRepository>
<id>ops4j-repository</id>
<url>http://repository.ops4j.org/maven2</url>
</pluginRepository>
</pluginRepositories>

It looks for dependencies of type "maven-plugin" and will merge the XML fragments describing their goals with any matching local goals that have the following syntax:

@extendsPlugin {plugin}
@goal {local-goal}

If you want to rename a inherited goal, use this syntax:

@extendsPlugin {plugin}
@extendsGoal {inherited-goal}
@goal {local-goal}

For example, in Pax-Construct I extend the archetype goal into a number of sub-goals, such as:

/**
* @extendsPlugin archetype
* @extendsGoal create
* @goal create-project
* @requiresProject false
*/

Overridden fields generate a warning at compile time and must be updated using reflection. See the main pax plugin for examples of using this technique to add behaviour to existing plugins.

Source code is available from:

https://scm.ops4j.org/repos/ops4j/projects/pax/construct/maven-inherit-plugin


(updated to show new javadoc tags)

Calling all testers! Pax Construct v2 beta1

Well, we've finally completed the move to our new home and are slowly unpacking boxes "on-demand" :)

Meanwhile, back at OPS4J I've finished a major refactoring of the Pax Construct plugin and slimmed down the archetypes to produce a much leaner project layout. The more adventurous of you might like to try out the beta version:

http://repository.ops4j.org/maven2/org/ops4j/pax/construct/scripts/0.2.0-beta1/scripts-0.2.0-beta1.zip

Be warned - the usual beta disclaimers apply! Especially since the only machine I have with Windows is still packed away, and so all testing so far has been on my macbook using Ubuntu (my main development environment). Also, the docs are woefully out of date - at this moment the code is the best documentation, but you can use -h with any of the scripts to get basic usage.

Second warning: Pax Construct v2 is not compatible with projects created using older versions, but a script is being developed to migrate projects to the new layout. However you can use v2 to create and manage new projects.

Some highlights of v2:
  • Transitive wrapping - you can choose to embed dependencies, or create further wrappers
  • Transitive import - provided dependencies of imported bundles are automatically added
  • Simple import management - the import list is maintained inside a single provision pom
  • Optional generation of Eclipse project files - use "mvn clean install -Peclipse"
  • Enhanced compilation - supports compiling against bundles with embedded jars
  • Refactoring support - bundles can be moved around, poms will be created as necessary
  • Improved maven mojos - can be used inside other poms to create projects for testing
Here's a couple of wrapping examples, which should be done inside a project created with pax-create-project - the first creates a bundle with embedded dependencies (use "mvn clean install" to build it) the second replaces it with a series of bundles, one per dependency:
pax-wrap-jar -g commons-logging -a commons-logging -v 1.1 -- -DembedTransitive

pax-wrap-jar -g commons-logging -a commons-logging -v 1.1 -- -DwrapTransitive -Doverwrite
A more complex example involving Spring-OSGi can be downloaded here:

Spring-OSGi deployment script (unix)
Spring-OSGi deployment script (windows)

Download the script for your OS, make sure the v2 scripts are in your path and run it - it should build and deploy a basic Spring-OSGi setup based on milestone 3, along with some wrappers and the weather sample. (note: it can take a few seconds to startup on Felix, the default framework)

There's a lot of cool stuff behind the scenes, and I'm starting on proper documentation for it this week. BTW, if you find any bugs with beta1 please raise them at http://issues.ops4j.org while I work on the docs :)

Sunday, July 22

Our new home


Hayfa and I are now home-owners! Picked up the keys to our new condo apartment yesterday, and spent most of this weekend discussing paints, what should go where, etc. (we're both fairly easy-going so it takes us ages to decide anything!)




Friday, July 6

Better dependency management with Pax Construct

Had some really useful discussions during the OSGi Community Event in Munich about wrapping complex artifacts such as Hibernate3. The next drop of Pax Construct will try to handle dependencies for you as much as possible (automatically embedding / wrapping / importing them as required) so with one command you can drag an artifact into your OSGi project without having to repeatedly deploy or compile to track down those annoying missing dependencies.

Also planned: OBR support to search for artifacts based on your bundle's imports :)

As ever, let me know via JIRA or email if there's anything that would make OSGi development that little bit easier!

Tuesday, July 3

OSGi Alliance Community Event talks now online

My talk from the 2007 OSGi Alliance Community Event is now online:

http://www2.osgi.org/wiki/uploads/Conference/OSGiCommunity-McCulloch.pdf

along with slides from all the other talks - well worth perusing.

http://www2.osgi.org/Conference/2007CommunityEvent

Saturday, June 23

Guice-OSGi 0.1.0 released

FYI, I've just made an initial drop of my Guice-OSGi laboratory project:

http://wiki.ops4j.org/confluence/display/ops4j/Guice-OSGi

org.ops4j.guice-osgi.core-0.1.0.jar
org.ops4j.guice-osgi.core-0.1.0-javadoc.jar
org.ops4j.guice-osgi.core-0.1.0-sources.jar

which lets you use Guice to access / register OSGi services - for example:

@Inject
@OSGiServiceRegistration
ExampleService exported;

would register the object injected into 'exported' as an OSGi service, and:

@Inject
@OSGiService
ExampleService imported;

would inject a proxy into 'imported' which delegates to the OSGi service.

example (use 'mvn clean install pax:provision' to try it out)

It's capable of lots more (custom LDAP filters, injected listeners, etc.) but I have a flight to catch in a few hours and need to finish my packing :) The integration tests checked into subversion contain more examples.

It doesn't do everything Spring-OSGi does, but then again it is only one bundle of ~500k ;)

(PS. I've also released 0.1.6 of the Pax Construct tools - busy week!)

Tuesday, June 12

The dreaded disk0s2: 0xe0030005 (UNDEFINED)

I've had my macbook for nearly five months and use it as my primary dev box. Last month I took it with me to Sweden to run some OSGi tutorials - before the very first session I calmly closed the lid, wandered over to the conference room and opened it up to see... nothing!

People were already wandering in so decided to do a quick reboot - but instead of the reassuring apple logo I now saw a flashing question mark folder (gulp). Luckily the tutorial was available on the intranet (FYI, it's based on Pax Construct) so I was able to grab a spare laptop and continue.

Anyway after the tutorial session I absentmindedly turned on my macbook, which now started ok!

So is this a new mac feature, auto-repair? Sadly not... since then its behaviour has been erratic - occasional beach-balls, looking like the system had frozen only to return after a few minutes. Tried turning off spotlight indexing (nice performance boost) which helped for a bit but the problem returned. Tried a full archive, erase and re-install with minimum setup which I thought had nailed it, but this weekend my macbook went totally rosak :(

No hard disk, nothing... nowhere to reinstall MacOSX, no chance of recovering data - thankfully I still had the full image backup from a few days ago (plus most of my work is online these days).

So my macbook is now at the local Apple support centre and I'm back to using my trusty Linux box that I built from scratch (and ironically contains a still-working HDD I rescued from an ancient Dell laptop and now use for temporary storage).

So here's the MOTD... if you see any errors like the following in your system log:

disk0s2: 0xe0030005 (UNDEFINED)

make sure you have any critical data backed up and get your macbook checked out asap.