Daniel Blasco
Daniel Blasco

Reputation: 1

Export jar file with included dependencies using Gradle in Netbeans

how can I include the dependency org.spongepowered:configurate-hocon:4.1.2 in the jar file of the project?

This is my gradle file:

plugins {
    id 'java'
}

group 'main.test'
version '1.0.7'

repositories {
    mavenCentral()
    maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
    maven { url = 'https://repo.codemc.io/repository/maven-public/' }
    maven { url = 'https://mvnrepository.com/artifact/it.unimi.dsi/fastutil' }
    maven { url = "https://repo.dmulloy2.net/repository/public/" }
    maven { url = "https://hub.spigotmc.org/nexus/content/groups/public/" }
}

dependencies {
    implementation("org.spongepowered:configurate-hocon:4.1.2")
    compileOnly 'org.jetbrains:annotations:23.0.0'
    compileOnly 'me.clip:placeholderapi:2.11.1'
    compileOnly 'fr.xephi:authme:5.6.0-SNAPSHOT'
    compileOnly 'it.unimi.dsi:fastutil:8.5.8'
    compileOnly "com.comphenix.protocol:ProtocolLib:4.7.0";
    compileOnly fileTree(dir: 'lib', include: 'spigot-1.8.8.jar')
    compileOnly fileTree(dir: 'lib', include: 'spigot-1.12.2.jar')
    compileOnly fileTree(dir: 'lib', include: 'spigot-1.16.5.jar')
    compileOnly fileTree(dir: 'lib', include: 'spigot-1.18.2-R0.1-SNAPSHOT.jar')
}

Upvotes: 0

Views: 242

Answers (1)

Funzter
Funzter

Reputation: 96

Try this:

task buildFatJar(type: Jar) {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    baseName = rootProject.name
    from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

jar.finalizedBy(buildFatJar)

You can optionally set a classifier with classifier = "all"

Upvotes: 1

Related Questions