Igor's Blog
Programming, DIY, Games, Hacks, and Tech

The general consensus is when you are having to fight Maven, you're doing something wrong. However, sometimes you get backed into a corner and do have to put up a fight to move forward. I've come across a situation where in order to connect to and use an API hosted as EJBs in WebLogic I needed to have a number of client jar files, 16 in total. I didn't particularly want to have 16 separate dependencies in my own Maven projects and I also wanted to make it as easy as possible for others on the project to access this API. My solution was to look into the creation of an UBER JAR file to hold all the required classes.

This is exactly what the Maven Shade Plugin is designed for. Unfortunately this plugin expects that all of your separate jar files are already present in the Maven repository as individual artefacts. Doh!

I didn't want to have all of the 16 separate jar files in the project Maven repository. I just wanted one artefact, the client that I needed to access the API. So I needed a way around Shade's dependency requirement.

My solution was to use a shell script to do some of the work, then to leverage my local Maven repository before deploying to the hosted project Maven repository. So lets see what I did exactly -

First I put all of the separate jar files that made up the 'API client' into a directory.
 Directory structure
\-- my_work_directory/
\-- client_jars/
\-- clientjar1.jar
|-- clientjar2.jar
|-- clientjar3.jar

Then I wrote a simple shell script that did two things - 1) install all of the jar files from the client_jars directory into my local Maven repository, and 2) created a pom.xml file with Maven Shade configuration to generate the uber jar file and its dependency reduced pom.

Here's what the script looked like:
 Bash Script
function minstall {
classifier=$(basename "$1" .jar|tr -cd '[[:alnum:]]')
mvn -q install:install-file -DartifactId=$artifactId -Dclassifier=$classifier -Dfile="$1" -DgroupId=$groupId -Dversion=$version -Dpackaging=jar
for i in $(ls $1); do
minstall "$1/$i"
cat > pom.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
mvn deploy

Continue reading...  

, , , ,

A month ago I received my 2017 MacBook Pro and with that came the Apple USB-C Digital Multi AV adapter that I needed to connect my monitor with. I also ordered a 'cheap' Chinese clone version from eBay since I use my laptop both at home and at work and didn't particularly want to bring a $99 adapter to the office. I did some testing of these at home and here's what I found out...

Both of the adapters actually look very similar. Unfortunately when you pick up the cheap clone, you can tell the difference immediately. It feels "cheap". Compared to the Apple version it's much lighter and feels empty inside. Its shell is made of metal, which is not necessarily bad, but it definitely doesn't feel as solid as the Apple one. The ports on the cheap clone do not have names/symbols like on the Apple version.

However, keep in mind that the Apple one is $99...

...and the eBay one is under $25, about a third of the price!

Overall the adapters are very similar. I do like that fact that the cheap clone has a blue tab for its USB 3.0 port, which the Apple one doesn't. It also has a slightly longer lead, but the points where the lead meets the case are not finished as well. That cheap feeling again.

DSC02326.JPG DSC02327.JPG

Continue reading...  

, , , ,

No matter how much you want to escape running graphical applications on a remote Linux server there are times (like when configuring Oracle WebLogic domains for example) that you are forced to do so. Sometimes, the user you have to be running these applications as is not the same as the your login user, this leads to errors like this...
X11 connection rejected because of wrong authentication.
Error: Can't open display: localhost:10.0

Ooops! This is easy to resolve though.

Before continuing, make sure you are running ssh with the -X switch (and that you have an X11 server running on your machine). Now after logging in as your initial user, do this:
xauth list

That will give you some output similar to this...
myhost.mydomain.com/unix:10 MIT-MAGIC-COOKIE-1 1183c75928e9dc95378aa3172b142652

Take note of the above and change to the user you need to run the graphical app as...
sudo su - appuser

Continue reading...  

, ,

I've recently added Banggood banner links to my Blog and noticed that Facebook started to use images of those banners whenever I shared a post that didn't have its own image. This was of course an undesirable behaviour and I looked into various ways of removing it and finally settled on a simple JavaScript approach.

When using the Facebook Debugger this is the kind of summary that I was getting...

The ad image is clearly part of the thumbnail of my shared post. I looked into different ways to fix this and there were a few - I could have used a nested iframe with the ad page loaded inside it, this would require me to generate a whole new HTML page for each banner. I could have also loaded the image using CSS instead of leaving it as an img tag - this required me to change my banner code significantly. These didn't sit well with me so I looked at yet another option which was to use some JavaScript, jQuery in my case, to set the content of a div element that held the ad - this required no change to my banner code.

I already had a div element to hold the ad, all I needed to do was give it an ID, like so:
<div id="banggood_banner" class="banggood_banner"></div>

Notice this is an empty div. This is where my Blog's template engine (Smarty) would typically inject ad code, I removed that injection. The template still needed the ad code however, but it was going to be used differently now.

At the bottom of my page (after jQuery scripts were loaded) I added the following bit of code that set the innerHTML value for the div element I've defined above, by calling the html() function...

Continue reading...  

, , , ,

Recent Blog Posts

A hack to create an uber jar with the Maven Shade Plugin using local jar files

Is it worth it? Apple USB-C Digital Multi AV adapter vs a cheap eBay clone

Running X11 graphical applications after changing to another user using 'sudo su'

How to stop Facebook using ad images as post sharing thumbnails

Picking lists for Atari Lynx capacitor replacement kits

Performance - 2012 Retina MacBook Pro vs 2017 MacBook Pro

Look and feel - 2012 Retina MacBook Pro vs 2017 MacBook Pro

Using math to work out the diameter of hard to reach water cooling pipes

How to get the unreachable shard in the Hinterlands in DragonAge Inquisition

Measy RC12 wireless 2.4Ghz keyboard touchpad review

Recent Galleries

Monument Valley 2 is released and does not disappoint

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

DIY indoor apartment grow light wiring

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
300 George St Blogumentary

My Online Tools

UUID to OID Converter
Guru JSON-RPC Tester
Extrudifier Object Designer
Travel ┬ÁBlog

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Don't forget to
me for more great articles!
Don't show this again