A "universal" / normalized API wrapper for git hosting services.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

185 lines
6.5 KiB

  1. apply plugin: "com.android.library"
  2. apply plugin: "kotlin-multiplatform"
  3. apply plugin: "kotlinx-serialization"
  4. def libraryVersion = "0.0.7"
  5. def libraryVersionCode = 7
  6. apply plugin: 'maven-publish'
  7. group 'gitrest'
  8. version libraryVersion
  9. android {
  10. compileSdkVersion 29
  11. defaultConfig {
  12. minSdkVersion 16
  13. targetSdkVersion 29
  14. versionCode libraryVersionCode
  15. versionName libraryVersion
  16. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  17. consumerProguardFiles 'consumer-rules.pro'
  18. }
  19. sourceSets {
  20. main {
  21. manifest.srcFile 'src/androidMain/AndroidManifest.xml'
  22. java.srcDirs = ['src/androidMain/kotlin']
  23. res.srcDirs = ['src/androidMain/res']
  24. }
  25. androidTest {
  26. java.srcDirs = ['src/androidTest/kotlin']
  27. res.srcDirs = ['src/androidTest/res']
  28. }
  29. }
  30. buildTypes {
  31. release {
  32. minifyEnabled false
  33. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  34. }
  35. }
  36. configurations.implementation {
  37. resolutionStrategy {
  38. // excluding "-common" dependencies from Android to prevent duplicate META-INF bugs
  39. exclude group: "org.jetbrains.kotlinx", module: "kotlinx-serialization-runtime-common"
  40. }
  41. }
  42. }
  43. // temporary solution for https://youtrack.jetbrains.com/issue/KT-34389
  44. project.plugins.apply(org.jetbrains.kotlin.gradle.targets.js.npm.NpmResolverPlugin)
  45. kotlin {
  46. js {
  47. compilations.main.kotlinOptions.moduleKind = 'umd'
  48. nodejs()
  49. browser {
  50. dceTask {
  51. keep 'git-rest-wrapper-gitrest.Client', "ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io"
  52. }
  53. compilations.all {
  54. kotlinOptions {
  55. metaInfo = true
  56. sourceMap = true
  57. sourceMapEmbedSources = "always"
  58. moduleKind = "umd"
  59. main = "call"
  60. }
  61. }
  62. }
  63. }
  64. jvm()
  65. android {
  66. publishAllLibraryVariants()
  67. publishLibraryVariantsGroupedByFlavor = false
  68. }
  69. sourceSets {
  70. commonMain {
  71. dependencies {
  72. compileOnly kotlin('stdlib-common')
  73. compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4'
  74. compileOnly "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version"
  75. compileOnly "io.ktor:ktor-client-core:$ktor_version"
  76. compileOnly "io.ktor:ktor-client-json:$ktor_version"
  77. compileOnly ("io.ktor:ktor-client-serialization:$ktor_version") {
  78. exclude group: "org.jetbrains.kotlinx", module: "kotlinx-serialization-json-common"
  79. }
  80. }
  81. }
  82. commonTest {
  83. dependencies {
  84. implementation kotlin('test-common')
  85. implementation kotlin('test-annotations-common')
  86. }
  87. }
  88. jvmMain {
  89. dependencies {
  90. api kotlin('stdlib-jdk8')
  91. //implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
  92. implementation "io.ktor:ktor-client-apache:$ktor_version"
  93. implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
  94. implementation ("io.ktor:ktor-client-serialization-jvm:$ktor_version") {
  95. // excluding transitive dependencies from Android to prevent duplicate META-INF bugs
  96. exclude group: "org.jetbrains.kotlinx", module: "kotlinx-serialization-runtime-common"
  97. }
  98. }
  99. }
  100. jvmTest {
  101. dependencies {
  102. implementation kotlin('test')
  103. implementation kotlin('test-junit')
  104. }
  105. }
  106. androidMain {
  107. dependencies {
  108. api kotlin('stdlib-jdk7')
  109. //implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
  110. implementation "io.ktor:ktor-client-android:$ktor_version"
  111. implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
  112. implementation ("io.ktor:ktor-client-serialization-jvm:$ktor_version") {
  113. // excluding transitive dependencies from Android builds to prevent duplicate META-INF bugs
  114. exclude group: "org.jetbrains.kotlinx", module: "kotlinx-serialization-runtime-common"
  115. }
  116. }
  117. }
  118. androidTest {
  119. dependencies {
  120. implementation kotlin('test')
  121. implementation kotlin('test-junit')
  122. implementation 'com.android.support.test:runner:1.0.2'
  123. }
  124. }
  125. jsMain {
  126. dependencies {
  127. implementation kotlin('stdlib-js')
  128. implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.6'
  129. implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version"
  130. implementation "io.ktor:ktor-client-js:$ktor_version"
  131. implementation "io.ktor:ktor-client-json-js:$ktor_version"
  132. implementation "io.ktor:ktor-client-serialization-js:$ktor_version"
  133. implementation npm("node-fetch", "2.6.0")
  134. implementation npm("text-encoding", "0.7.0")
  135. implementation npm("abort-controller", "3.0.0")
  136. }
  137. }
  138. jsTest {
  139. dependencies {
  140. implementation kotlin('test-js')
  141. }
  142. }
  143. nativeMain {
  144. dependencies {
  145. implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
  146. implementation "io.ktor:ktor-client-curl:$ktor_version"
  147. implementation "io.ktor:ktor-client-json-native:$ktor_version"
  148. implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
  149. }
  150. }
  151. nativeTest {}
  152. }
  153. }
  154. configurations { // Seems to be a hack for a gradle bug.
  155. compileClasspath
  156. }
  157. task run dependsOn "check"
  158. // random util task for CI / npm publish scripting
  159. task printVersionName {
  160. doLast {
  161. println libraryVersion
  162. }
  163. }
  164. // this doesn't launch properly on Arch & always fails (unsure why, but it's lengthy & a bit heavy for CI testing regardless)
  165. gradle.startParameter.excludedTaskNames += ["jsBrowserTest"]