fatjar with gradle and shadowjar

1,023 views
Skip to first unread message

ash.ta

unread,
Dec 30, 2015, 12:15:09 PM12/30/15
to Akka User List
hi,

i'm struggling with a gradle build in attempt to build a fatjar.
following some examples i've found, i created the following gradle.build:

import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer

apply
plugin: "java"
apply plugin: "scala"
apply plugin: "com.github.johnrengelman.shadow"

sourceCompatibility = 1.8
version = '0.0.1'

if (!JavaVersion.current().java8Compatible) {
   
throw new IllegalStateException("Java 8 is mandatory for building this project")
}

repositories
{
    mavenCentral
()
    jcenter
()
}

buildscript
{
    repositories
{
        jcenter
{
            url
"http://jcenter.bintray.com/"
        }
   
}
    dependencies
{
        classpath
'com.github.jengelman.gradle.plugins:shadow:1.2.2'
    }
}

dependencies
{

    compile
("com.typesafe.akka:akka-actor_2.11:2.4.1")
    compile
("com.typesafe.akka:akka-cluster_2.11:2.4.1")
    compile
("com.typesafe.akka:akka-cluster-tools_2.11:2.4.1")
    compile
("com.typesafe.akka:akka-http-experimental_2.11:2.0.1")
    compile
("com.typesafe.akka:akka-http-core-experimental_2.11:2.0.1")
    compile
("org.scala-lang:scala-library:2.11.7")

    testCompile
("junit:junit:4.11")
}

tasks
.withType(ScalaCompile) {
    scalaCompileOptions
.useAnt = false
}

task wrapper
(type: Wrapper) {
    gradleVersion
= '2.9'
}
jar
{
    manifest
{
        attributes
"Main-Class": "com.whatever.Main"
        attributes "Build-Version": version
   
}
   
from {
        configurations
.compile.collect { it.isDirectory() ? it : zipTree(it) }
   
}
    archiveName
'fat.jar'
}

shadowJar
{
    transform
(AppendingTransformer) {
        resource
= 'reference.conf'
    }
}

 unfortunately, i still fail to run created jar due to the following error:

Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.version'

does anyone have an idea what do i miss here?

thanks!

Viktor Klang

unread,
Dec 30, 2015, 1:35:29 PM12/30/15
to Akka User List
Hi Ash,


Also, the Akka Documentation has a lot of effort put into it, and is a great source of information:

Please let us know if you didn't find the answer in there,

Happy hAkking!


--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,

ash.ta

unread,
Dec 31, 2015, 3:50:26 AM12/31/15
to Akka User List
hey,

thanks for the tips. 
i guess i understand what's wrong now: while shadowJar plugin is mentioned as the one that should do the job of merging reference.conf files, it doesn't happen with the build script i run.
i get a jar full of different reference.confs. therefore i think the problem is with the script itself.

thanks
Reply all
Reply to author
Forward
0 new messages