/* * Declaration section * */ val projectName = "RtnCalendar" fun getExtOrDefault(name: String): String { // val value = rootProject.extra.takeIf { it.has(name) }?.get(name) // ?: project.properties["${projectName}_$name"] // return value.toString() return project.properties["${projectName}_$name"].toString() } fun isNewArchitectureEnabled(): Boolean { return rootProject.hasProperty("newArchEnabled") && rootProject.property("newArchEnabled") == "true" } /* * Main configurations * */ buildscript { val projectName = "RtnCalendar" val kotlinVersion = rootProject.extra.takeIf { it.has("kotlinVersion") } ?.get("kotlinVersion") ?: project.properties["${projectName}_kotlinVersion"] repositories { google() mavenCentral() } dependencies { // !! In buildscript.dependencies cannot use implement, only using classpath // Because, this is library, we specify clearly instead using libs.versions.tomb classpath("com.android.tools.build:gradle:8.6.0") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") classpath("com.facebook.react:react-native-gradle-plugin") } } // ------------------------------------------------------------------- // Uncomment for building application (and Comment for building library) // plugins { // id("kotlin-android") // id("com.android.application") // } // dependencies { // implementation(libs.androidx.ui.tooling.preview) // implementation(libs.androidx.activity.compose) // debugImplementation(libs.androidx.ui.tooling) // } // ------------------------------------------------------------------- // Uncomment for building library (and Comment for building application) plugins { id("com.android.library") id("kotlin-android") id("com.facebook.react") } react { jsRootDir = file("../src/") libraryName = "RtnCalendarView" codegenJavaPackageName = "com.sp365.calendar" } tasks.withType { exclude("**/MainActivity.kt") } // --------------------------------------------------- android { namespace = "com.sp365.calendar" compileSdkVersion = getExtOrDefault("compileSdkVersion") buildFeatures { buildConfig = true compose = true } defaultConfig { minSdk = getExtOrDefault("minSdkVersion").toInt() targetSdk = getExtOrDefault("targetSdkVersion").toInt() buildConfigField( "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() ) vectorDrawables { useSupportLibrary = true } } buildTypes { release { isMinifyEnabled = false } } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } composeOptions { // Compose compiler version kotlinCompilerExtensionVersion = "1.5.14" } sourceSets { getByName("main") { manifest.srcFile("src/main/AndroidManifest.xml") res.setSrcDirs(listOf("src/main/res")) java.setSrcDirs( listOf( // Import definition file generated by codegen "${layout.buildDirectory.get()}/generated/source/codegen/java", "src/main/java" ) ) } } kotlinOptions { jvmTarget = "17" } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } } dependencies { /* Because this is library, we specify clearly instead of using library catalog declaration (libs.versions.tomb) */ // For build component fo react native implementation("com.facebook.react:react-android:0.75.4") implementation("org.jetbrains.kotlin:kotlin-stdlib:${getExtOrDefault("kotlinVersion")}") // For library using in composable and ui implementation("androidx.compose.runtime:runtime-android:1.7.4") implementation("androidx.compose.material3:material3-android:1.3.0") // For compose compiler implementation(platform("androidx.compose:compose-bom:2024.04.01")) // utils implementation ("androidx.compose.runtime:runtime-livedata:1.4.4") implementation ("io.coil-kt:coil-compose:2.3.0") implementation ("com.caverock:androidsvg:1.4") implementation ("com.google.accompanist:accompanist-pager:0.28.0") }