plugins { id 'java' id 'idea' id 'eclipse' id 'com.gradleup.shadow' version '8.3.8' } group = 'me.konsolas.aac' version = '4.3.7' def javaVersion = 17 repositories { mavenCentral() maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') } } configurations { apiGenerator } def generatorClasses = layout.buildDirectory.dir('api-generator/classes') tasks.register('compileApiGenerator', JavaCompile) { source = files('gradle/GenerateCompileApis.java') classpath = configurations.apiGenerator destinationDirectory = generatorClasses javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(javaVersion) } options.release = javaVersion options.encoding = 'UTF-8' } tasks.register('generateCompileApis', JavaExec) { group = 'build setup' description = 'Generates compile-only API headers from text declarations.' dependsOn tasks.named('compileApiGenerator') inputs.dir('gradle/api-signatures') outputs.dir(layout.buildDirectory.dir('compile-apis')) classpath = files(generatorClasses) + configurations.apiGenerator javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(javaVersion) } mainClass = 'GenerateCompileApis' maxHeapSize = '2g' args file('gradle/api-signatures').absolutePath, layout.buildDirectory.dir('compile-apis').get().asFile.absolutePath } def compileApi = { String name -> files(layout.buildDirectory.file("compile-apis/${name}.jar")).builtBy(tasks.named('generateCompileApis')) } tasks.register('prepareIde') { group = 'ide' description = 'Generates the compile-only API headers used by the IDE import.' dependsOn tasks.named('generateCompileApis') } java { toolchain.languageVersion = JavaLanguageVersion.of(javaVersion) withSourcesJar() } dependencies { apiGenerator 'org.ow2.asm:asm:9.8' apiGenerator 'com.google.code.gson:gson:2.10.1' implementation 'org.ow2.asm:asm:9.8' implementation 'org.ow2.asm:asm-tree:9.8' implementation 'net.jodah:expiringmap:0.5.10' compileOnly compileApi('aac4') compileOnly 'com.google.guava:guava:21.0' compileOnly 'com.google.code.gson:gson:2.8.9' compileOnly 'org.yaml:snakeyaml:1.27' compileOnly 'commons-lang:commons-lang:2.6' compileOnly 'com.googlecode.json-simple:json-simple:1.1.1' } tasks.withType(JavaCompile).configureEach { if (name != 'compileApiGenerator') { dependsOn tasks.named('generateCompileApis') } options.release = javaVersion options.encoding = 'UTF-8' options.compilerArgs += ['-parameters', '-Xmaxerrs', '1500'] options.debug = true options.debugOptions.debugLevel = 'source,lines,vars' } tasks.withType(AbstractArchiveTask).configureEach { preserveFileTimestamps = false reproducibleFileOrder = true filePermissions { unix('0644') } dirPermissions { unix('0755') } } jar { archiveClassifier = 'plain' manifest.attributes('Implementation-Title': 'AAC', 'Implementation-Version': project.version) } shadowJar { archiveClassifier = 'java17' relocate 'org.objectweb.asm', 'me.konsolas.aac.lib.asm' relocate 'net.jodah.expiringmap', 'me.konsolas.aac.lib.expiringmap' minimize() mergeServiceFiles() exclude 'META-INF/*.SF', 'META-INF/*.RSA', 'META-INF/*.DSA' exclude 'META-INF/INDEX.LIST', 'META-INF/maven/**' exclude 'META-INF/LICENSE', 'META-INF/LICENSE.txt', 'META-INF/NOTICE', 'META-INF/NOTICE.txt' manifest.attributes('Implementation-Title': 'AAC', 'Implementation-Version': project.version) } assemble.dependsOn shadowJar idea { module { downloadSources = true downloadJavadoc = true } } eclipse { classpath { downloadSources = true downloadJavadoc = true } }