Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 4.28 KB | None | 0 0
  1.  
  2. apply plugin: ‘kotlin-multiplatform’
  3. apply plugin: ‘com.android.library
  4. apply plugin: ‘kotlinx-serialization’
  5. apply plugin: ‘kotlin-android-extensions’
  6. apply plugin: ‘org.jetbrains.dokka-android’
  7.  
  8.  
  9. android {
  10.     compileSdkVersion 28
  11.    
  12.     defaultConfig {
  13.         minSdkVersion 21
  14.     }
  15.    
  16.     buildTypes {
  17.         release {
  18.             minifyEnabled true
  19.             proguardFiles getDefaultProguardFile(‘proguard-android-optimize.txt), ‘proguard-rules.pro
  20.         }
  21.     }
  22.  
  23.     packagingOptions {
  24.         exclude ‘META-INF/*.kotlin_module’
  25.     }
  26. }
  27.  
  28. def mobilePlatformAttribute = Attribute.of(‘com.inspirefitness.mobile’, String)
  29.  
  30. kotlin {
  31.  
  32.     final def iOSTarget = System.getenv(‘SDK_NAME’)?.startsWith(“iphoneos”) ? presets.iosArm64 : presets.iosX64
  33.     targets {
  34.         fromPreset(iOSTarget, ‘iOS’) {
  35.             binaries {
  36.                 framework(“SharedCode”)
  37.             }
  38.         }
  39.     }
  40.  
  41.     presets
  42.  
  43.     android(‘android’).attributes {
  44.         attribute(mobilePlatformAttribute, ‘android’)
  45.     }
  46.  
  47.     sourceSets {
  48.  
  49.         commonMain.dependencies {
  50.             api kotlin(‘stdlib-common’)
  51.             implementation “io.ktor:ktor-client-core:$ktor_version”
  52.             implementation “io.ktor:ktor-client-json:$ktor_version”
  53.             implementation “io.ktor:ktor-client-logging:$ktor_version”
  54.  
  55.  
  56.             implementation “org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version”
  57.             implementation “org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version”
  58.  
  59. //             Time and Date Lib https://korlibs.soywiz.com/klock/
  60.             implementation “com.soywiz.korlibs.klock:klock:$klockVersion”
  61.         }
  62.  
  63.         commonTest.dependencies {
  64.             implementation kotlin(“test-common”)
  65.             implementation kotlin(“test-annotations-common”)
  66.             api kotlin(‘stdlib-common’)
  67.         }
  68.  
  69.  
  70.         androidMain.dependencies {
  71.             api kotlin(‘stdlib’)
  72.             implementation “io.ktor:ktor-client-android:$ktor_version”
  73.             implementation “io.ktor:ktor-client-json-jvm:$ktor_version”
  74.             implementation “io.ktor:ktor-client-logging-jvm:$ktor_version”
  75.  
  76.             implementation “org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version”
  77.             implementation “org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version”
  78.         }
  79.        
  80.         androidTest.dependencies {
  81.             implementation kotlin(“test-junit”)
  82.         }
  83.        
  84. //        For when Kotlin multiplatform properly supports multiple android targets
  85. //        consoleMain.dependencies {
  86. //                api kotlin(‘stdlib’)
  87. //        }
  88.  
  89.         iOSMain.dependencies {
  90.             api kotlin(‘stdlib’)
  91.             implementation “org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version”
  92.             implementation “io.ktor:ktor-client-ios:$ktor_version”
  93.             implementation “io.ktor:ktor-client-json-native:$ktor_version”
  94.             implementation “io.ktor:ktor-client-logging-native:$ktor_version”
  95.             implementation “org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version”
  96.            
  97.         }
  98.     }
  99.  
  100.     dokka {
  101.         outputFormat = ‘kotlin-website*’
  102.         outputDirectory = “$buildDir/javadoc”
  103.     }
  104. }
  105.  
  106. configurations {
  107.     compileClasspath
  108. }
  109.  
  110. task packForXCode(type: Sync) {
  111.     final File frameworkDir = new File(buildDir, “xcode-frameworks”)
  112.     final String mode = project.findProperty(“XCODE_CONFIGURATION”)?.toUpperCase() ?: ‘DEBUG’
  113.     final def framework = kotlin.targets.iOS.binaries.getFramework(“SharedCode”, mode)
  114.  
  115.     inputs.property “mode”, mode
  116.     dependsOn framework.linkTask as Task
  117.  
  118.     from { framework.outputFile.parentFile }
  119.     into frameworkDir
  120.  
  121.     doLast {
  122.         new File(frameworkDir, ‘gradlew’).with {
  123.             text = “#!/bin/bash\nexport ‘JAVA_HOME=${System.getProperty(“java.home”)}‘\ncd ‘${rootProject.rootDir}’\n./gradlew \$@\n”
  124.             setExecutable(true)
  125.         }
  126.     }
  127. }
  128.  
  129. tasks.build.dependsOn packForXCode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement