2
0

build.gradle.kts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. @file:Suppress("UNUSED_VARIABLE")
  2. plugins {
  3. kotlin("multiplatform")
  4. id("kotlinx-atomicfu")
  5. id("kotlinx-serialization")
  6. `maven-publish`
  7. id("com.jfrog.bintray") version "1.8.4-jetbrains-3" // DO NOT CHANGE THIS VERSION UNLESS YOU WANT TO WASTE YOUR TIME
  8. }
  9. apply(from = rootProject.file("gradle/publish.gradle"))
  10. val kotlinVersion: String by rootProject.ext
  11. val atomicFuVersion: String by rootProject.ext
  12. val coroutinesVersion: String by rootProject.ext
  13. val kotlinXIoVersion: String by rootProject.ext
  14. val coroutinesIoVersion: String by rootProject.ext
  15. val klockVersion: String by rootProject.ext
  16. val ktorVersion: String by rootProject.ext
  17. val serializationVersion: String by rootProject.ext
  18. fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
  19. fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
  20. description = "QQ protocol library"
  21. val isAndroidSDKAvailable: Boolean by project
  22. kotlin {
  23. if (isAndroidSDKAvailable) {
  24. apply(from = rootProject.file("gradle/android.gradle"))
  25. android("android") {
  26. publishAllLibraryVariants()
  27. }
  28. } else {
  29. println(
  30. """Android SDK 可能未安装.
  31. $name 的 Android 目标编译将不会进行.
  32. 这不会影响 Android 以外的平台的编译.
  33. """.trimIndent()
  34. )
  35. println(
  36. """Android SDK might not be installed.
  37. Android target of $name will not be compiled.
  38. It does no influence on the compilation of other platforms.
  39. """.trimIndent()
  40. )
  41. }
  42. jvm("jvm") {
  43. }
  44. sourceSets {
  45. all {
  46. languageSettings.enableLanguageFeature("InlineClasses")
  47. languageSettings.useExperimentalAnnotation("kotlin.Experimental")
  48. dependencies {
  49. api(kotlin("stdlib", kotlinVersion))
  50. api(kotlin("serialization", kotlinVersion))
  51. api("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
  52. api(kotlinx("io", kotlinXIoVersion))
  53. api(kotlinx("coroutines-io", coroutinesIoVersion))
  54. api(kotlinx("coroutines-core", coroutinesVersion))
  55. }
  56. }
  57. commonMain {
  58. dependencies {
  59. api(kotlin("reflect", kotlinVersion))
  60. api(kotlin("serialization", kotlinVersion))
  61. api(kotlinx("coroutines-core-common", coroutinesVersion))
  62. api(kotlinx("serialization-runtime-common", serializationVersion))
  63. api(ktor("http-cio", ktorVersion))
  64. api(ktor("http", ktorVersion))
  65. api(ktor("client-core-jvm", ktorVersion))
  66. api(ktor("client-cio", ktorVersion))
  67. api(ktor("client-core", ktorVersion))
  68. api(ktor("network", ktorVersion))
  69. //implementation("io.ktor:ktor-io:1.3.0-beta-1")
  70. //runtimeOnly(files("build/classes/kotlin/metadata/main")) // classpath is not properly set by IDE
  71. }
  72. }
  73. commonTest {
  74. dependencies {
  75. api(kotlin("test-annotations-common"))
  76. api(kotlin("test-common"))
  77. //runtimeOnly(files("build/classes/kotlin/metadata/test")) // classpath is not properly set by IDE
  78. }
  79. }
  80. if (isAndroidSDKAvailable) {
  81. val androidMain by getting {
  82. dependencies {
  83. api(kotlin("reflect", kotlinVersion))
  84. api(kotlinx("serialization-runtime", serializationVersion))
  85. api(kotlinx("coroutines-android", coroutinesVersion))
  86. api(ktor("client-android", ktorVersion))
  87. }
  88. }
  89. val androidTest by getting {
  90. dependencies {
  91. api(kotlin("test", kotlinVersion))
  92. api(kotlin("test-junit", kotlinVersion))
  93. api(kotlin("test-annotations-common"))
  94. api(kotlin("test-common"))
  95. }
  96. }
  97. }
  98. val jvmMain by getting {
  99. dependencies {
  100. //api(kotlin("stdlib-jdk8", kotlinVersion))
  101. //api(kotlin("stdlib-jdk7", kotlinVersion))
  102. api(kotlin("reflect", kotlinVersion))
  103. api(ktor("client-core-jvm", ktorVersion))
  104. api(kotlinx("io-jvm", kotlinXIoVersion))
  105. api(kotlinx("serialization-runtime", serializationVersion))
  106. api("org.bouncycastle:bcprov-jdk15on:1.64")
  107. runtimeOnly(files("build/classes/kotlin/jvm/main")) // classpath is not properly set by IDE
  108. }
  109. }
  110. val jvmTest by getting {
  111. dependencies {
  112. api(kotlin("test", kotlinVersion))
  113. api(kotlin("test-junit", kotlinVersion))
  114. implementation("org.pcap4j:pcap4j-distribution:1.8.2")
  115. runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
  116. }
  117. }
  118. }
  119. }