buildscript { repositories { jcenter() mavenCentral() } dependencies { classpath group: 'org.ajoberstar.grgit', name: 'grgit-gradle', version: grgit_version classpath group: 'com.github.jengelman.gradle.plugins', name: 'shadow', version: shadow_version } } repositories { mavenCentral() jcenter() maven { name = "Minecraft Libraries" url = "https://libraries.minecraft.net" } } apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'org.ajoberstar.grgit' apply plugin: 'idea' apply plugin: 'java' apply plugin: 'application' apply plugin: 'maven-publish' group = 'sciwhiz12.janitor' archivesBaseName = 'janitor_bot' version = getVersion() println("Version: ${version}") java { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } dependencies { implementation group: 'net.dv8tion', name: 'JDA', version: jda_version implementation group: 'com.electronwill.night-config', name: 'toml', version: nightconfig_version implementation group: 'net.sf.jopt-simple', name: 'jopt-simple', version: jopt_version implementation group: 'com.google.guava', name: 'guava', version: guava_version implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jackson_version implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: jackson_version implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jackson_version implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: log4j_bridge_version implementation group: 'ch.qos.logback', name: 'logback-classic', version: logback_version implementation group: 'com.mojang', name: 'brigadier', version: brigadier_version testImplementation group: 'junit', name: 'junit', version: junit_version } application { mainClassName = 'sciwhiz12.janitor.JanitorBot' } task sourcesJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource classifier "sources" } jar.finalizedBy('sourcesJar') jar.finalizedBy('shadowJar') def getVersion() { try { def raw_version = grgit.describe(longDescr: true, tags: true) def versionSep = raw_version.split "-" def startVer = versionSep[0].substring(1) return startVer + "." + versionSep[1] } catch (Exception e) { def ver = 'unknown' if (System.getenv("GITHUB_RUN_NUMBER") != null) ver = System.getenv("GITHUB_RUN_NUMBER") logger.error("Error getting version information, defaulting to '${ver}': {}", e.getMessage()) return ver } }