GradleUp / shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
https://www.gradleup.com/shadow/
Apache License 2.0
3.77k stars 396 forks source link

Multi-project mergeServiceFiles does not include dependencies services #556

Open ronjunevaldoz opened 4 years ago

ronjunevaldoz commented 4 years ago

Encountered this error from one of my dependencies io.grpc.ManagedChannelProvider: Provider io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider not found

Shadow Version

5.2.0

Gradle Version

gradle-5.2.1

Expected Behavior

include all service dependencies in jar

Actual Behavior

does not include services from dependencies

Gradle Build Script(s)

buildscript {
    ext.kotlinVersion = '1.3.61'
    ext.koinVersion = '2.1.4'
    ext.shadowVersion = '5.2.0'

    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "com.github.jengelman.gradle.plugins:shadow:$shadowVersion"
        classpath "org.koin:koin-gradle-plugin:$koinVersion"
    }
}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.61' apply false
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.61' apply false
    id 'com.github.johnrengelman.shadow' version '5.2.0' apply false
}

allprojects {
    apply plugin: 'java'
    apply plugin: 'application'
    apply plugin: 'com.github.johnrengelman.shadow'
    apply plugin: 'org.jetbrains.kotlin.jvm'
    apply plugin: 'org.jetbrains.kotlin.plugin.serialization'
    apply plugin: 'koin'

    group 'awaken'
    version '1.0'

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8

        kotlinOptions {
            jvmTarget = '1.8'
        }
    }
    repositories {
        jcenter()
        mavenCentral()
    }
}

repositories {
    flatDir {
        dirs 'lib'
    }
}

ext {
    ktxFirebaseCommon = '19.3.0'
    ktxFirestore = '21.4.0'
}

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar// Configure Auto Relocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation

task relocateShadowJar(type: ConfigureShadowRelocation) {
    target = tasks.shadowJar
    prefix = "awaken" // Default value is "shadow"

}

tasks.shadowJar.dependsOn tasks.relocateShadowJar

subprojects {
    shadowJar {
        zip64 = true
        minimize()
        mergeServiceFiles()
    }

    repositories {
        jcenter()
        mavenCentral()
    }

    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
        implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
        implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0" // JVM dependency
        implementation 'com.google.firebase:firebase-admin:6.12.2'
    }
}

task explodedDist(type: Copy) {
    into "$buildDir/explodedDist"
    subprojects {
        from tasks.withType(ShadowJar)
    }
}

project(':core') {
    mainClassName = ''
}

project(':login') {
    mainClassName = 'com.fa.server.login.LoginMainKt'
    dependencies {
        implementation project(path: ':core')
    }
}

project(':cluster') {
    mainClassName = 'com.fa.server.cluster.ClusterMainKt'
    dependencies {
        implementation project(path: ':core')
    }
}

project(':world') {
    mainClassName = 'com.fa.server.world.WorldMainKt'
    dependencies {
        implementation project(path: ':core')
    }
}

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)

shadow jar built successfully, but with error missing services login-1.0-all.jar cluster-1.0-all.jar world-1.0-all.jar

vladp commented 4 years ago

@ronjunevaldoz were you able to resolve this?

I think I am having similar issue even with shadow 6.0.0 getting java.lang.IllegalArgumentException: cannot find a **NameResolver** for 127.0.0.1:7349 (Illegal character in scheme name at index 0: 127.0.0.1:4649 when

ManagedChannelBuilder builder = OkHttpChannelBuilder.forAddress(host, port).userAgent("java-client");
            ManagedChannelBuilder builder =  builder.usePlaintext();
            this.managedChannel = builder.build();
Sm0keySa1m0n commented 2 years ago

Any updates on this?