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() } 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}") dependencies { implementation "net.dv8tion:JDA:${jda_version}" implementation "com.electronwill.night-config:toml:${nightconfig_version}" implementation "net.sf.jopt-simple:jopt-simple:${jopt_version}" implementation "com.google.guava:guava:${guava_version}" implementation "com.google.code.gson:gson:${gson_version}" implementation "ch.qos.logback:logback-classic:${logback_version}" testImplementation "junit:junit:${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 } }