JSR-330 integration for Hudson.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Smoothie: Hudson JSR330 integration for Hudson

Smoothie (a blend of guice for hudson) was designed to allow plugin components written with JSR-330 annotations to be used as Hudson extension points while leaving existing @Extension mechanism AS-IS.

Aside from installing the custom PluginStrategy (and its dependencies) into the hudson.war there are no changes to hudson-core required.



Check-out and build:

git clone git@github.com:sonatype/matrix-smoothie.git
cd matrix-smoothie
mvn install


An example of a modified hudson.war is generated in the matrix-smoothie-webapp module.

Install dependencies

Several jars need to be added to the hudson.war:

Copy matrix-smoothie/target/matrix-smoothie-*.jar into hudson.war/WEB-INF/lib
Copy matrix-smoothie-webapp/target/dependency/* into into hudson.war/WEB-INF/lib

Configure Hudson to use Smoothie

Configure system properties:



Use JSR-330 annotations to mark components

A simple component:

public class MyPageDecorator extends PageDecorator {
    // ...

Descriptors (and some other extensions) require additional @Typed meta-data:

public class MyScm extends SCM {
    // ...

    public static final class DescriptorImpl extends SCMDescriptor<MyScm> {
        // ...

Advanced Usage

Configure Aspect for Plugin development

To enable the injection of hudson.model.Describable instances, configure your HPI plugin to weave the matrix-smoothie aspect:


This will enable setter injection on Describable instances:

public class MyScm extends SCM {
    // ...

    private transient MyScmBacking backing;

    public void setMyScmBacking(MyScmBacking backing) {
        this.backing = backing;

    public static final class DescriptorImpl extends SCMDescriptor<MyScm> {
        // ...

Remember to make fields holding onto injected resources in Describable instances transient. When the object is deserialized Smoothie will re-inject the instance.

Constructor injection is NOT available for Describable instances.

Trying it out

java -DHUDSON_HOME=target/hudson \
    -Dhudson.PluginStrategy=com.sonatype.matrix.smoothie.internal.plugin.DelegatingPluginStrategy \
    -jar matrix-smoothie-webapp/target/smoothie-hudson.war

This should add a new smoothie-enabled management link and a new smoothie builder, both to simply say hello by delegation to an injected component.