I am trying to use grpc-java v1.1.2 (build.gradle section below) but when I try to run the fat jar for the sample application, its throwing the exception given below. I do not s
The issue for me was, jar did not contain the dependent lib classes. I had to make this change to resolve it :
jar {
...
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
Which is just another way to create fat jar :)
I fixed the issue by using the shadow plugin for creating fat jars.
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.9"
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
}
}
plugins {
id 'java'
id 'application'
id 'idea'
id 'com.github.johnrengelman.shadow' version '1.2.4'
id "net.ltgt.errorprone" version '0.0.9'
}
shadowJar {
baseName = 'shadow'
classifier = null
version = null
}
jar {
manifest {
attributes(
'Class-Path': configurations.runtime.files.collect {"$it.name"}.join(' '),
'Main-Class': 'com.abc.test'
)
}
}
Run the following:
gradle shadowJar
the shadowJar file gets created in the build/libs directory which can be run as:
java -jar shadowJar