Findbugs, PMD, Checkstyle & Dependency Finder in Netbeans

The Software Quality Environment project provides Netbeans plugins related to code quality.

Unfortunately they are not in the default Update Centers so you have to add the SQE Update Center Manually.

Unfortunately again, at the time of writing, the SQE web site provide a wrong Update Center URL that leads to a 404. Who mentionned java.net ? :)

So, without further ado, here is the SQE Update Center URL:

http://deadlock.netbeans.org/hudson/job/sqe/lastStableBuild/artifact/build/full-sqe-updatecenter/updates.xml

Once the Update Center is added, the Available Plugin catalog contains a Quality category that contains cited plugins.

All the plugins are working fine on Netbeans 7.0.

flamingo-maven-plugin-1.1 released!

flamingo-maven-plugin transcode SVG files into Java2D classes that can implement ResizableIcon from the Flamingo / Insubstantial projects

The project is hosted in maven central. here you’ll find a quick copy/paste for the dependency.

Transcode SVG files

Use the following goal: transcode

Configuration inside the POM

Here is a quick example:

<plugin>
 <groupId>org.codeartisans</groupId>
 <artifactId>flamingo-maven-plugin</artifactId>
 <version>1.1</version>
 <executions>
  <execution>
   <id>icons</id>
   <phase>generate-sources</phase>
   <goals><goal>transcode</goal></goals>
   <configuration>
    <sourceDirectory>${project.basedir}/src/main/svg</sourceDirectory>
    <outputPackage>com.example.icons</outputPackage>
    <implementsResizableIcon>true</implementsResizableIcon><!-- Defaults to false -->
    <stopOnFailure>false</stopOnFailure> <!-- Defaults to true -->
   </configuration>
  </execution>
 </executions>
</plugin>

thirdparties-maven-plugin-1.0 released!

Use thirdparties-maven-plugin to easily copy/download external files and attach them as classified artifacts.

The project is hosted in maven central so no special setup is needed to use it.

Here is the snippet for the 1.0 version :

<plugin>
 <groupId>org.codeartisans</groupId>
 <artifactId>thirdparties-maven-plugin</artifactId> 
 <version>1.0</version>
</plugin>

Usage

This plugin has only one goal : attached.

Configuration using a property file

<configuration>
 <thirdPartiesFile>${project.basedir}/path/to/yours.properties</thirdPartiesFile>
</configuration> 

Property file syntax is as follow:

[classifier].[type].src=[url]
[classifier].[type].md5=[md5] 

Here is a quick example:

foo.tar.gz.src=http://example.com/Foo-1.2.3-r5635.tar.gz
foo.tar.gz.md5=94c331b029ab45d7db5d39cccacdf0e1 

The md5 statement is optional and used only if present. If absent a file that already exists is not downloaded.

Configuration inside the POM

Here is a quick example:

<configuration>
 <thirdParties>
 <thirdParty>
 <classifier>foo</classifier>
 <type>tar.gz</type>
 <src>http://example.com/Foo-1.2.3-r5635.tar.gz</src>
 <md5>94c331b029ab45d7db5d39cccacdf0e1</md5>
 </thirdParty>
 </thirdParties>
</configuration>

artifactinfo-maven-plugin-1.0 released!

artifactinfo-maven-plugin generate java code with constants containing maven project metadata for use in your code.

The project is hosted in maven central so no special setup is needed to use it.

Here is the snippet for the 1.0 version :

<plugin>
 <groupId>org.codeartisans</groupId>
 <artifactId>artifactinfo-maven-plugin</artifactId> 
 <version>1.0</version>
</plugin>

It is very simple to use:

  • it has only one goal : artifactinfo
  • without configuration it use sensible defaults reusing groupId and artifactId for package and class name
  • you can override default package name with the packageName configuration parameter
  • you can override default class name with the className configuration parameter

Swing On Steroïds 1.2 Released

Today I released Swing On Steroïds 1.2 under the Apache Licence 2.0.

Swing On Steroïds is a micro-framework bringing awesomness to Swing development with Supervising Presenters and Passive Views (aka. MVP), a MessageBus and optionaly Guice or Qi4j.

It’s largely inspired by the work of Ray Ryan at Google on the GWT Wave client and his presentation at Google IO 2009 titled Best Practices for Architecting GWT App.
I’d say that watching this video is the first step to understanding Swing On Steroids.

It’s been used in production apps for about a year now with success : it’s modular, refactorable and work for small or big applications.

Among some enchancements, this release is the first one where non-ui related code (threading, forking, messagebus etc…) is available in a separate jar.

At this time the documentation is really poor. I hope to find time to write some.
If you’re interested, read about the patterns mentionned above and then dig into the code. If you understand the patterns it won’t be hard to understand and get started.

As a bonus, a versatile wizard api using the same patterns, a graph model and commodities such as BlockingView easing in and out smoothly thanks to Trident is provided.

You can find the jars and dependency snippets in Maven Central.

Tell me what you think.

Getting used to gradle, a case study : developing Qi4j

Lately Qi4j moved from maven to gradle:

Qi4j community migrated away from Maven after several years of frustration, especially around release management, versioning and cross-module dependency resolution issues, in Feb 2011. The tool of choice is now Gradle.

What ?

The case study I want to describe today is quite simple. I’m writing an application using Qi4j, it’s build is maven based. As I am contributing to Qi4j alongside the development of my own application I’m using the development branch of Qi4j most of the time. In maven terms it means my application depends on the last version SNAPSHOT. I want to continue working this way so I’ll describe here how to use the Qi4j build system for this use case.

In other words, you’ll learn how to manage the Qi4j build system for developing Qi4j and use it in maven projects.

What not ?

I will not talk about IDE support here, only build systems, namely maven and gradle.

Making it work

The main goal is to find gradle commands for different aims and make their run as short as possible.

I used the same computer for all time mesures present in this post, a Samsung netbook N150 with 2GB RAM and a Vetrex II solid state drive from OCZ.

Commands described here last from 45 minutes to 5 minutes for building and installing the whole Qi4j ecosystem in the local maven repository. When dealing with single modules all this gets very quick. For example org.qi4j.core.api can run in 20 seconds when skipping tests and javadoc.

Here are some example gradle commands. I use the gradle daemon to get rid of the startup time.

$ gradle install -Dversion=1.3.0-SNAPSHOT

This one takes forever, it will buid and install locally all artifacts (main, -sources, -javadoc),run tests and then generate the qi4j-sdk distribution archives. Took my netbook ~40 minutes.

$ gradle -x test -x javadoc -x javadocJar -x sourceJar -x :javadocs -x :distLayout -x :tarBinaries -x :tarSources -x :zipBinaries -x :zipSources install -Dversion=1.3.0-SNAPSHOT

This one build and locally install all main artifacts skipping tests, javadocs, sources and distribution archives. Took ~5 minutes on my netbook.

$ gradle -a -x test -x javadoc -x javadocJar -x sourceJar -x :javadocs -x :distLayout -x :tarBinaries -x :tarSources -x :zipBinaries -x :zipSources :org.qi4j.libraries:org.qi4j.library.servlet install -Dversion=1.3.0-SNAPSHOT

This one build and install only the org.qi4j.library.servlet artifact, skipping tests, javadocs and sources archives and ignoring changes in other modules. Took ~15 seconds, now that gets usable !

Theses are quite hairy, aren’t they?

Getting easy

To ease my work I wrote some shell scripts around gradle. They are available on github here: https://github.com/eskatos/qi4j-dev-scripts

Here is the help of the qi4j-build command:

paul@petit:~/src/github/qi4j-sdk$ qi4j-build 
qi4j-build [-p group:project] command [flags]

  -p Select the target project
    group can be core, library, extension, tool, sample or tutorial
    project is the base name of the targeted submodule

  Available commands
    clean            Clean output
    test             Run tests
    install          Install only main artifacts
    devinstall       Install javadoc and sources artifacts
    distinstall      Install distributions archives

  Available flags
    skipTests        Skip tests

  Examples
    qi4j-build clean
    qi4j-build devinstall
    qi4j-build library:servlet test
    qi4j-build libraries install
    qi4j-build distinstall

Feel free to report issues, fork and request pull.

Another scpresume alias with rsync

File copy over ssh is nice but it has no resume support. That can be a pain if dealing with big files and/or poor connectivity.

As a reminder to myself here is a shell alias I use :

alias scpresume='rsync -Pazhv -e ssh'

  • -P is the same as –partial –progress, this enable progress indication and partially downloaded files transfer to be resumed
  • -a activate archive mode to be recursive
  • -z enable compression
  • -h outputs human readable units
  • -v add more verbosity, especially reassuring with poor connectivity
  • ‘-e ssh’ is needed to use ssh as transport, you can change this to ‘-e “ssh -p XXXX”‘ if you need to change used port or any other ssh options