import org.embeddedt.embeddium.gradle.task.GenerateLWJGLAbstraction plugins { id 'java-library' id 'maven-publish' } group = "org.embeddedt.celeritas" version = rootProject.version java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 withSourcesJar() } repositories { mavenCentral() } def generatedSourcesDir = layout.buildDirectory.dir("generated/sources/lwjgl-abstraction/java") sourceSets { lwjglCommon { java.srcDir(generatedSourcesDir.map { it.dir("main") }) } lwjgl2 { java.srcDir(generatedSourcesDir.map { it.dir("lwjgl2") }) compileClasspath += main.compileClasspath compileClasspath += lwjglCommon.output } lwjgl3 { java.srcDir(generatedSourcesDir.map { it.dir("lwjgl3") }) compileClasspath += main.compileClasspath compileClasspath += lwjglCommon.output } main { compileClasspath += lwjglCommon.output } } def generateAbstractionLayer = tasks.register("generateLWJGLAbstraction", GenerateLWJGLAbstraction) { lwjgl2Classpath.from(configurations.named("lwjgl2CompileClasspath")) lwjgl3Classpath.from(configurations.named("lwjgl3CompileClasspath")) outputDirectory.set(generatedSourcesDir) } tasks.named("compileLwjglCommonJava") { dependsOn(generateAbstractionLayer) } def compileAgainstLwjgl = true dependencies { def lwjglVersion = "3.3.1" def lwjgl2Version = "2.9.3" lwjgl3CompileOnly(platform("org.lwjgl:lwjgl-bom:$lwjglVersion")) lwjgl3CompileOnly "org.lwjgl:lwjgl" lwjgl3CompileOnly "org.lwjgl:lwjgl-opengl" lwjgl2CompileOnly("org.lwjgl.lwjgl:lwjgl:$lwjgl2Version") if (compileAgainstLwjgl) { // TODO Completely remove direct dependency on LWJGL3 implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion")) implementation "org.lwjgl:lwjgl" implementation "org.lwjgl:lwjgl-opengl" } implementation "org.joml:joml:1.10.5" implementation "it.unimi.dsi:fastutil:7.1.0" implementation "org.apache.logging.log4j:log4j-api:2.0-beta9" compileOnly "org.jetbrains:annotations:24.1.0" compileOnly("org.projectlombok:lombok:1.18.30") annotationProcessor("org.projectlombok:lombok:1.18.30") implementation("org.ow2.asm:asm:9.6") implementation("org.ow2.asm:asm-tree:9.6") implementation("org.ow2.asm:asm-util:9.6") implementation "com.google.code.gson:gson:2.10.1" testImplementation 'org.junit.jupiter:junit-jupiter:5.13.0' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } tasks.named('test', Test) { useJUnitPlatform() maxHeapSize = '1G' testLogging { events "passed" } } publishing { publications { mavenJava(MavenPublication) { artifactId 'celeritas-common' from components.java } } repositories { maven { name = "taumcRepository" url = uri("https://maven.taumc.org/releases") credentials { username = System.getenv("MAVEN_USERNAME") password = System.getenv("MAVEN_SECRET") } authentication { basic(BasicAuthentication) } } } } tasks.withType(Jar).configureEach { from(rootProject.file("COPYING")) from(rootProject.file("COPYING.LESSER")) } jar { from(sourceSets.lwjglCommon.output) from(sourceSets.lwjgl2.output) from(sourceSets.lwjgl3.output) manifest { attributes([ "Lwjgl3ify-Aware": "true" ]) } } // make RFG stop complaining def obfAttr = Attribute.of("com.gtnewhorizons.retrofuturagradle.obfuscation", String) def transformedAttr = Attribute.of("rfgDeobfuscatorTransformed", Boolean) configurations { runtimeElements { attributes { attribute(obfAttr, "mcp") attribute(transformedAttr, true) } } }