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

Maven, help-plugin and continuous integration

MavenWhen a maven build fails in continuous integration you often end up reading the console output, sometimes browsing kilobytes of text (yes, maven outputs a lot and can seem chaotic). To ease build debugging you can tell maven to output some introspectional data.

The idea is to use the maven-help-plugin a lot but you can add others and home made ones to the mix. To quickly see what can easily get outputed my maven you can play with the following commands :


mvn help:system
mvn help:active-profiles
mvn help:effective-settings
mvn help:effective-pom

Here is a sample output of the active-profiles goal :

[INFO] ------------------------------------------------------------------------
[INFO] Building my-project
[INFO] task-segment: [help:active-profiles] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [help:active-profiles]
[INFO]
Active Profiles for Project 'myGroupId:myArtifactId:jar:0.1.0-SNAPSHOT':

The following profiles are active:

- continuous-integration (source: settings.xml)
- libs-daily (source: pom)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

Adding such output at the very start of builds is really handy when setting up a CI service or during build refactorings.

Note that if a profile is defined in a parent pom it won’t be shown as activated in submodules by help:active-profiles but if you read the help:effective-pom output on one of the modules you’ll see it’s effectively activated, see this comment in MNG-3228.

Hope this helps.

If you read this, you certainly want to read Maven Continuous Integration Best Practices.

Classpath tools : jcfind and JWhich

JavaDeep understanding of Java classpath is something that is too often neglected. I won’t write an article about classpath, internet is full of readings about it :

Here come JWhich and jcfind. Both are classpath reflection tools.

JWhich provides a command line interface and a Java api where jcfind only has command line interface and is written in python.

I prefer to use jcfind from the command line because it’s really faster than Which4j and the command line is more practical. In Java software, I use the JWhich API that is really easy to use. The big drawback of using Which4j from command line is that you must provide a full class name, using it’s API you can search for a class simple name.