eskatos's thoughts

Posts Tagged ‘maven

flamingo-maven-plugin-1.1 released!

with one comment

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>

Written by Paul

June 26, 2011 at 2:14 pm

Posted in Code, Projects, Tools

Tagged with , , , , ,

thirdparties-maven-plugin-1.0 released!

leave a comment »

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>

Written by Paul

June 22, 2011 at 8:04 pm

Posted in Code, Projects, Tools

Tagged with , ,

artifactinfo-maven-plugin-1.0 released!

leave a comment »

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

Written by Paul

June 22, 2011 at 7:38 pm

Posted in Code, Projects, Tools

Tagged with , ,

Getting used to gradle, a case study : developing Qi4j

with 2 comments

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.

Written by Paul

April 10, 2011 at 1:54 am

Posted in Code, HOWTOs

Tagged with , , , ,

Maven, help-plugin and continuous integration

leave a comment »

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.

Written by Paul

October 28, 2009 at 9:57 pm

jaroverlay-maven-plugin is dead, long live truezip-maven-plugin

leave a comment »

MavenI think I was the only humain being using my jaroverlay-maven-plugin.

Now that truezip-maven-plugin has been published I refactored my builds to use it. It is not only working but it’s both quicker and cleaner with this plugin.

As a consequence I discontinue jaroverlay-maven-plugin development.

Written by Paul

April 23, 2009 at 9:07 am

Posted in Projects, Tools

Tagged with , ,

A maven plugin to repackage your java archives : jaroverlay-maven-plugin

with 2 comments

MavenIn the Java EE 5 TutorialDevelopment Roles” chapter we can see the following three roles, from the code to the deployment :

  • Application Component Provider: “The application component provider is the company or person who creates web components, enterprise beans, applets, or application clients for use in Java EE applications.”
  • Application Assembler: “The application assembler is the company or person who receives application modules from component providers and assembles them into a Java EE application EAR file.”
  • Application Deployer and Administrator: “The application deployer and administrator is the company or person who configures and deploys the Java EE application …”

This page says that this is the Application Assembler job to configure the deployment descriptor before packaging the EAR.

Beside that, artifact produced by mavenized enterprise projects are EARs, already packaged. Plus, it often is the developer (or Application Component Provider) that write the packaging configuration.

Next comes the “configuration for deployment” time. Here, if deployment dependant configuration is in deployment descriptors you would have to unpack the EAR and possibly nested java archives (WARs and/or JARs) to get a hand on all deployment descriptors.

This task can be quite cumbersome and time consuming (really dumb too). Read the rest of this entry »

Written by Paul

August 3, 2008 at 6:32 pm

Posted in Projects

Tagged with ,

Follow

Get every new post delivered to your Inbox.