|
| 1 | +/* |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0. |
| 4 | + */ |
| 5 | +import org.jetbrains.kotlin.konan.target.HostManager |
| 6 | +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget |
| 7 | +import java.util.Properties |
| 8 | + |
| 9 | +plugins { |
| 10 | + kotlin("multiplatform") version "1.4.21" |
| 11 | + `maven` |
| 12 | + `maven-publish` |
| 13 | +} |
| 14 | + |
| 15 | +group = "software.amazon.awssdk.crt" |
| 16 | +version = "0.1.0-SNAPSHOT" |
| 17 | +description = "Kotlin Multiplatform bindings for AWS SDK Common Runtime" |
| 18 | + |
| 19 | +allprojects { |
| 20 | + repositories { |
| 21 | + mavenLocal() |
| 22 | + mavenCentral() |
| 23 | + jcenter() |
| 24 | + maven ("https://dl.bintray.com/kotlin/kotlin-eap") |
| 25 | + maven ("https://kotlin.bintray.com/kotlinx") |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +// See: https://kotlinlang.org/docs/reference/opt-in-requirements.html#opting-in-to-using-api |
| 30 | +val experimentalAnnotations = listOf("kotlin.RequiresOptIn") |
| 31 | + |
| 32 | + |
| 33 | +kotlin { |
| 34 | + explicitApi() |
| 35 | + |
| 36 | + jvm() |
| 37 | + |
| 38 | + val kotlinVersion: String by project |
| 39 | + val coroutinesVersion: String by project |
| 40 | + |
| 41 | + sourceSets { |
| 42 | + val commonMain by getting { |
| 43 | + dependencies { |
| 44 | + implementation(kotlin("stdlib-common")) |
| 45 | + // native multithreading support for coroutines is not stable... |
| 46 | + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion-native-mt") |
| 47 | + } |
| 48 | + } |
| 49 | + val commonTest by getting { |
| 50 | + dependencies { |
| 51 | + implementation(kotlin("test-common")) |
| 52 | + implementation(kotlin("test-annotations-common")) |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + val jvmMain by getting { |
| 57 | + dependencies { |
| 58 | + api("org.jetbrains.kotlin:kotlin-stdlib") |
| 59 | + val crtJavaVersion: String by project |
| 60 | + implementation("software.amazon.awssdk.crt:aws-crt:$crtJavaVersion") |
| 61 | + |
| 62 | + // FIXME - temporary integration with CompletableFuture while we work out a POC on the jvm target |
| 63 | + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVersion") |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + val jvmTest by getting { |
| 68 | + dependencies { |
| 69 | + val junitVersion: String by project |
| 70 | + api("org.jetbrains.kotlin:kotlin-test:$kotlinVersion") |
| 71 | + api("org.jetbrains.kotlin:kotlin-test-junit5:$kotlinVersion") |
| 72 | + implementation("org.junit.jupiter:junit-jupiter:$junitVersion") |
| 73 | + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutinesVersion") |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + } |
| 78 | + |
| 79 | + sourceSets.all { |
| 80 | + println("configuring source set $name") |
| 81 | + val srcDir = if (name.endsWith("Main")) "src" else "test" |
| 82 | + val resourcesPrefix = if (name.endsWith("Test")) "test-" else "" |
| 83 | + // source set name should always be the platform followed by a suffix of either "Main" or "Test |
| 84 | + // e.g. jvmMain, commonTest, etc |
| 85 | + val platform = name.substring(0, name.length - 4) |
| 86 | + |
| 87 | + kotlin.srcDir("src/$platform/$srcDir") |
| 88 | + resources.srcDir("src/$platform/${resourcesPrefix}resources") |
| 89 | + experimentalAnnotations.forEach { languageSettings.useExperimentalAnnotation(it) } |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +// have to configure JVM test task to use junit platform when using junit5 |
| 94 | +val jvmTest: Test by tasks |
| 95 | +jvmTest.apply { |
| 96 | + testLogging { |
| 97 | + events("passed", "skipped", "failed") |
| 98 | + showStandardStreams = true |
| 99 | + } |
| 100 | + |
| 101 | + useJUnitPlatform() |
| 102 | +} |
| 103 | + |
| 104 | +val ktlint by configurations.creating |
| 105 | +val ktlintVersion: String by project |
| 106 | + |
| 107 | +dependencies { |
| 108 | + ktlint("com.pinterest:ktlint:$ktlintVersion") |
| 109 | +} |
| 110 | + |
| 111 | +val lintPaths = listOf( |
| 112 | + "src/**/*.kt", |
| 113 | + "elasticurl/**/*.kt" |
| 114 | +) |
| 115 | + |
| 116 | +tasks.register<JavaExec>("ktlint") { |
| 117 | + description = "Check Kotlin code style." |
| 118 | + group = "Verification" |
| 119 | + classpath = configurations.getByName("ktlint") |
| 120 | + main = "com.pinterest.ktlint.Main" |
| 121 | + args = lintPaths |
| 122 | +} |
| 123 | + |
| 124 | +tasks.register<JavaExec>("ktlintFormat") { |
| 125 | + description = "Auto fix Kotlin code style violations" |
| 126 | + group = "formatting" |
| 127 | + classpath = configurations.getByName("ktlint") |
| 128 | + main = "com.pinterest.ktlint.Main" |
| 129 | + args = listOf("-F") + lintPaths |
| 130 | +} |
| 131 | + |
| 132 | +tasks.check.get().dependsOn(":ktlint") |
0 commit comments