/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java project to get you started.
 * For more details take a look at the Java Quickstart chapter in the Gradle
 * User Manual available at https://docs.gradle.org/5.6.3/userguide/tutorial_java_projects.html
 */
buildscript {

}

plugins {
    // Apply the java plugin to add support for Java
    id 'java'

    id 'idea'
}

sourceCompatibility = 17
targetCompatibility = 17

def version_tag = "dev-1.5.0"

repositories {
    mavenCentral()
}

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()

    maven {
        url "https://repo.spring.io/release"
    }

    maven {
        url "https://s01.oss.sonatype.org/content/groups/public/"
    }
}

dependencies {
    implementation fileTree(dir: 'lib', include: ['*.jar'])

	implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.8'
    
	implementation group: 'dev.morphia.morphia', name: 'morphia-core', version: '2.2.6'

    //implementation group: 'tech.xigam', name: 'grasscutter', version: '1.0.2-dev'

    implementation 'io.jsonwebtoken:jjwt-api:0.11.3'
    runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.3', 'io.jsonwebtoken:jjwt-gson:0.11.3'

}


task injectGitHash {
    def gitCommitHash = {
        try {
            return 'git rev-parse --verify --short HEAD'.execute().text.trim()
        } catch (e) {
            return "GIT_NOT_FOUND"
        }
    }
    def pluginJson = {
        return new File(projectDir, "src/main/resources/plugin.json.tmpl").text.replace("{{VERSION}}", "${version_tag}-${gitCommitHash()}")
    }
    new File(projectDir, "src/main/resources/plugin.json").text = pluginJson()
}

jar {
    jar.baseName = 'mojoconsole'

    destinationDir = file(".")
}

