Advertisement
Guest User

Untitled

a guest
May 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 2.21 KB | None | 0 0
  1. apply plugin: 'kotlin-multiplatform'
  2.  
  3.  
  4. def mobilePlatformAttribute = Attribute.of('com.inspirefitness.mobile', String)
  5. def consolePlatformAttribute = Attribute.of('com.inspirefitness.console', String)
  6.  
  7.  
  8.  
  9. configurations {
  10.  
  11.  
  12.     mobileConfiguration {
  13.         extendsFrom configurations.default
  14.  
  15.         attributes.attribute(mobilePlatformAttribute, 'mobile')
  16.     }
  17.    
  18.    
  19.     consoleConfiguration {
  20.        
  21.         extendsFrom configurations.default
  22.  
  23.         attributes.attribute(consolePlatformAttribute, 'console')
  24.     }
  25. }
  26.  
  27. kotlin {
  28.     targets {
  29.         final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
  30.                               ? presets.iosArm64 : presets.iosX64
  31.  
  32.         fromPreset(iOSTarget, 'iOS') {
  33.             compilations.main.outputKinds('FRAMEWORK')
  34.         }
  35.     }
  36.  
  37.    
  38.    
  39.     jvm('android').attributes {
  40.         attribute(mobilePlatformAttribute, 'mobile')
  41.     }
  42.    
  43.     jvm('console').attributes {
  44.         attribute(consolePlatformAttribute, 'console')
  45.     }
  46.    
  47.    
  48.     sourceSets {
  49.         commonMain.dependencies {
  50.             api 'org.jetbrains.kotlin:kotlin-stdlib-common'
  51.         }
  52.  
  53.         androidMain.dependencies {
  54.             api 'org.jetbrains.kotlin:kotlin-stdlib'
  55.         }
  56.        
  57.         consoleMain.dependencies {
  58.             api 'org.jetbrains.kotlin:kotlin-stdlib'
  59.         }
  60.        
  61.     }
  62. }
  63.  
  64. // workaround for https://youtrack.jetbrains.com/issue/KT-27170
  65. configurations {
  66.     compileClasspath
  67. }
  68.  
  69. task packForXCode(type: Sync) {
  70.     final File frameworkDir = new File(buildDir, "xcode-frameworks")
  71.     final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG'
  72.  
  73.     inputs.property "mode", mode
  74.     dependsOn kotlin.targets.iOS.compilations.main.linkTaskName("FRAMEWORK", mode)
  75.  
  76.     from { kotlin.targets.iOS.compilations.main.getBinary("FRAMEWORK", mode).parentFile }
  77.     into frameworkDir
  78.  
  79.     doLast {
  80.         new File(frameworkDir, 'gradlew').with {
  81.             text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
  82.             setExecutable(true)
  83.         }
  84.     }
  85. }
  86.  
  87. tasks.build.dependsOn packForXCode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement