aboutsummaryrefslogtreecommitdiff
path: root/examples/uber-jar-example/README.md
blob: e4f8da0d3d67976a6c968218ef6e9377b3c0e2a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
### Uber-jar plugin example

This example shows how to build uber jar(aka fat jar) with `UberJar` plugin.

In order to create uber jar: execute `cbt uberJar`. Produced jar will be in target folder.

By default, jar name is your `cbt name`, you can provide other name via overriding `uberJarName` task.

By default, main class is `Main`. You can provide custom main class via overriding `uberJarMainClass` task.

To run your main class you can execute `java -jar your-jar-name.jar`.

You can also run scala REPL with your jar classpath and classes with this command: `scala -cp your-jar-name.jar`.

In scala REPL you will have access to all your project classes and dependencies.

```
scala -cp uber-jar-example-0.0.1.jar
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_72).
Type in expressions for evaluation. Or try :help.

scala> import com.github.someguy.ImportantLib
import com.github.someguy.ImportantLib

scala> ImportantLib.add(1,2)
res0: Int = 3

scala> ImportantLib.currentDirectory
Current directory is: /Users/rockjam/projects/cbt/examples/uber-jar-example/target

scala> Main.main(Array.empty)
fooo
Current directory is: /Users/rockjam/projects/cbt/examples/uber-jar-example/target
not empty list

scala> import shapeless._
import shapeless._

scala> 1 :: "String" :: 3 :: HNil
res3: shapeless.::[Int,shapeless.::[String,shapeless.::[Int,shapeless.HNil]]] = 1 :: String :: 3 :: HNil
```