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

How can I remove module-info.class warning for a shaded .jar?

Filtering out the file in the shade plugin seems to work fine for me. Here’s what my maven-shade-plugin config looks like: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.1</version> <configuration> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>module-info.class</exclude> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> The key line is the <exclude>module-info.class</exclude>. The filter … Read more

What is an uber JAR file?

Ü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

Create standalone jar using SBT

There is a difference between standalone and making a project useable as a dependency or another project. In the first case, you would use a plugin such as sbt-assembly. What it will do is create one jar file containing the project class files along with all of its dependencies. If you write an application, what … Read more

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

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

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

tech