Artifact Size. A story of size enforcement.

So it looks like I’ve not been posting here for quite some time. Last post was in 2017…

The maven enforcer on the binary size can be a very useful tool as well as disruptive and close to useless. I think, in this world of cloud deployment and containers it’s getting again useful as you want a microservice to be as little as possible and be aware if it breaks a certain limit.

I said it: a microservice. What if you are working on a HUGE monolith comprised by 185 different OSGi bundles and God only knows how many other form of binary content are distributed in there?

In this last case, you may have a limit, with some margin and then the size is creeping closer and closer to the limit. Then you send your PR, which increase the size by just 2KB and BANG! Fails the check. WTF! You sure think… not my fault. Why on earth… regardless.

The point now is to find if there has been any commit which pushed the size considerably in the “recent past”. A task that done by hand can be tedious and error prone. So here’s another script. With a very imaginative name:

What it does is fairly simple. it takes 3 mandatory parameters: repo, name and numer of commits. Repo is the path to a local git clone of the project, name is the relative path to the generated artifact (the jar) and number of commits is, well…, the number of commits you want to go back in time.

Don’t worry, if just invoke it without any parameter it will give you a help.

It will then take that number of commits, go back in time and start working forwards one commit a time packaging your project and collecting in target/ a CSV with the meaningful info like: commit hash, size and something more. You can then open this CSV file in open office (for example) and start playing with filters, putting it through a complex pipe of bash command or, why not, read it as it is.

If you’re lucky like me, you can find a single commit pushing considerably the size (20MB+) and therefore can work with the developer on what can be done (reverting?).

Potential future improvements? Here are some ideas and PR are always welcome

  • get a % of increase as argument and flag already any commit that goes beyond such threshold.
  • take the above % and work with bisect pinning down the first commit that bumped the size beyond such threshold.

Bash: compute dates

Often I found myself in the need of computing some math on dates. For example what is 10 weeks from a given date? Rather than opening a calendar and start counting you can quickly open a bash shell.

Example: what’s 6th of June 2017 plus 10 weeks?

$ date -j -v '+10w' -f '%Y-%m-%d' '2017-06-06'
Tue 15 Aug 2017 10:00:20 BST

OSX Restarting GDrive App

If you use Google Drive and the OSX app, and like me you often travel and change network connection (VPNs count as well), you may have noticed that it won’t connect anymore.

While I don’t know why exactly, it may be due to some security things in the app itself, I noticed that by restarting the app it connects successfully.

Having to do it more than once a day, here is a simple script that with a double-click will restart it.

How many CQ5 concurrent users?

Defining the concept of concurrent user in the web world is difficult and it’s even more difficult to do it in CQ as it doesn’t keep any session informantion. Technically speaking I define two users as concurrent when a request from user A has not finished yet that the one from B starts.

Don’t know if it’s possible to achieve such information just by looking at CQ logs but the analyse-access tool help you in the analysis of the access.log files that CQ produces giving you some numbers in a very handy markdown format that can be then converted to PDF for presenting it to the business.


CQ5 backup your sources from CRX

El grito de la gaviota - Seagull scream

by Dani_vr via flickr

updated on Feb 15th, 2011

Yes, it happens. CRX has lost my sources from one day to another. As usual you realize that you need a backup when it’s too late. So the question became: how can I backup my sources outside the crx? Packages!

First you have to create a package of what you want to backup via the package manager provided with CRX. I wont go in details of this operation. Then you can call every package operation from a command line like bash and curl application. Fortunately Mac OS X and Linux come with cURL out of the box so nothing special is needed.

Just download the pdf containing the bash code, fix the variable according to your needs and schedule it or execute by hand.

The script is missing at all the error checking and some other things but works well for the moment; maybe in the future I’ll start a new SF project with the script source.

For more information here is a couple of links (same page)

Changing $PATH in Mac OS X

Two Paths Through the Tangled Japanese Forest

by Stuck in Customs via flickr

I’ve started few days ago using Mac OS X. While I still prefer Linux I appreciate the fact that I have the bash power within and I don’t have to go for cygwin anymore. However cygwin is a great tool!

The first thing I had to do was changing the PATH environment variable in my shell for having the newly installed XAMPP binaries. Here is how: edit your ~/.profile file (create it if not exists) and add/change the line export PATH=$PATH:/path/to/your/bins.

Easy! 🙂

[bash] format date

It happens often a script I have the needs to append a simple timestamp in the format of YYYYMMDDHHMMSS to a generated file.

It’s very easy to get it to work in pure bash, without perl script and similia. Just use the native date command with his format option. Easy as drinking a glass of water, the command is (for the format above)

$ date +”%Y%m%d%H%M%S”

for the full detail of the format arguments, refer to the man page.

A simple usage in script is

set -e

NOW=`date +”%Y%m%d%H%M%S”`

echo $FILE