#[solved] jar bundeling

42 messages · Page 1 of 1 (latest)

dim raft
#

I got an jar in a libs folder in my project folder. When building the mod and then looking into the jar there is no jar and no libs folder. How do I make it so the jar will be in there because its a dependency?

gradlew.build

plugins {
    id 'fabric-loom' version '1.14-SNAPSHOT'
    id 'maven-publish'
}

version = project.mod_version
group = project.maven_group

base {
    archivesName = project.archives_base_name
}


fabricApi {
    configureDataGeneration {
        client = true
    }
}


repositories {
    // Add repositories to retrieve artifacts from in here.
    // You should only use this when depending on other mods because
    // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
    // See https://docs.gradle.org/current/userguide/declaring_repositories.html
    // for more information about repositories.
    mavenCentral()

    // LIBS FLATDIR
    flatDir { dirs "libs" }

    maven { url = "https://maven.fabricmc.net/" }
}

dependencies {
    // Version (to change the versions see the gradle.properties file)
    minecraft "com.mojang:minecraft:${project.minecraft_version}"

    // Yarn
    mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"

    // Fabric Loader
    modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

    // Fabric API
    modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

    // Discord IPC
    modImplementation files('libs/DiscordIPC.jar')
}

processResources {
    inputs.property "version", project.version
    inputs.property "minecraft_version", project.minecraft_version
    inputs.property "loader_version", project.loader_version
    filteringCharset "UTF-8"

    filesMatching("fabric.mod.json") {
        expand "version": project.version,
                "minecraft_version": project.minecraft_version,
                "loader_version": project.loader_version
    }
}

def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
    // ensure that the encoding is set to UTF-8, no matter what the system default is
    // this fixes some edge cases with special characters not displaying correctly
    // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
    // If Javadoc is generated, this must be specified in that task too.
    it.options.encoding = "UTF-8"
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        it.options.release.set(targetJavaVersion)
    }
}

java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
    // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
    // if it is present.
    // If you remove this line, sources will not be generated.
    withSourcesJar()
}

jar {
    from("LICENSE") {
        rename { "${it}_${project.archivesBaseName}" }
        configurations.modCompileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

// configure the maven publication
publishing {
    publications {
        create("mavenJava", MavenPublication) {
            artifactId = project.archives_base_name
            from components.java
        }
    }

    // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
    repositories {
        // Add repositories to publish to here.
        // Notice: This block does NOT have the same function as the block in the top level.
        // The repositories here will be used for publishing your artifact, not for
        // retrieving dependencies.
    }
}
static lark
#

replace modImplementation files(...) with include modImplementation(files(...))

#

@dim raft

dim raft
dim raft
static lark
#

where did you get this mod? modrinth? curseforge?

dim raft
#

When I run the client via ./gradlew runClient it works fine

static lark
dim raft
#

and jcenter is outdated

static lark
#

wdym jcenter is outdated

#

brb

dim raft
#

I thought so...

#

and when trying to e.g. run clean it gives this error


A problem occurred evaluating root project 'Nexsus Client'.
> Could not find method jcenter() for arguments [] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.
BUILD FAILED in 427ms
dim raft
static lark
dim raft
#
    id 'fabric-loom' version '1.14-SNAPSHOT'
    id 'maven-publish'
//    id 'com.gradleup.shadow' version '8.11.0'
}

version = project.mod_version
group = project.maven_group

base {
    archivesName = project.archives_base_name
}


fabricApi {
    configureDataGeneration {
        client = true
    }
}


repositories {
    // Add repositories to retrieve artifacts from in here.
    // You should only use this when depending on other mods because
    // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
    // See https://docs.gradle.org/current/userguide/declaring_repositories.html
    // for more information about repositories.
    mavenCentral()

    // LIBS FLATDIR
    flatDir { dirs "libs" }

    jcenter()
}

dependencies {
    // Version (to change the versions see the gradle.properties file)
    minecraft "com.mojang:minecraft:${project.minecraft_version}"

    // Yarn
    mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"

    // Fabric Loader
    modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

    // Fabric API
    modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

    // Discord IPC
    // modImplementation files('libs/DiscordIPC.jar')
    include modImplementation(files('libs/DiscordIPC.jar'))
}

processResources {
    inputs.property "version", project.version
    inputs.property "minecraft_version", project.minecraft_version
    inputs.property "loader_version", project.loader_version
    filteringCharset "UTF-8"

    filesMatching("fabric.mod.json") {
        expand "version": project.version,
                "minecraft_version": project.minecraft_version,
                "loader_version": project.loader_version
    }
}

def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
    // ensure that the encoding is set to UTF-8, no matter what the system default is
    // this fixes some edge cases with special characters not displaying correctly
    // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
    // If Javadoc is generated, this must be specified in that task too.
    it.options.encoding = "UTF-8"
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        it.options.release.set(targetJavaVersion)
    }
}

java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
    // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
    // if it is present.
    // If you remove this line, sources will not be generated.
    withSourcesJar()
}

jar {
    from("LICENSE") {
        rename { "${it}_${project.archivesBaseName}" }
        configurations.modCompileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

// configure the maven publication
publishing {
    publications {
        create("mavenJava", MavenPublication) {
            artifactId = project.archives_base_name
            from components.java
        }
    }

    // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
    repositories {
        // Add repositories to publish to here.
        // Notice: This block does NOT have the same function as the block in the top level.
        // The repositories here will be used for publishing your artifact, not for
        // retrieving dependencies.
    }
}```
static lark
#

actually

#

jcenter only has 0.3

#

spring lib m has 0.4

#

you can add https://repo.spring.io/libs-milestone/ as a repository and use implementation 'com.jagrosh:DiscordIPC:0.4'

#

(i think you can use implementation because modImplementation is for importing mods which need to be remapped)

dim raft
static lark
#

in the repositories section:

    maven {
        url "https://repo.spring.io/libs-milestone/"
    }
dim raft
#

thanks

#

when launching the mod with prism launcher I get this error

#
    at net.fabricmc.loader.impl.FabricLoaderImpl.lambda$invokeEntrypoints$0(FabricLoaderImpl.java:409)
    at net.fabricmc.loader.impl.util.ExceptionUtil.gatherExceptions(ExceptionUtil.java:33)
    at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:407)
    at net.fabricmc.loader.impl.game.minecraft.Hooks.startClient(Hooks.java:53)
    at knot//net.minecraft.class_310.<init>(class_310.java:477)
    at knot//net.minecraft.client.main.Main.main(Main.java:239)
    at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:514)
    at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:72)
    at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
    at org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:105)
    at org.prismlauncher.EntryPoint.listen(EntryPoint.java:129)
    at org.prismlauncher.EntryPoint.main(EntryPoint.java:70)
Caused by: java.lang.NoClassDefFoundError: com/jagrosh/discordipc/exceptions/NoDiscordClientException
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:534)
    at java.base/java.lang.Class.forName(Class.java:513)
    at net.fabricmc.loader.impl.util.DefaultLanguageAdapter.create(DefaultLanguageAdapter.java:50)
    at net.fabricmc.loader.impl.entrypoint.EntrypointStorage$NewEntry.getOrCreate(EntrypointStorage.java:124)
    at net.fabricmc.loader.impl.entrypoint.EntrypointContainerImpl.getEntrypoint(EntrypointContainerImpl.java:53)
    at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:405)
    ... 9 more
Caused by: java.lang.ClassNotFoundException: com.jagrosh.discordipc.exceptions.NoDiscordClientException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
    at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.loadClass(KnotClassDelegate.java:239)
    at net.fabricmc.loader.impl.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:119)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
    ... 16 more```
#

also when decompiling the mod and looking into it there is no where any discordipc jar

static lark
#

ah
right i forgot

static lark
dim raft
bleak tinsel
#

!!dependencies

pliant fossilBOT
bleak tinsel
#

for future reference

dim raft
#

Thanks ill look if what 7410 said works and if not ill look at the docs and tell you

dim raft
dim raft
#

[solved] jar bundeling