build.gradle.kts (1212B) - raw


      1 import org.apache.tools.ant.taskdefs.condition.Os
      2 plugins {
      3     alias(libs.plugins.androidLibrary)
      4     alias(libs.plugins.kotlinAndroid)
      5 }
      6 
      7 android {
      8     namespace = rootProject.ext["applicationId"].toString() + ".composer"
      9     compileSdk = 34
     10 
     11     sourceSets {
     12         getByName("main") {
     13             assets.srcDirs("build/assets")
     14         }
     15     }
     16 }
     17 
     18 task("compileTypeScript") {
     19     doLast {
     20         if (Os.isFamily(Os.FAMILY_WINDOWS))  {
     21             project.exec {
     22                 commandLine("npx.cmd", "--yes", "tsc", "--project", "tsconfig.json")
     23             }
     24             project.exec {
     25                 commandLine("npx.cmd", "--yes", "rollup", "--config", "rollup.config.js", "--bundleConfigAsCjs")
     26             }
     27         } else {
     28             project.exec {
     29                 commandLine("npx", "--yes", "tsc", "--project", "tsconfig.json")
     30             }
     31             project.exec {
     32                 commandLine("npx", "--yes", "rollup", "--config", "rollup.config.js", "--bundleConfigAsCjs")
     33             }
     34         }
     35 
     36         project.copy {
     37             from("build/loader.js")
     38             into("build/assets/composer")
     39         }
     40     }
     41 }
     42 
     43 tasks.named("preBuild").configure {
     44     dependsOn("compileTypeScript")
     45 }