Skip to content

runServer throws ClassNotFoundException error #280

@NriotHrreion

Description

@NriotHrreion

I'm developing a multi-module minecraft server-side mod project, and I have a core module to be included in other modules. But when it comes to the neoforge module, although the finally built jar file includes the code of core module, the task runServer cannot find the classes in core module and throws ClassNotFoundException.

build.gradle of my neoforge module:

plugins {
    id 'eclipse'
    id 'idea'
    id 'com.gradleup.shadow' version '8.3.8'
    id 'net.neoforged.gradle.userdev' version '7.0.192'
}

configurations {
    shadowImplementation
    implementation.extendsFrom(shadowImplementation)
    runtimeClasspath.extendsFrom(localRuntime)
}

// ...

runs {
    server {
        workingDirectory project.file('run')
        argument '--nogui'
    }
}

// ...

dependencies {
    implementation "net.neoforged:neoforge:${neo_version}"

    shadowImplementation(project(":core")) {
        // To avoid conflict
        exclude group: 'com.github.oshi', module: 'oshi-core'
        exclude group: 'org.slf4j', module: 'slf4j-api'
    }

    implementation "com.github.oshi:oshi-core:6.8.2"
}

// ...

shadowJar {
  // ...
}

build {
    dependsOn shadowJar
}

// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions