javafirebasegradleuberjar

Firebase Admin - Gradle - Fat Jar - Can't make it work


I am building a server to push notifications using Fire Cloud Messaging. It is super simple, making a test example, just importing firebase.

dependencies {
    implementation 'com.google.firebase:firebase-admin:7.1.1'
}

If I don't create the fat Jar, it runs perfectly until it get to the pushService, I am getting a ClassNotFound error for FirebaseConnector. Which I believe it's right. The funny thing is that when I add the library to the FatJar, like this:

jar {
    manifest {
        attributes 'Main-Class': 'com.server.push.NotificationProcess'
    }
    from {
        configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

mainClassName = 'com.server.push.NotificationProcess'

I get the no main class error

Error: Could not find or load main class com.server.push.NotificationProcess

It is not a mispelling or anything like that.. also I am including just 1 dependency so I dont see dependency conflict. I am using gradle-5.4.1 if that helps.

Can anyone give me a hand with this?

Much appreciated.


Solution

  • Seems it is too late, but just in case someone looking for the solution,

    you can use this plugin

    https://imperceptiblethoughts.com/shadow/