plugins { id 'org.jetbrains.kotlin.multiplatform' id 'org.jetbrains.kotlin.plugin.atomicfu' id 'org.jetbrains.kotlin.plugin.serialization' id 'com.android.library' id 'maven-publish' } android { compileSdkVersion rootProject.ext.version_android_compile_sdk buildTypes { release { consumerProguardFiles 'proguard-rules.pro' } } packagingOptions { resources { excludes += ['META-INF/INDEX.LIST', '**/*.kotlin_metadata', 'META-INF/*.kotlin_module', 'licenses/**.TXT'] } } defaultConfig { minSdkVersion 21 targetSdkVersion rootProject.ext.version_android_target_sdk testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } compileOptions { sourceCompatibility = '1.8' targetCompatibility = '1.8' } testOptions { unitTests { returnDefaultValues = true } } lint { abortOnError false } namespace 'com.ustadmobile.port.sharedse' tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { kotlinOptions { jvmTarget = "1.8" } } } sourceCompatibility = '1.8' targetCompatibility = '1.8' group rootProject.group version rootProject.version kotlin { jvm { compilations.main.kotlinOptions { // Setup the Kotlin compiler options for the 'main' compilation: jvmTarget = "$version_kotlin_jvmTarget" } compilations.test.kotlinOptions { // Setup the Kotlin compiler options for the 'main' compilation: jvmTarget = "$version_kotlin_jvmTarget" } } //Unfortunately there isn't really an elegant way to create a sourceset for one module //The section below can be uncommented for development so that autocomplete works for JVM libraries // see https://youtrack.jetbrains.com/issue/KT-28194 // It should be commented out again before running jvmTest. /*jvm("commonJvm") { compilations.main.kotlinOptions { // Setup the Kotlin compiler options for the 'main' compilation: jvmTarget = "$version_kotlin_jvmTarget" } }*/ android() jvm { compilations.main.kotlinOptions { // Setup the Kotlin compiler options for the 'main' compilation: jvmTarget = "$version_kotlin_jvmTarget" } } sourceSets { commonMain { dependencies { implementation project(":core") implementation project(":lib-util") implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$version_kotlin" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version_coroutines" implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$version_kotlinx_serialization" implementation "io.ktor:ktor-client-core:$version_ktor" implementation "io.ktor:ktor-client-json:$version_ktor" implementation "io.ktor:ktor-io:$version_ktor" implementation "io.ktor:ktor-client-content-negotiation:$version_ktor" implementation "io.ktor:ktor-serialization-gson:$version_ktor" implementation "io.github.aakira:napier:$version_napier" implementation "org.kodein.di:kodein-di:$version_kodein_di" implementation "org.jetbrains.kotlinx:atomicfu:$version_atomicfu" implementation "com.github.UstadMobile.door:door-runtime:$version_door" implementation project(':lib-database') implementation "com.ustadmobile.xmlpullparserkmp:xmlpullparserkmp:$version_xmlpullparserkmp" } } commonJvmMain { dependencies { implementation "org.nanohttpd:nanohttpd:$version_nanohttpd" implementation "org.nanohttpd:nanohttpd-nanolets:$version_nanohttpd" implementation "com.squareup.okhttp3:okhttp:$version_okhttp" implementation "net.sf.kxml:kxml2:$version_kxml" implementation "com.google.code.gson:gson:$version_gson" implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$version_kotlinx_serialization" implementation "com.neovisionaries:nv-i18n:$version_nv_lang" implementation "io.ktor:ktor-client-okhttp:$version_ktor" implementation "io.ktor:ktor-client-cio:$version_ktor" implementation "io.ktor:ktor-serialization-gson:$version_ktor" implementation "io.ktor:ktor-io-jvm:$version_ktor" implementation "org.kodein.di:kodein-di:$version_kodein_di" implementation "com.ustadmobile.xmlpullparserkmp:xmlpullparserkmp:$version_xmlpullparserkmp" } } /* Normally we would add a sourceSet and then use dependsOn. Unfortunately this does not work when running unit tests in the IDE. */ androidMain { dependsOn commonJvmMain dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version_kotlin" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version_coroutines" implementation "androidx.lifecycle:lifecycle-livedata:$version_androidx_lifecycle" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$version_androidx_lifecycle" implementation "androidx.work:work-runtime:$version_android_workmanager" implementation "org.kodein.di:kodein-di-framework-android-x:$version_kodein_di" implementation "androidx.room:room-runtime:$version_android_room" implementation "com.google.android.material:material:$version_android_material" implementation "io.ktor:ktor-client-okhttp:$version_ktor" implementation "io.ktor:ktor-client-cio:$version_ktor" implementation "io.ktor:ktor-serialization-gson:$version_ktor" implementation "org.nanohttpd:nanohttpd:$version_nanohttpd" implementation "org.nanohttpd:nanohttpd-nanolets:$version_nanohttpd" //Begin SharedSE Android and JVM dependencies implementation "org.nanohttpd:nanohttpd:$version_nanohttpd" implementation "org.nanohttpd:nanohttpd-nanolets:$version_nanohttpd" implementation "com.squareup.okhttp3:okhttp:$version_okhttp" implementation "com.google.code.gson:gson:$version_gson" //end SharedSE Android and JVM dependencies } } jvmMain { dependsOn commonJvmMain dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version_kotlin" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version_coroutines" implementation "io.ktor:ktor-client-okhttp:$version_ktor" implementation "io.ktor:ktor-serialization-gson:$version_ktor" //Begin Android and JVM dependencies implementation "org.nanohttpd:nanohttpd:$version_nanohttpd" implementation "org.nanohttpd:nanohttpd-nanolets:$version_nanohttpd" implementation "com.squareup.okhttp3:okhttp:$version_okhttp" implementation "com.google.code.gson:gson:$version_gson" //end Android and JVM dependencies } } commonTest { dependencies { } } jvmTest { dependencies { implementation project(":lib-test-common") implementation "io.github.aakira:napier:$version_napier" implementation "com.soywiz.korlibs.klock:klock:$version_klock" implementation "junit:junit:$version_junit" implementation "io.ktor:ktor-server-netty:$version_ktor" implementation "com.squareup.okhttp3:mockwebserver:$version_mockwebserver" implementation "com.squareup.okhttp3:okhttp:$version_okhttp" implementation "io.github.aakira:napier-jvm:$version_napier" implementation "org.mockito.kotlin:mockito-kotlin:$version_kotlin_mockito" implementation "com.soywiz.korlibs.klock:klock-jvm:$version_klock" implementation "com.github.h-thurow:simple-jndi:$version_simple_jndi" implementation "org.apache.commons:commons-pool2:$version_apache_commons_pool2" implementation "org.xerial:sqlite-jdbc:$version_sqlite_jdbc" implementation "org.apache.commons:commons-dbcp2:$version_apache_commons_dbcp2" implementation "org.kodein.di:kodein-di-framework-ktor-server-jvm:$version_kodein_di" api project(":sharedse") api project(":app-ktor-server") } } } } /* * This might be required to be able to run unit tests via the IDE. */ task copyTestResources(type: Copy) { outputs.upToDateWhen { project.file("build/local.env.properties").exists() } from project.file("src/commonTest/resources") into rootProject.file("build/classes/test/sharedse_jvmTest") doFirst { println("Dump sharedse local.env.properties") if (!project.file("build").exists()) project.file("build").mkdir() def outWriter = new FileWriter(project.file("build/local.env.properties")) System.getProperties().store(outWriter, "System properties for use with running unit tests in IDE") outWriter.flush() outWriter.close() } } tasks.whenTaskAdded { task -> if (task.name == "compileTestKotlinJvm") { println("Add task to jvmTest") task.dependsOn(copyTestResources) } } jvmTest.dependsOn(copyTestResources) publishing { publications { maven(MavenPublication) { groupId rootProject.group artifactId project.name version rootProject.version } } repositories { maven { url rootProject.ext.buildConfigProperties['repo.dir'] } } }