Andrey Hihlovskiy

Professional blog on groovy, gradle, Java, Javascript and other stuff.

Script for batch installation of maven artifacts

I created gradle script that delivers batch installation of maven artifacts to local maven repository (source code here: https://github.com/akhikhl/contribs).

The script supports two tasks – installContribs and cleanContribs – but can be extended with additional tasks (for example, implementing deployment to corporate repo).

how it works:

1. you call it with the command-line:

gradle -b contribs.gradle

(or you rename script to “build.gradle” and just put it somewhere in the multi-project tree, it will be called by gradle automatically).

2. installContribs task iterates the current folder (where the script resides) and all it’s subfolders

3. in each folder it iterates files with extension “pom”

4. for each found pom-file it looks for “.jar”, “-sources.jar” and “-javadoc.jar” and install all found files (together with pom) to the local maven repository.

5. pom-file without jars will be installed as an artifact on it’s own. Typical use-case: installation of parent-poms and aggregator-poms.

The script accurately calculates inputs/outputs. If all files were not changed since the last installation, it does not install anything and shows “UP-TO-DATE” in the console.

cleanContribs task makes script “forget” about the time of the last artifact installation. As the result, running script with installContribs task will install all artifacts anew.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: