Localized Maven Repositories – A Hot Tip

I’ve been building a Maven Project that uses some jar files which are not in Maven Central (or any repository). I ran across this article – Local Maven Dependencies. I found it very helpful.

Simply, do the following:

create a directory (d:/folder/repo)

Run a maven deploy to url (it’ll create the repository details based on the flags)

mvn deploy:deploy-file -Durl=file://d:/folder/repo/ -Dfile=Common.jar -DgroupId=xyz -DartifactId=Common -Dpackaging=jar -Dversion=1.0

and add to your Maven Project’s POM
<id>Local Repository</id>

Then reference your jar file with a new dependency.

The code should almost write itself from there 🙂

My Experience with maven-antrun-plugin

I’ve been spending some time with maven so that files which matched a certain criteria were automatically moved in the project – OpenNTF SocialSDK.  The files only should be moved when the files don’t have -SNAPSHOT at the end of the version.

I started modifying some code that used maven-antrun-plugin, which bridges the maven-ant worlds.  I tried mixing complex conditional depends on and unless statements from Ant targets and Ant Tasks. Where the target “depends” on another target, you should be able to conditionally execute a target.  I wrote the code, however it never ran cleanly, always throwing an error.

I split the ant tasks and targets into a separate file, and the code now runs cleanly.  From the best practices I’ve read it’s better to pick one, and only use one Maven file or Ant file, I however couldn’t get it to read depends on targets.

I hope you find this ant-maven hack as helpful as I did.


The solution is found in the commit – added support for automatically moving the cdnjs files when a release.