Idea artifact fat jar creation: how to duplicate in Gradle

I’m developing extensions for a commercial app.

These extensions run within the main app when I place a jar file in the apps special ‘extensions’ folder.

So, this is like library development as there is no ‘main’ class, and no exectuable application.

If my extensions require dependent libraries, the app also has a special ‘ext’ folder to place them in. So far, I’ve had no problems placing my extensions and having them use the dependent libraries.

But, I’m wanting to share my extensions with others without having them need to mess with external libs, so want to create fat jars with embedded libs.

Unfortunately, the usual suspects in gradle to create fat jars, all fail to load properly into the app. So far I’ve tried the Shadow plugin, and the standard ‘fatJar’ gradle task everyone uses, which includes the code:

configurations.compile.collect { 
            it.isDirectory() ? it : zipTree(it) 

While they both successfully create fat jars, I get many errors on loading, including ‘no class definition found’ errors.

The one thing I found that did the job was using Idea’s ‘Artifacts’ tool, accessed via the ‘Project Structure’ dialog. Found instructions here, under Variant #2

Building my artifact manually this way loads without error into my app.

So, the question from my post subject: does anyone have a gradle task, that in part, or fully duplicates how Idea is doing this?

How IntelliJ is doing it depends on how you configured it.
But basically the shadow plugin of John Engelman should indeed be the best option to build such a bad-practice fat jar.
If it does not work but your IntelliJ built one works, maybe use IntelliJ to diff those two jars to see where the difference is.

Thanks, I’ll try it.

Idea: it would be neat if Intellij had a ‘create Gradle script from process’ button when creating artificats :wink: .

Tell them, that’s an IntelliJ topic, not a Gradle topic. :wink: