Home > Maven Mojos > maven-external-dependency-plugin

maven-external-dependency-plugin

February 7th, 2010 Leave a comment Go to comments

Well, I have started my first open source project. It is called “maven-external-dependency-plugin“ and is hosted over on the Google Code site. I started using Maven about a year ago in a large project at work and have really gown to love all that it offers and its immense extensibility. We use Maven for Java and Adobe Flex based projects and it works very well for us. However, one of the really frustrating things for me is to come across dependencies that are not hosted in a public Maven repository. On the Java side, this is a bit of a more rare occurrence, but with Flex, a large portion of that community is not Maven-minded. This means that I have to mange those dependencies by adding them to my local M2 repository and then manually deploy them to a group repository so that all team members can access these artifacts. Keeping them up to date becomes a pain mainly because of the manual effort involved and because it is not part of the standard workflow. I have been using batch files for managing these one-offs but that leaved me as the sole person responsible for maintaining these dependencies.

So … there has to be a better way … Right?

Well, I have thought for a long time … wouldn’t it be helpful to have a Maven plugin that could automatically download a file from a URL and install it to my local repository and them maybe also deploy it to my group’s Maven repository?    I has looked around at several Maven plugins out there trying to piece together a solution to perform this task.  But I did not find an out of the box solution that could be easily implemented and be robust and straight-forward.   So why not created my own mojo and contribute to the community?   How difficult could it be?

My first experience with Maven plugin development was working on a custom modified version of the Israfil Flex plugin to compile our Flex-based projects about a year ago.  Out of the box it got me to 90% of what I needed to accomplish, but there were something it could not do when compiling Flex modules, I don’t remember the specifics now but I think it had something to do with compiling multiple Flex modules and generating multiple module artifacts in a single project.  I abandoned this effort long ago in favor of the much more capable and powerful  “flex-mojos“.  So I jumped into the Java code for this plugin and made the necessary tweaks to meet my needs.

I remembered how simple it was to extend and how easy it was to create a Maven plugin so this weekend I created the “maven-external-dependency-plugin“.  This Maven (mojo) plugin is used to aid in managing external Maven artifacts that are not published public Maven repositories.

The goal of this project is to allow you to define a configuration for external (not hosted in M2 repo) artifacts that will automatically download the artifact, install to you local M2 repository and optionally deploy to your team/company M2 repository.

Granted there is still a bit of manual effort involved for updating the POM configuration information for these external dependencies when new versions are available, but this should eliminate the manual effort of having to install and deploy these types of files by hand.

Here is an example of an artifact configured to download from an external URL and install to the local Maven repository

   <!-- THIS JAR IS HOSTED ON GOOGLE CODE,
        BUT IS NOT AVAILABLE IN A MAVEN REPO -->
   <artifactItem>
       <groupId>com.google.code</groupId>
       <artifactId>google-api-translate-java</artifactId>
       <version>0.92</version>
       <packaging>jar</packaging>
       <downloadUrl>
          http://google-api-translate-java.googlecode.com/files/google-api-translate-java-{version}.jar
       </downloadUrl>
       <install>true</install>
       <force>false</force>
   </artifactItem>

Please visit this link for a complete example of a POM file configured to this this plugin: http://code.google.com/p/maven-external-dependency-plugin/source/browse/trunk/maven-external-dependency-plugin-test/pom.xml

Please visit the “maven-external-dependency-plugin” project site on Google Code for more information.

Categories: Maven Mojos
  1. February 7th, 2010 at 19:12 | #1

    Hi,

    I do like your initiative, specially on the flex universe it is a real pain to find anything on maven central… nor Flex SDK nor 3rd party libraries are deployed there.

    FWIW, I started on maven plugin development on a much similar way, but instead of israfil I started hacking servebox… eventually I figured that was too much pain and the project seemed death, so I decide to start a fresh one.

    For sure I will advice flexmojos users about your plugin and may use it in the future if it begins to support zipped artifacts (I wrong a ticket on code google).

    VELO

  2. February 8th, 2010 at 00:16 | #2

    Hi Velo,

    Thank you for the words of encouragement and for noticing my little project. By the way, I did abandon Israfil long ago in favor of your much more capable flex-mojos plugin. When I first started working in Flex and Maven, I was new to both technologies and back then the Israfil plugin seemed easier for someone to get up and running without much effort and without in-depth knowledge. But it wasn’t long before I started running into more complex needs that the Israfil plugin just could not support. I started extending it to meet my needs and that was OK, but I did not like the idea of having this one off customization and the demands for change kept growing. Ultimately I delved into the flex-mojos plugin and converted all out projects to use it instead. It did take a more in depth investment of time and learning curve to get up and running with the flex-mojos, but I can say looking back, there are no regrets. Flex-mojos have provided me with a solution for every curve I have thrown at it and we have a fairly complex build. Also its support for pulling down the flex compiler artifacts rather than being dependent on a local install of the flex SDK was very nice since we use both Windows and Linux platforms for Maven builds.

    So, let me take this moment to extend a BIG THANK YOU for all your efforts on that project!

    I agree that dependency management in the Flex development world is a bit out of sorts and including non-maven-hosted flex dependencies is a pain. Your project and M2 repository hosting the Flex SDK artifacts is a huge benefit for all of us Flex-Mavenites, I certainly wish Adobe and the community would embrace Maven. I will follow up on your zipped artifacts support topic on the Google code site, I like the idea and will do what I can to include it :-)

    Thanks Again, Robert

  1. No trackbacks yet.