Skip to content

Gradle Setup

Daniel Ennis edited this page May 27, 2018 · 3 revisions

Gradle

First you will need to add the repositories and the dependency to your build.gradle. You will also need to shadow the library into your application/plugin jar.

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
    }
}

apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'java'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {
    maven { url = "https://repo.aikar.co/content/groups/aikar/" }
}

dependencies {
    compile "co.aikar:idb-core:1.0.0-SNAPSHOT"
    compile "com.zaxxer:HikariCP:2.4.1"
}

shadowJar {
   relocate 'co.aikar.idb', '[PACKAGE].idb'
}

build.dependsOn shadowJar

Replace [PACKAGE] with a package to your application/plugin so that IDB is relocated to it.

JDBC Driver

You also need to make sure your respective JDBC driver (MySQL, etc) is shaded/available

For the utility .mysql() method on the options builder, the standard MySQL driver is expected: mysql:mysql-connector-java:5.1.33 which uses the class com.mysql.jdbc.jdbc2.optional.MysqlDataSource

Bukkit Minecraft Servers: This is already included for you, you do not need to add it.

Bukkit Minecraft Servers

If using Bukkit, A bukkit specific setup class is provided where you can pass your plugin and mysql information and get some defaults pre setup. This will set up some of the configuration for you such as DB Pool name, Logger and automatic closing on plugin disable. Example:

Database db = BukkitDB.createHikariDatabase(this, dbUser, dbPass, dbName, hostAndPort);
// Global is already set for you.

Setup:

dependencies {
    compile "co.aikar:idb-bukkit:1.0.0-SNAPSHOT"
}

Then use BukkitDB class to initialize with your plugin to automatically close the database on disable.

idb-bukkit is optional, as you can do this stuff yourself with just core

You can’t perform that action at this time.