#!/home/nick/bin/feather2 library /home/nick/projects/metabuild/build/libs/metabuild-0.1.jar import uk.co.nickthecoder.metabuild.* class GlokMetaBuild : MetaBuild() { val group = "uk.co.nickthecoder" val version = "1.0beta3" // Don't forget to run MetaBuild before publishing a new version! val gitLabProjectID = gitLabProjectId( "nickthecoder/glok" ) // 46354938 val tokenName = "gitLabPrivateToken" val platforms : List = listOf( "js", "jvm" ) val lwjgl_version="3.3.1" val junit_version="4.13.2" val coroutines_version="1.10.2" // Used by glok-demos-js client/server application. val ktor_version="2.3.4" // Used by glok-demos-js client/server application. meth build() { kotlinVersion().apply { // Ignore warning : 'expect'/'actual' classes ... are in Beta compilerOption( "-Xexpect-actual-classes" ) } // This is an attempt to fix "Java heap space" error messages from dokka. jvmArgs("-Xmx2048M -XX:MaxMetaspaceSize=512m" ) // No clue why this is needed. The project compiles fine directly from gradle, but // intelliJ flags "actuals" as errors without it. // kotlin.mpp.stability.nowarn=true property( "kotlin.mpp.stability.nowarn", "true" ) installGradle() publish(group, version) repositories( MavenCentral() ) // ==== model ==== val model = project( "glok-model" ).apply { kotlinMultiPlatform( platforms ) dokkaPartial() publishing().apply { publishToGitLab( gitLabProjectID, tokenName ) } } // ==== resources ==== val resources = project( "glok-resources" ).apply { kotlin() publishing().apply { publishToGitLab( gitLabProjectID, tokenName ) } } // ==== core ==== val core = project( "glok-core" ).apply { kotlinMultiPlatform( platforms ).apply { implementation( model ) implementation(kotlinReflect()) platform( "jvm" ).apply { implementation( resources ) implementation("org.lwjgl:lwjgl:$lwjgl_version") implementation("org.lwjgl:lwjgl-glfw:$lwjgl_version") implementation("org.lwjgl:lwjgl-jemalloc:$lwjgl_version") implementation("org.lwjgl:lwjgl-opengl:$lwjgl_version") implementation("org.lwjgl:lwjgl-stb:$lwjgl_version") implementation("org.lwjgl:lwjgl-glfw:$lwjgl_version") implementation("org.lwjgl:lwjgl-nfd:$lwjgl_version") // I've chosen to bundle the natives for linux, windows and macOS, so that 3rd parties // don't need to worry about it. // This makes the final product cross-platform, at the expense of wasted space/download times. // The alternative would be to create 3 separate subprojects for linux, windows and macos. for ( os in listOf( "linux", "macos", "windows" ) ) { implementation("org.lwjgl:lwjgl:$lwjgl_version:natives-$os") implementation("org.lwjgl:lwjgl-glfw:$lwjgl_version:natives-$os") implementation("org.lwjgl:lwjgl-jemalloc:$lwjgl_version:natives-$os") implementation("org.lwjgl:lwjgl-opengl:$lwjgl_version:natives-$os") implementation("org.lwjgl:lwjgl-stb:$lwjgl_version:natives-$os") implementation("org.lwjgl:lwjgl-nfd:$lwjgl_version:natives-$os") } } platform( "js" ).apply { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" ) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutines_version" ) } } dokkaPartial() publishing().apply { publishToGitLab( gitLabProjectID, tokenName ) } } // ==== dock ==== val dock = project( "glok-dock" ).apply { kotlinMultiPlatform( platforms ).apply { implementation( model ) implementation( core ) } dokkaPartial() publishing().apply { publishToGitLab( gitLabProjectID, tokenName ) } } // ==== markdown ==== val markdown = project( "glok-markdown" ).apply { kotlinMultiPlatform( platforms ).apply { implementation( model ) implementation( core ) } dokkaPartial() publishing().apply { publishToGitLab( gitLabProjectID, tokenName ) } } // ==== demos ==== val demos = project( "glok-demos" ).apply { application( "uk.co.nickthecoder.glok.demos.DemoMenu" ) kotlin().apply { implementation( model ) implementation( dock ) implementation( core ) implementation( markdown ) } } // ==== demo-server ==== val demoServer = project( "glok-demo-server" ).apply { application("uk.co.nickthecoder.glok.demo.server.DemoServer") kotlin().apply { implementation( resources ) implementation("io.ktor:ktor-server-core:$ktor_version") implementation("io.ktor:ktor-server-netty:$ktor_version") implementation("io.ktor:ktor-server-html-builder:$ktor_version") implementation("org.slf4j:slf4j-nop:2.0.9") // To make ktor quiet! } } // ==== demo-client ==== val demoClient = project( "glok-demo-client" ).apply { kotlinMultiPlatform( platforms ).apply { executable = true implementation( model ) implementation( core ) implementation("org.slf4j:slf4j-nop:2.0.9") // To make ktor quiet! platform( "jvm" ).apply { // We need to load textures from the web server. implementation("io.ktor:ktor-client-core:$ktor_version") implementation("io.ktor:ktor-client-cio:$ktor_version") } } } val test = project( "glok-test" ).apply { kotlin().apply { implementation( model ) implementation( core ) testImplementation("junit:junit:${junit_version}") } } val root = project().apply { defaultTasks( "jar", "installDist" ) dokkaMultiModule() exec( "ntc", "publishToNTC.feather", "--", version ).apply { dependsOn( "glok-demos:installDist", "dokkaHtmlMultiModule" ) } } buildGradleScripts() } func main(args: String...) { GlokMetaBuild().build() } }