Hi all, as you may know TurmericSOA has a multi-module project structure, as example take a look at Rate Limiter module under turmeric-security project:
turmeric-security/ratelimiter
|
|---RateLimiterService
|---RateLimiterProvider
|---RateLimiterCounterProvider
|---RateLimiterServiceConsumer
|---RateLimiterServiceImpl
|---RateLimiterErrorLibrary
|---RateLimiterCounterMapProviderImpl
|---RateLimiterCounterCassandraProviderImpl
|---RateLimiterProviderImpl
|readme.txt
|pom.xml
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
mvn clean package –pl RateLimiterCounterMapProviderImpl -am
That builds RateLimiterService, RateLimiterCounterProvider and RateLimiterCounterMapProviderImpl
__________________________________________________
Or build my project and its dependants: –also-make-dependents or -amd
mvn clean package -pl RateLimiterCounterMapProviderImpl -amd
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.
__________________________________________________
- Dependencies and versions
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
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.
__________________________________________________
By default maven works with --fail-fast or -ff option. That is the multi-module build stops as soon a module fails.
mvn clean package -> -ff option by default
...the output:
[INFO] ————————————————————-
[INFO] ————————————————————————
[INFO] Reactor Summary:
[INFO]
[INFO] turmeric-ratelimiter-parent ………………….. SUCCESS [2.177s]
[INFO] Rate Limiter :: Rate Limiter Service ………….. SUCCESS [17.947s]
[INFO] Rate Limiter :: Rate Limiter Provider :: Interface FAILURE [0.361s]
[INFO] Rate Limiter :: Rate Limiter CounterMap Provider :: Interface SKIPPED
[INFO] Rate Limiter :: Error Library ………………… SKIPPED
[INFO] Rate Limiter :: Rate Limiter Service :: Consumer .. SKIPPED
[INFO] Rate Limiter :: Rate Limiter Service :: Impl …… SKIPPED
[INFO] Rate Limiter :: Rate Limiter CounterMap Provider :: Impl SKIPPED
[INFO] Rate Limiter :: Rate Limiter CounterCassandra Provider :: Impl SKIPPED
[INFO] Rate Limiter :: Rate Limiter Provider :: Impl ….. SKIPPED
[INFO] ————————————————————————
[INFO] BUILD FAILURE
[INFO] ————————————————————————
__________________________________________________________
You can use the --fail-at-end or -fae option to continue the build despite some modules has failed.
mvn -fae clean package -Dmaven.test.skip=true -> just to avoid my tests during the build process
...the output:
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] turmeric-ratelimiter-parent ....................... SUCCESS [1.959s]
[INFO] Rate Limiter :: Rate Limiter Service .............. SUCCESS [29.078s]
[INFO] Rate Limiter :: Rate Limiter Provider :: Interface FAILURE [0.309s]
[INFO] Rate Limiter :: Rate Limiter CounterMap Provider :: Interface SUCCESS [13.085s]
[INFO] Rate Limiter :: Error Library ..................... SUCCESS [6.886s]
[INFO] Rate Limiter :: Rate Limiter Service :: Consumer .. SUCCESS [5.550s]
[INFO] Rate Limiter :: Rate Limiter Service :: Impl ...... SKIPPED
[INFO] Rate Limiter :: Rate Limiter CounterMap Provider :: Impl SUCCESS [7.367s]
[INFO] Rate Limiter :: Rate Limiter CounterCassandra Provider :: Impl SUCCESS [8.224s]
[INFO] Rate Limiter :: Rate Limiter Provider :: Impl ..... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
__________________________________________________________
...and finally the preferred tool for dishonest developers 
--fail-never or -fn
mvn -fn clean package -Dmaven.test.skip=true -> just to avoid my tests during the build process
...the output:
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] turmeric-ratelimiter-parent ....................... SUCCESS [1.959s]
[INFO] Rate Limiter :: Rate Limiter Service .............. SUCCESS [29.078s]
[INFO] Rate Limiter :: Rate Limiter Provider :: Interface FAILURE [0.309s]
[INFO] Rate Limiter :: Rate Limiter CounterMap Provider :: Interface SUCCESS [13.085s]
[INFO] Rate Limiter :: Error Library ..................... SUCCESS [6.886s]
[INFO] Rate Limiter :: Rate Limiter Service :: Consumer .. SUCCESS [5.550s]
[INFO] Rate Limiter :: Rate Limiter Service :: Impl ...... SKIPPED
[INFO] Rate Limiter :: Rate Limiter CounterMap Provider :: Impl SUCCESS [7.367s]
[INFO] Rate Limiter :: Rate Limiter CounterCassandra Provider :: Impl SUCCESS [8.224s]
[INFO] Rate Limiter :: Rate Limiter Provider :: Impl ..... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] + Ignoring failures
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
draw your own conclusions based on the outputs and your needs....
Now enjoy your new free time with the use of these tips....