Azure-sdk-for-java: [QUERY] Azure SDK Shading

Created on 11 Mar 2020  路  4Comments  路  Source: Azure/azure-sdk-for-java

Query/Question
I am running into issues trying to generate a shaded JAR for the azure-storage-blob SDK (12.4.0) based on the pom.xml snippet noted to the wiki page. Can someone confirm that the configuration snippet is always valid/applicable or wether there is missing/placeholder configuration metadata that needs to be supplied ? The <!--YOUR_APPLICATION_MAIN_CLASS --> parameter seems like a place-holder and is unclear what the relevant class path to use is.

I am getting the following error when trying to build with the snippet copied into the pom.xml (without any alterations): [ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.0.0:shade (default) on project azure-storage-blob: Error creating shaded jar: null: IllegalArgumentException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.0.0:shade (default) on project azure-storage-blob: Error creating shaded jar: null

Why is this not a Bug or a feature Request?
Shading isn't supported

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [+] Query Added
  • [+] Setup information Added
Client Docs customer-reported question

Most helpful comment

@anuchandy Awesome, I was able to successfully generate the shaded JAR . Thanks to both you and @joshfree for all your help.

All 4 comments

Hi @abelmariam thanks for posting the question. Yes, you'll need to specify the fully.qualified.MainClass which contains the application's entry point within the <mainClass> </mainClass> tags and not leave the field blank.

@anuchandy can you please help clarify this in the wiki?

@abelmariam please let us know if you have any other questions.

Ok, thanks for the prompt follow up @joshfree. Just to clarify (might be a noob maven question) but is the snippet supposed to defined in the pom.xml associated with the SDK itself or the one associated with my application ? Based on the fact we have to specify a class from the client application main class in the snippet block, I would assume it would be the client application's respective pom.xml.

Unfortunately, the application I am working on does not use maven not sure how to go about generating this JAR without having to go through the setup of a maven project (not a build tool I'm especially familiar with). Is there any way I can simply download the JAR somewhere ?

@abelmariam - Like Josh pointed the pom snippet in the wiki represents the application's pom file and <mainClass> should contain the application's main class entry point. Note that this is when you want to "Shade your entire application", where resulting jar includes your application code and dependencies i.e. blob-storage and other dependencies mentioned in your application pom file.

If I understand correctly what you're looking for is - you don't want to shade the entire application, instead, want the application to take a dependency on shaded blob-storage. So we're looking for a way to generate "shaded blob-storage jar".

Created a java project for that:

  1. download the zip storage-blob-shade.zip
  2. unzip e.g. c:\storage-blob-shade.
  3. From console switch to this dir c:\storage-blob-shade and run mvn package. This will produce the shaded jar azblobstorageshadedlib-1.0-SNAPSHOT-shaded.jar under C:\storage-blob-shade \target\.

Now your app can refer to this shaded jar (and can remove any maven dependency to stroage-blob package)

@anuchandy Awesome, I was able to successfully generate the shaded JAR . Thanks to both you and @joshfree for all your help.

Was this page helpful?
0 / 5 - 0 ratings