a simple mvn clean package process takes about 9 minutes…no so bad, it could be worst, for example if you build the entire security project….please be patient 🙂

For those kind of projects here I recall you some useful tips building with maven…

Use the maven reactor plugin: in short terms it allows to resume your build process where last fails has placed or simlply from where you specify:

In my case I pasted the RateLimiter module structure based on its dependencies, not alphabetically… Now assume you’ve got a fail at RateLimiterCounterMapProviderImpl module, if you run a simple “mvn clean install” you are running a complete rate limiter project build, instead of that try: –resume-from or -rf

mvn clean package –rf RateLimiterCounterMapProviderImpl

That command just runs RateLimiterCounterMapProviderImpl, RateLimiterCounterCassandraProviderImpl and RateLimiterProviderImpl.

__________________________________________________

Also you can specify a particular module or project to run with the use of –projects or -pl

mvn clean package –pl RateLimiterCounterMapProviderImpl

That build just the indicated project. You can specifiy one or more projects separated by comma.

__________________________________________________

Another option could be, build my project and its dependencies: –also-make or -am

That builds RateLimiterCounterMapProviderImpl and RateLimiterProviderImpl

__________________________________________________

An easy one, working in offline mode: –offline or -o

mvn clean package -o RateLimiterCounterMapProviderImpl

That will not try to download the artifacts from remote repos, you’re an isolated developer 🙂

__________________________________________________

Sometimes I use my own Nexus repo (see Continuous Integration in Local post), so I need to change some
configurations in my maven setting files, to be honest I use two files: –settings or -s

mvn -s ~/.m2/settingsnexus.xml clean package

__________________________________________________
If you are familiar with maven I’m pretty sure you’ve hit your head on the table more than once and you finally decided to manually delete the your .m2 repo. The –update-snapshots or -U option could helps in those annoying times

mvn -U clean package

This will force to download the artifacts despite mvn does not consider them obsoletes.
__________________________________________________

That is a common dependency section in a pom.xml file. But you can specify the version in different ways:
1.8.5 => “Soft” requirement on 1.8.5 as a recommendation
[1.8.5] => “Hard” requirement on 1.8.5
[1.8.1,1.8.5] => Any between 1.8.1 and 1.8.5
[1.8.1,1.8.5) => Any between 1.8.1 and 1.8.4.99….
[1.8.5,) => Any above or equals to 1.8.5
(,1.8.1],[1.8.5,)=> Any below or equals to 1.8.1 OR any above or equals 1.8.5.
__________________________________________________

What-if fails

By default maven works with –fail-fast or -ff option. That is the multi-module build stops as soon a module fails.

During last days I’ve suffered some Internet connection troubles, sometimes connections goes, other it turns very slow, similar at the 56kb modems in the early stages of internet. BTW, thanks to Movistar.

Those ones, can become (or not) in serious issues for an isolated developer or web page designer who could upload his advances once a day, or a week…but it turns critical for this developer who works together a multi-country team in an Open Source project.

For instance, in my daily labor I run maven builds, some days several of them…as you may know these maven builds look for and downloads huge quantities of files, artifacts, or dependencies…off course according your configurations, at least, I have to…….So, the need of an enhancement in this process arose me during these days. Does not take much time to decide one of the better and well-known tools that bring you the ability to manage the provisioning artifacts during development, mainly based on the its simply installation and configuration process. Welcome Nexus to my laptop. Nexus Open Source is available under the GNU Affero General Public License version 3 (AGPLv3): http://opensource.org/licenses/agpl-v3.html.

Is not the intention of this post to tell you what Nexus is or does, for that purpose just surf on the adequate and, for sure more complete; nexus site. Instead of that, I wrote this lines to let you know how to get Nexus working on your computers.

So, firstly some key aspects about nexus:

Nexus is a Jetty unzip and run tool

You can manage your repositories from different approaches, in my case I set them as Proxy Repos: “When you proxy a remote repository with Nexus Open source you can control all aspects of the connection to a remote repository including security parameters, HTTP proxy settings. You can configure which mirrors Nexus will download artifacts from, and you can control how long Nexus will store artifacts and how it will expire artifacts which are no longer referenced by your build….”

Nexus provides a JavaService wrapper for Windows. Just in case u prefer MS W rather than any linux OS

… for a better feature description here you have a copy of the Sonatype Nexus Feature Matrix:

Decompress this file into a folder that you selected as nexus home. This package contains 2 folders inside: nexus-oss-webapp-1.9.1.1, the nexus distribution itself and the sonatype-work, empty for now, that is the folder where your local repo will resid. You can assign different /home/.. folders for each of them, or you can decompress it in just one. I choose that way, both, nexus-oss-webapp-1.9.1.1 and sonatype-work, under a /home/jose/.nexus/ folder. In case you are damning the two-folder structure, just think in upgrading the nexus distribution in your environment, your local repo will remain intact!

Now, under your …./.nexus/nexus-oss-webapp-1.9.1.1/bin/jsw/ folder you can see several distribution folders. I use a linux over 64 bits, so I’m going to work with linux-x86-64. Be sure to run the appropriate according your OS.

Then, let’s create a linux link for nexus path:

ln -s .nexus/nexus-oss-webapp-1.9.1.1/bin/jsw/linux-x86-64/ nexus

You can run nexus as a service or just manually, but you need to remember to run it prior to start you development day. I preferred to set as service., and these were the steps:

Copy either ${NEXUS_HOME}/bin/jsw/linux-ppc-64/nexus, ${NEXUS_HOME}/bin/jsw/linux-x86-32/nexus, or ${NEXUS_HOME}/bin/jsw/linux-x86-64/nexus to /etc/init.d/nexus.

Take care about the repositories id that you set, ie: ebayopensource-snapshots. These need to be the same as you defined in Nexus repo.

And….that’s all!!! now let’s do a maven build.mvn clean package

During this process maven should attempt to download all your artifacts from http://localhost:8081&#8230;.. Of course first time you run your build, your nexus repo is empty so, the consuming time will not be decreased, but, try with your second build.

NOTE: If after your first maven build, maven is still getting some artifacts from any other external repository just review your Nexus Repositories looking for a wrong setup or just for a missing custom repository.