Building a self-executable JAR with Gradle and Kotlin

Add the plugin application, then set the mainClassName as mainClassName=”[your_namespace].[your_arctifact]Kt” For instance, suppose you have placed the following code in a file named main.kt: package net.mydomain.kotlinlearn import kotlin import java.util.ArrayList fun main(args: Array<String>) { println(“Hello!”) } your build.gradle should be: apply plugin: ‘kotlin’ apply plugin: ‘application’ mainClassName = “net.mydomain.kotlinlearn.MainKt” In fact Kotlin is building a … Read more

Why does format(“kafka”) fail with “Failed to find data source: kafka.” (even with uber-jar)?

kafka data source is an external module and is not available to Spark applications by default. You have to define it as a dependency in your pom.xml (as you have done), but that’s just the very first step to have it in your Spark application. <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-sql-kafka-0-10_2.11</artifactId> <version>2.2.0</version> </dependency> With that dependency you have … Read more

Building an uberjar with Gradle

I replaced the task uberjar(.. with the following: jar { from(configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) { exclude “META-INF/*.SF” exclude “META-INF/*.DSA” exclude “META-INF/*.RSA” } manifest { attributes ‘Implementation-Title’: ‘Foobar’, ‘Implementation-Version’: version, ‘Built-By’: System.getProperty(‘user.name’), ‘Built-Date’: new Date(), ‘Built-JDK’: System.getProperty(‘java.version’), ‘Main-Class’: mainClassName } } The exclusions are needed because in their absence you will hit … Read more

Is it possible to create an “uber” jar containing the project classes and the project dependencies as jars with a custom manifest file?

Actually, I didn’t check what the maven-shade-plugin is doing exactly (or any other plugin) as maven 2 has everything built-in to create a megajar or uberjar. You just have to use the maven-assembly-plugin with the predefined jar-with-dependencies descriptor. Just add this snippet to your pom.xml to customize the manifest: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> … Read more

How to build an Uber JAR (Fat JAR) using SBT within IntelliJ IDEA?

Finally I totally skip using IntelliJ IDEA to avoid generating noise in my global understanding 🙂 I started reading the official SBT tutorial. I created my project with the following file structure : my-project/project/assembly.sbt my-project/src/main/scala/myPackage/MyMainObject.scala my-project/build.sbt Added the sbt-assembly plugin in my assembly.sbt file. Allowing me to build a fat JAR : addSbtPlugin(“com.eed3si9n” % “sbt-assembly” … Read more

Using Gradle to build a jar with dependencies

I posted a solution in JIRA against Gradle: // Include dependent libraries in archive. mainClassName = “com.company.application.Main” jar { manifest { attributes “Main-Class”: “$mainClassName” } from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } } Note that mainClassName must appear BEFORE jar {.

What is a fat JAR? [duplicate]

The fat jar is the jar, which contains classes from all the libraries, on which your project depends and, of course, the classes of current project. In different build systems fat jar is created differently, for example, in Gradle one would create it with (instruction): task fatJar(type: Jar) { manifest { attributes ‘Main-Class’: ‘com.example.Main’ } … Read more

What is an uber jar?

Ãœber is the German word for above or over (it’s actually cognate with the English over). Hence, in this context, an uber-jar is an “over-jar”, one level up from a simple JAR (a), defined as one that contains both your package and all its dependencies in one single JAR file. The name can be thought … Read more