plugins {
    id("essentials.shadow-module")
}

dependencies {
    compileOnly('com.github.milkbowl:VaultAPI:1.7') {
        exclude group: "org.bukkit", module: "bukkit"
    }
    compileOnly 'net.luckperms:api:5.3'

    api 'io.papermc:paperlib:1.0.6'

    implementation 'org.spongepowered:configurate-yaml:4.2.0'
    implementation 'org.checkerframework:checker-qual:3.49.0'
    implementation 'nu.studer:java-ordered-properties:1.0.4'

    implementation 'net.kyori:adventure-api:4.24.0'
    implementation 'net.kyori:adventure-text-minimessage:4.24.0'
    implementation 'net.kyori:adventure-platform-bukkit:4.4.1'

    // Providers
    api(project(':providers:BaseProviders')) {
        exclude(module: 'spigot-api')
    }
    api(project(path: ':providers:PaperProvider', configuration: 'shadow')){
        exclude(module: 'paper-api')
    }
    api(project(':providers:NMSReflectionProvider')) {
        exclude(module: 'bukkit')
    }
    api(project(':providers:1_8Provider')) {
        exclude(module: 'spigot-api')
    }
    api(project(':providers:1_12Provider')) {
        exclude(module: 'bukkit')
    }
}

test {
    testLogging.showStandardStreams = true
}

tasks.register('versionData', VersionDataTask) {
    destination.set(rootProject.layout.projectDirectory.dir("generated").file("version-data.json"))
}

shadowJar {
    dependencies {
        include (dependency('io.papermc:paperlib'))
        include (dependency('org.bstats:bstats-bukkit'))
        include (dependency('org.bstats:bstats-base'))
        include (dependency('org.spongepowered:configurate-yaml'))
        include (dependency('org.spongepowered:configurate-core'))
        include (dependency('org.yaml:snakeyaml'))
        include (dependency('io.leangen.geantyref:geantyref'))
        include (dependency('org.checkerframework:checker-qual'))
        include (dependency('nu.studer:java-ordered-properties'))
        include (dependency('net.kyori:adventure-api'))
        include (dependency('net.kyori:adventure-key'))
        include (dependency('net.kyori:examination-api'))
        include (dependency('net.kyori:examination-string'))
        include (dependency('net.kyori:option'))
        include (dependency('net.kyori:adventure-platform-bukkit'))
        include (dependency('net.kyori:adventure-platform-api'))
        include (dependency('net.kyori:adventure-platform-facet'))
        include (dependency('net.kyori:adventure-nbt'))
        include (dependency('net.kyori:adventure-text-serializer-bungeecord'))
        include (dependency('net.kyori:adventure-text-serializer-gson'))
        include (dependency('net.kyori:adventure-text-serializer-gson-legacy-impl'))
        include (dependency('net.kyori:adventure-text-serializer-json'))
        include (dependency('net.kyori:adventure-text-serializer-json-legacy-impl'))
        include (dependency('net.kyori:adventure-text-serializer-legacy'))
        include (dependency('net.kyori:adventure-text-minimessage'))
        include (project(':providers:BaseProviders'))
        include (project(path: ':providers:PaperProvider', configuration: 'shadow'))
        include (project(':providers:NMSReflectionProvider'))
        include (project(':providers:1_8Provider'))
        include (project(':providers:1_12Provider'))

        // Paper in-dev adventure versions (for snapshot/pre-releases)
        include (dependency('io.papermc.adventure:adventure-api'))
        include (dependency('io.papermc.adventure:adventure-key'))
        include (dependency('io.papermc.adventure:adventure-nbt'))
        include (dependency('io.papermc.adventure:adventure-text-serializer-gson'))
        include (dependency('io.papermc.adventure:adventure-text-serializer-gson-legacy-impl'))
        include (dependency('io.papermc.adventure:adventure-text-serializer-json'))
        include (dependency('io.papermc.adventure:adventure-text-serializer-json-legacy-impl'))
        include (dependency('io.papermc.adventure:adventure-text-serializer-legacy'))
        include (dependency('io.papermc.adventure:adventure-text-minimessage'))
    }
    relocate 'io.papermc.lib', 'com.earth2me.essentials.paperlib'
    relocate 'org.bstats', 'com.earth2me.essentials.libs.bstats'
    relocate 'org.spongepowered.configurate', 'com.earth2me.essentials.libs.configurate'
    relocate 'org.yaml.snakeyaml', 'com.earth2me.essentials.libs.snakeyaml'
    relocate 'io.leangen.geantyref', 'com.earth2me.essentials.libs.geantyref'
    relocate 'org.checkerframework', 'com.earth2me.essentials.libs.checkerframework'
    relocate 'net.kyori', 'com.earth2me.essentials.libs.kyori'
    relocate 'net.essentialsx.temp.adventure', 'net.kyori.adventure'

    minimize {
        include(dependency('org.checkerframework:checker-qual'))
        include(dependency('net.kyori:adventure-api'))
        include(dependency('net.kyori:adventure-platform-bukkit'))
        include(dependency('net.kyori:adventure-text-minimessage'))
    }
}
