Creating an Uber Jar with Gradle is not working

Asked

Viewed 58 times

1

I’m using the plugin johnrengelman / shadow to create a Uber with some local dependencies, but for some reason unknown is not working.

build.Gradle

/*
 * This file was generated by the Gradle 'init' task.
 */
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
    }
}

plugins {
    id 'java'
    id 'maven-publish'
    id 'com.github.johnrengelman.shadow' version '5.2.0'
}

repositories {
    mavenLocal()
    maven {
        url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
    }

    maven {
        url = 'https://repo.bukkit.org/content/groups/public/'
    }

    maven {
        url = 'https://repo.maven.apache.org/maven2'
    }
}

shadowJar {
   archiveBaseName = "uber"
   classifier = ''
   archiveVersion = '1.0.0-SNAPSHOT'
}

dependencies {
    compileOnly fileTree(dir: 'lib', include: 'minecraft-colors-*.jar')
    shadow fileTree(dir: 'lib', include: 'knautiluz-http-*.jar')
    shadow fileTree(dir: 'lib', include: 'knautiluz-http-services-*.jar')
    testImplementation 'junit:junit:4.8.1'
    testImplementation 'org.mockito:mockito-all:1.9.5'
    compileOnly 'org.spigotmc:spigot-api:1.15.1-R0.1-SNAPSHOT'
}

group = 'com.knautiluz.lorelei'
version = '1.0.0-SNAPSHOT'
description = 'Knautiluz Verify'
sourceCompatibility = '1.8'

publishing {
    publications {
        maven(MavenPublication) {
            from(components.java)
        }
    }
}

With the commands gradle build and gradle shadowJar the created jars are practically the same, and do not load the mentioned dependencies inserir a descrição da imagem aqui

1 answer

0


Although I see in several places that the way to create Shade is to use the shadow something must have changed in the last version, because I got the Uber jar using implementation in place of shadow getting:

dependencies {
    compileOnly fileTree(dir: 'lib', include: 'minecraft-colors-*.jar')
    implementation fileTree(dir: 'lib', include: 'knautiluz-http-*.jar')
    implementation fileTree(dir: 'lib', include: 'knautiluz-http-services-*.jar')
    testImplementation 'junit:junit:4.8.1'
    testImplementation 'org.mockito:mockito-all:1.9.5'
    compileOnly 'org.spigotmc:spigot-api:1.15.1-R0.1-SNAPSHOT'
}

inserir a descrição da imagem aqui

And so he created my chubby jar with the dependencies.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.