2

I am developing a Minecraft plugin with Spigot, so far no problem.

I have added several dependencies so an dependencies that refers to a . jar pixearth-core-1.0 located at the root of the project in a folder libs. When I develop, I have access to the classes in the pixearth-core-1.0 library.

When I compile the project there is no problem, however when I run the plugin on the server, I have the following error:

[01:58:17 ERROR]: Error occurred while enabling Idle v1.0-SNAPSHOT (Is it up to date?)
java.lang.NoClassDefFoundError: pixearth/idleplugin/database/DatabaseManager
        at pixearth.idle.Main.onEnable(Main.java:26) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:339) [spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.enablePlugin(CraftServer.java:426) [spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.enablePlugins(CraftServer.java:340) [spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at net.minecraft.server.v1_13_R1.MinecraftServer.m(MinecraftServer.java:562) [spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at net.minecraft.server.v1_13R1.MinecraftServer.g(MinecraftServer.java:524) [spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at net.minecraft.server.v1_13_R1.MinecraftServer.a(MinecraftServer.java:423) [spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at net.minecraft.server.v1_13_R1.DedicatedServer.init(DedicatedServer.java:288) [spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at net.minecraft.server.v1_13_R1.MinecraftServer.run(MinecraftServer.java:686) [spigot.jar:git-Spigot-fe3ab0d-162bda9]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221]
Caused by: java.lang.ClassNotFoundException: pixearth.idleplugin.database.DatabaseManager

The class pixearth/idleplugin/database/Databasemanager is located in the pixearth-core-1.0 library.

Only the pixearth-core-1.0 library is not exported during compilation but spigot-api and SQLiteQueryBuilder are exported.

I’m not sure why, do you have any idea how to fix the problem?

My build.gradle :

apply plugin: 'java'

group = pluginGroup
version = pluginVersion

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
    maven {
        name = 'spigotmc-repo'
        url = 'https://hub.spigotmc.org/nexus/content/groups/public/'
    }
    maven {
        name = 'sonatype'
        url = 'https://oss.sonatype.org/content/groups/public/'
    }
    maven {
        url "https://jitpack.io/"
    }
    flatDir {
        dirs 'libs'
    }

}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile 'org.spigotmc:spigot-api:1.13-R0.1-SNAPSHOT'
    compile 'com.github.alexfu:SQLiteQueryBuilder:0.1.1'
    compile files('libs\pixearth-core-1.0.jar')
}

import org.apache.tools.ant.filters.ReplaceTokens

processResources {
    from(sourceSets.main.resources.srcDirs) {
        filter ReplaceTokens, tokens: [version: version]
    }
}
DDbout
  • 41
  • 2
  • 4

1 Answers1

0

Your plugin is calling on the library during runtime but it is not found. It needs to either be loaded by spigot as a plugin on its own, or included in your jar. There is a Gradle plugin to help you with this called Shadow. You can find it on GitHub. Here is the user guide but to summarize, add that to your plugins in buildscript and use task shadowJar. Anything with runtime classpath will be included inside your final jar.

It is also recommended to use implementation instead of compile. It still works in some Gradle versions for compatibility issues but it is deprecated and has been removed from Gradle 7. More information on Gradle docs site