import org.apache.tools.ant.filters.ReplaceTokens //Plugins plugins { //Compiles Java id 'java' //Adds an Executable Manifest id 'application' //Creates FatJars id 'com.github.johnrengelman.shadow' version '8.1.1' } archivesBaseName = 'AleaAPI' group "toastiet0ast" def ver = new Version(major: 2, minor: 2, revision: 1) version ver.toString() sourceCompatibility = 17 targetCompatibility = 17 mainClassName = "com.toastiet0ast.aleaapi.AleaAPI" def lint = [ "auxiliaryclass", "cast", "classfile", "deprecation", "dep-ann", "divzero", "empty", "exports", "fallthrough", "finally", "module", "opens", "options", "overloads", "overrides", "path", //removed because of "No processor claimed any of these annotations: ..." //"processing", "rawtypes", "removal", "requires-automatic", "requires-transitive-automatic", "serial", "static", "try", "unchecked", "varargs", "preview" ] repositories { mavenCentral() maven { url 'https://jitpack.io' } } tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:deprecation" options.encoding = "UTF-8" } dependencies { implementation 'com.sparkjava:spark-core:2.9.4' implementation 'ch.qos.logback:logback-classic:1.2.11' implementation ('com.github.adamint:patreon-java:417322b') { exclude group: 'org.slf4j' } implementation group: 'org.json', name: 'json', version: '20220320' implementation group: 'commons-io', name: 'commons-io', version: '2.11.0' implementation group: 'commons-codec', name: 'commons-codec', version: '1.15' implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.1' implementation group: 'redis.clients', name: 'jedis', version: '4.2.3' implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.10.0' testImplementation group: 'junit', name: 'junit', version: '4.13.2' } build.dependsOn shadowJar artifacts { archives shadowJar } def gitRevision() { def gitVersion = new ByteArrayOutputStream() exec { commandLine("git", "rev-parse", "--short", "HEAD") standardOutput = gitVersion } return gitVersion.toString().trim() } task sourcesForRelease(type: Copy) { from ('src/main/java') { include '**/APIInfo.java' filter(ReplaceTokens, tokens: [ version: ver.toString(), revision: gitRevision().toString() ]) } into 'build/filteredSrc' includeEmptyDirs = false } task generateJavaSources(type: SourceTask) { def javaSources = sourceSets.main.allJava.filter { it.name != 'APIInfo.java' } source = javaSources + sourcesForRelease.destinationDir dependsOn sourcesForRelease } compileJava { source = generateJavaSources.source classpath = sourceSets.main.compileClasspath options.compilerArgs += ["-Xlint:${lint.join(",")}"] dependsOn generateJavaSources } task cleanDistTar(type: Delete) { delete files(distTar) } distTar { archiveClassifier.set("trash") } distTar.finalizedBy cleanDistTar task cleanDistZip(type: Delete) { delete files(distZip) } distZip { archiveClassifier.set("trash") } distZip.finalizedBy cleanDistZip task cleanUnshadedJar(type: Delete) { delete files(jar) } jar { archiveClassifier.set("trash") } jar.finalizedBy cleanUnshadedJar shadowJar { archiveClassifier.set(null) } class Version { String major, minor, revision String toString() { "${major}.${minor}.${revision}" } }