title: Shading multiple versions of same dependencies required for functioning application
body: <p>I've got a multi-project application where we use a library, <a href="https://github.com/oshi/oshi/releases" rel="nofollow noreferrer" title="oshi">oshi</a>, that depends on version 4.2.2 of <a href="https://github.com/java-native-access/jna" rel="nofollow noreferrer" title="jna">JNA</a>.
  In our project itself, we use 4.3.0, which hasn't been released yet. We made a contribution that will be in 4.3.0 when it ever gets released, but we need it right now, so we currently use a forked version that we build ourselves.</p>
  
  <p>We package everything up using the maven shade plugin. Currently, the shade plugin uses 4.3.0 in the uberjar.</p>
  
  <p>The problem is that oshi uses a function in 4.2.2 that doesn't seem to be in 4.3.0. The interface we are using was changed, and now we get NoSuchMethodError exception. The exception we get looks like this:</p>
  
  <pre><code>org.quartz.JobExecutionException: org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NoSuchMethodError: com.sun.jna.platform.win32.OleAuto.VariantClear(Lcom/sun/jna/Pointer;)Lcom/sun/jna/platform/win32/WinNT$HRESULT;]
  at org.quartz.core.JobRunShell.run(JobRunShell.java:218) [quartz-2.2.3.jar:?] 
  at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.2.3.jar:?]
  
  Caused by: org.quartz.SchedulerException: Job threw an unhandled exception.
  at org.quartz.core.JobRunShell.run(JobRunShell.java:213) [quartz-2.2.3.jar:?]
  ... 1 more
  Caused by: java.lang.NoSuchMethodError: com.sun.jna.platform.win32.OleAuto.VariantClear(Lcom/sun/jna/Pointer;)Lcom/sun/jna/platform/win32/WinNT$HRESULT;
  at oshi.util.platform.windows.WmiUtil.enumerateProperties(WmiUtil.java:504) ~[oshi-core-3.2.jar:3.2]
  at oshi.util.platform.windows.WmiUtil.queryWMI(WmiUtil.java:304) ~[oshi-core-3.2.jar:3.2]
  at oshi.util.platform.windows.WmiUtil.selectUint32sFrom(WmiUtil.java:112) ~[oshi-core-3.2.jar:3.2]
  at oshi.hardware.platform.windows.WindowsGlobalMemory.updateSwap(WindowsGlobalMemory.java:74) ~[oshi-core-3.2.jar:3.2]
  at oshi.hardware.common.AbstractGlobalMemory.getSwapTotal(AbstractGlobalMemory.java:82) ~[oshi-core-3.2.jar:3.2] 
  </code></pre>
  
  <p>So what I need to do is figure out how to have both versions in the uberjar.</p>
  
  <p>I've tried <a href="https://maven.apache.org/components/plugins/maven-shade-plugin/examples/class-relocation.html" rel="nofollow noreferrer" title="relocated">relocating</a> the 4.3.0 version, but it didn't seem to work (the classes weren't in the uberjar anywhere). Further I swear I read earlier today (but of course can't find it now) that the pattern in the relocation field is <code>groupId:artifactId[:type][:classifier]</code> with no option for version.</p>
  
  <p>The relevant portion of my dependency tree looks like this:</p>
  
  <pre><code>myproject
  +-oshi-core
  |   +- jna 4.2.2
  +-jna 4.3.0-CUSTOM
  </code></pre>
  
  <p>Can anyone give me any suggestions on how to resolve this?
  Thanks!</p>