diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 15321fcb..00000000 --- a/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 Russell Wolf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -buildscript { - ext.kotlin_version = '1.3.50' - repositories { - google() - maven { url "https://plugins.gradle.org/m2/" } - maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' } - jcenter() - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "com.android.tools.build:gradle:3.4.1" - classpath "com.moowork.gradle:gradle-node-plugin:1.3.1" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4-jetbrains-3" - } -} - -subprojects { - group 'com.russhwolf' - version '0.3.2' - - repositories { - google() - jcenter() - } - - tasks.withType(AbstractTestTask) { - testLogging { - showStandardStreams = true - events 'passed', 'failed' - } - } -} diff --git a/sample/build.gradle b/build.gradle.kts similarity index 58% rename from sample/build.gradle rename to build.gradle.kts index 9ce4b9c0..f67fe76c 100644 --- a/sample/build.gradle +++ b/build.gradle.kts @@ -14,28 +14,27 @@ * limitations under the License. */ -buildscript { - ext.kotlin_version = '1.3.50' - ext.library_version = '0.3.2' - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } +plugins { + kotlin("multiplatform").version("1.3.50").apply(false) + id("com.android.library").version("3.4.1").apply(false) } -allprojects { +subprojects { + group = "com.russhwolf" + version = "0.3.3" + repositories { - mavenLocal() google() jcenter() - maven { url 'https://dl.bintray.com/russhwolf/multiplatform-settings' } } -} -task clean(type: Delete) { - delete rootProject.buildDir + tasks.withType(AbstractTestTask::class) { + testLogging { + showStandardStreams = true + events("passed", "failed") + } + } + + // workaround for https://youtrack.jetbrains.com/issue/KT-27170 + configurations.create("compileClasspath") } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41b1321a..f0035199 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Sun Jun 09 17:45:17 EDT 2019 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/multiplatform-settings-test/build.gradle b/multiplatform-settings-test/build.gradle deleted file mode 100644 index 466801ea..00000000 --- a/multiplatform-settings-test/build.gradle +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2019 Russell Wolf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id 'kotlin-multiplatform' -} -apply plugin: 'com.android.library' -apply plugin: 'maven-publish' -apply plugin: 'com.jfrog.bintray' -apply from: rootProject.file('gradle/publish.gradle') - -kotlin { - android { - publishAllLibraryVariants() - } - jvm() - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - js { - browser() - configure([compilations.main, compilations.test]) { - tasks.getByName(compileKotlinTaskName).kotlinOptions { - metaInfo = true - sourceMap = true - moduleKind = 'umd' - } - } - } - sourceSets { - all { - languageSettings { - useExperimentalAnnotation('kotlin.Experimental') - } - } - commonMain { - dependencies { - implementation kotlin("stdlib-common") - - implementation project(":multiplatform-settings") - } - } - commonTest { - dependencies { - implementation project(":tests") - - implementation kotlin("test-common") - implementation kotlin("test-annotations-common") - } - } - - androidMain { - dependencies { - implementation kotlin("stdlib") - } - } - androidTest { - dependencies { - implementation kotlin("test") - implementation kotlin("test-junit") - implementation 'junit:junit:4.12' - } - } - - jvmMain { - dependencies { - implementation kotlin("stdlib") - } - } - jvmTest { - dependencies { - implementation kotlin("test") - implementation kotlin("test-junit") - implementation 'junit:junit:4.12' - } - } - - iosSimMain.dependsOn iosMain - iosSimTest.dependsOn iosTest - macosMain.dependsOn iosMain - macosTest.dependsOn iosTest - - jsMain { - dependencies { - implementation kotlin('stdlib-js') - } - } - jsTest { - dependencies { - implementation kotlin('test-js') - } - } - } -} - -android { - compileSdkVersion 28 - - defaultConfig { - minSdkVersion 15 - } -} - -task iosTest(dependsOn: 'linkDebugTestIosSim') { - doLast { - def testBinaryPath = kotlin.targets.iosSim.binaries.getTest('DEBUG').outputFile.absolutePath - exec { - commandLine 'xcrun', 'simctl', 'spawn', "iPhone Xʀ", testBinaryPath - } - } -} -tasks.allTests.dependsOn iosTest - -// workaround for https://youtrack.jetbrains.com/issue/KT-27170 -configurations { - compileClasspath -} diff --git a/multiplatform-settings-test/build.gradle.kts b/multiplatform-settings-test/build.gradle.kts new file mode 100644 index 00000000..142626e6 --- /dev/null +++ b/multiplatform-settings-test/build.gradle.kts @@ -0,0 +1,141 @@ +/* + * Copyright 2019 Russell Wolf + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile + +plugins { + kotlin("multiplatform") + id("com.android.library") + id("maven-publish") + id("com.jfrog.bintray") version "1.8.4-jetbrains-3" +} +apply(from = "../gradle/publish.gradle") + +kotlin { + android { + publishAllLibraryVariants() + } + jvm() + iosArm64("ios") + iosX64("iosSim") + macosX64("macos") + js { + browser() + compilations.all { + (tasks.getByName(compileKotlinTaskName) as Kotlin2JsCompile).kotlinOptions { + metaInfo = true + sourceMap = true + moduleKind = "umd" + } + } + } + sourceSets { + all { + languageSettings.apply { + useExperimentalAnnotation("kotlin.Experimental") + } + } + commonMain { + dependencies { + implementation(kotlin("stdlib-common")) + + implementation(project(":multiplatform-settings")) + } + } + commonTest { + dependencies { + implementation(project(":tests")) + + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } + } + + val androidMain by getting { + dependencies { + implementation(kotlin("stdlib")) + } + } + val androidTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation("junit:junit:4.12") + } + } + + val jvmMain by getting { + dependencies { + implementation(kotlin("stdlib")) + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation("junit:junit:4.12") + } + } + + val iosMain by getting + val iosTest by getting + + val iosSimMain by getting { + dependsOn(iosMain) + } + val iosSimTest by getting { + dependsOn(iosTest) + } + val macosMain by getting { + dependsOn(iosMain) + } + val macosTest by getting { + dependsOn(iosTest) + } + + val jsMain by getting { + dependencies { + implementation(kotlin("stdlib-js")) + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + } + } + } +} + +android { + compileSdkVersion(28) + + defaultConfig { + minSdkVersion(15) + } +} + +task("iosTest") { + dependsOn("linkDebugTestIosSim") + doLast { + val testBinaryPath = + (kotlin.targets["iosSim"] as KotlinNativeTarget).binaries.getTest("DEBUG").outputFile.absolutePath + exec { + commandLine("xcrun", "simctl", "spawn", "iPhone Xʀ", testBinaryPath) + } + } +} +tasks["allTests"].dependsOn("iosTest") diff --git a/multiplatform-settings/build.gradle b/multiplatform-settings/build.gradle deleted file mode 100644 index 71828656..00000000 --- a/multiplatform-settings/build.gradle +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2018 Russell Wolf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id 'kotlin-multiplatform' -} -apply plugin: 'com.android.library' -apply plugin: 'maven-publish' -apply plugin: 'com.jfrog.bintray' -apply from: rootProject.file('gradle/publish.gradle') - -kotlin { - android { - publishAllLibraryVariants() - } - jvm() - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - js { - browser() - configure([compilations.main, compilations.test]) { - tasks.getByName(compileKotlinTaskName).kotlinOptions { - metaInfo = true - sourceMap = true - moduleKind = 'umd' - } - } - } - - sourceSets { - all { - languageSettings { - useExperimentalAnnotation('kotlin.Experimental') - } - } - commonMain { - dependencies { - implementation kotlin("stdlib-common") - } - } - commonTest { - dependencies { - implementation project(":tests") - - implementation kotlin("test-common") - implementation kotlin("test-annotations-common") - } - } - - androidMain { - dependencies { - implementation kotlin("stdlib") - } - } - androidTest { - dependencies { - implementation kotlin("test") - implementation kotlin("test-junit") - implementation 'junit:junit:4.12' - implementation "androidx.test:core:1.2.0" - implementation "androidx.test.ext:junit:1.1.1" - implementation "org.robolectric:robolectric:4.0" - } - } - - jvmMain { - dependencies { - implementation kotlin("stdlib") - } - } - jvmTest { - dependencies { - implementation kotlin("test") - implementation kotlin("test-junit") - implementation 'junit:junit:4.12' - } - } - - iosSimMain.dependsOn iosMain - iosSimTest.dependsOn iosTest - macosMain.dependsOn iosMain - macosTest.dependsOn iosTest - - jsMain { - dependencies { - implementation kotlin('stdlib-js') - } - } - jsTest { - dependencies { - implementation kotlin('test-js') - } - } - } -} - -android { - compileSdkVersion 28 - - defaultConfig { - minSdkVersion 15 - } - - testOptions.unitTests.includeAndroidResources = true -} - -task iosTest(dependsOn: 'linkDebugTestIosSim') { - doLast { - def testBinaryPath = kotlin.targets.iosSim.binaries.getTest('DEBUG').outputFile.absolutePath - exec { - commandLine 'xcrun', 'simctl', 'spawn', "iPhone Xʀ", testBinaryPath - } - } -} -tasks.allTests.dependsOn iosTest - -// workaround for https://youtrack.jetbrains.com/issue/KT-27170 -configurations { - compileClasspath -} diff --git a/multiplatform-settings/build.gradle.kts b/multiplatform-settings/build.gradle.kts new file mode 100644 index 00000000..edf190e4 --- /dev/null +++ b/multiplatform-settings/build.gradle.kts @@ -0,0 +1,145 @@ +/* + * Copyright 2018 Russell Wolf + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile + +plugins { + kotlin("multiplatform") + id("com.android.library") + id("maven-publish") + id("com.jfrog.bintray") version "1.8.4-jetbrains-3" +} +apply(from = "../gradle/publish.gradle") + +kotlin { + android { + publishAllLibraryVariants() + } + jvm() + iosArm64("ios") + iosX64("iosSim") + macosX64("macos") + js { + browser() + compilations.all { + (tasks.getByName(compileKotlinTaskName) as Kotlin2JsCompile).kotlinOptions { + metaInfo = true + sourceMap = true + moduleKind = "umd" + } + } + } + + sourceSets { + all { + languageSettings.apply { + useExperimentalAnnotation("kotlin.Experimental") + } + } + commonMain { + dependencies { + implementation(kotlin("stdlib-common")) + } + } + commonTest { + dependencies { + implementation(project(":tests")) + + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } + } + + val androidMain by getting { + dependencies { + implementation(kotlin("stdlib")) + } + } + val androidTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation("junit:junit:4.12") + implementation("androidx.test:core:1.2.0") + implementation("androidx.test.ext:junit:1.1.1") + implementation("org.robolectric:robolectric:4.0") + } + } + + val jvmMain by getting { + dependencies { + implementation(kotlin("stdlib")) + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation("junit:junit:4.12") + } + } + + val iosMain by getting + val iosTest by getting + + val iosSimMain by getting { + dependsOn(iosMain) + } + val iosSimTest by getting { + dependsOn(iosTest) + } + val macosMain by getting { + dependsOn(iosMain) + } + val macosTest by getting { + dependsOn(iosTest) + } + + val jsMain by getting { + dependencies { + implementation(kotlin("stdlib-js")) + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + } + } + } +} + +android { + compileSdkVersion(28) + + defaultConfig { + minSdkVersion(15) + } + + testOptions.unitTests.isIncludeAndroidResources = true +} + +task("iosTest") { + dependsOn("linkDebugTestIosSim") + doLast { + val testBinaryPath = + (kotlin.targets["iosSim"] as KotlinNativeTarget).binaries.getTest("DEBUG").outputFile.absolutePath + exec { + commandLine("xcrun", "simctl", "spawn", "iPhone Xʀ", testBinaryPath) + } + } +} +tasks["allTests"].dependsOn("iosTest") diff --git a/sample/app-android/build.gradle b/sample/app-android/build.gradle deleted file mode 100644 index 4aa83df0..00000000 --- a/sample/app-android/build.gradle +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2018 Russell Wolf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' - -android { - compileSdkVersion 28 - - defaultConfig { - applicationId "com.russhwolf.settings.example" - minSdkVersion 15 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation project(':shared') - implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation "androidx.appcompat:appcompat:1.0.2" - implementation "androidx.constraintlayout:constraintlayout:1.1.3" - implementation "com.russhwolf:multiplatform-settings:$library_version" -} - diff --git a/sample/app-android/build.gradle.kts b/sample/app-android/build.gradle.kts new file mode 100644 index 00000000..c975815a --- /dev/null +++ b/sample/app-android/build.gradle.kts @@ -0,0 +1,55 @@ +import com.android.builder.model.BuildType + +/* + * Copyright 2018 Russell Wolf + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("com.android.application") + kotlin("android") +} + +android { + compileSdkVersion(28) + + defaultConfig { + applicationId = "com.russhwolf.settings.example" + minSdkVersion(15) + targetSdkVersion(28) + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" + + } + + buildTypes { + val release by getting { + this as? com.android.build.api.dsl.model.BuildType + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } +} + +dependencies { + implementation(project(":shared")) + implementation(fileTree("include" to listOf("*.jar"), "dir" to "libs")) + implementation(kotlin("stdlib")) + implementation("androidx.appcompat:appcompat:1.0.2") + implementation("androidx.constraintlayout:constraintlayout:1.1.3") + implementation("com.russhwolf:multiplatform-settings:${rootProject.ext["library_version"]}") +} + diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts new file mode 100644 index 00000000..1c2c0a6f --- /dev/null +++ b/sample/build.gradle.kts @@ -0,0 +1,41 @@ +/* + * Copyright 2018 Russell Wolf + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + kotlin("multiplatform").version("1.3.50").apply(false) + kotlin("android").version("1.3.50").apply(false) + id("com.android.library").version("3.4.1").apply(false) + id("com.android.application").version("3.4.1").apply(false) +} + +allprojects { + ext["library_version"] = "0.3.3" + + repositories { + mavenLocal() + google() + mavenCentral() + maven(url = "https://dl.bintray.com/russhwolf/multiplatform-settings") + jcenter() + } + + // workaround for https://youtrack.jetbrains.com/issue/KT-27170 + configurations.create("compileClasspath") +} + +task(name = "clean", type = Delete::class) { + delete(rootProject.buildDir) +} diff --git a/sample/gradle/wrapper/gradle-wrapper.properties b/sample/gradle/wrapper/gradle-wrapper.properties index 32d921f8..2e351aeb 100644 --- a/sample/gradle/wrapper/gradle-wrapper.properties +++ b/sample/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip diff --git a/sample/settings.gradle b/sample/settings.gradle.kts similarity index 60% rename from sample/settings.gradle rename to sample/settings.gradle.kts index cf2b4d91..1c9d28e3 100644 --- a/sample/settings.gradle +++ b/sample/settings.gradle.kts @@ -16,15 +16,20 @@ pluginManagement { resolutionStrategy { eachPlugin { - if (requested.id.id == "kotlin-multiplatform") { - useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}") + when (requested.id.id) { + "org.jetbrains.kotlin.multiplatform", + "org.jetbrains.kotlin.android"-> useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}") + "com.android.library", + "com.android.application" -> useModule("com.android.tools.build:gradle:${requested.version}") } } } repositories { + google() mavenCentral() - maven { url 'https://plugins.gradle.org/m2/' } + maven(url = "https://plugins.gradle.org/m2/") + jcenter() } } -include ':shared',':app-android' +include(":shared", ":app-android") diff --git a/sample/shared/build.gradle b/sample/shared/build.gradle deleted file mode 100644 index be98282b..00000000 --- a/sample/shared/build.gradle +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2018 Russell Wolf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id 'kotlin-multiplatform' -} -apply plugin: 'com.android.library' - -kotlin { - android() - - def iosTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64 - targetFromPreset(iosTarget, "ios") { - binaries { - framework("Shared") - } - } - - sourceSets { - all { - languageSettings { - useExperimentalAnnotation('kotlin.Experimental') - } - } - - commonMain { - dependencies { - implementation "com.russhwolf:multiplatform-settings:$library_version" - implementation kotlin('stdlib-common') - } - } - commonTest { - dependencies { - // Android needs to see this dependency in test sources as workaround for https://youtrack.jetbrains.com/issue/KT-29343 - implementation "com.russhwolf:multiplatform-settings:$library_version" - implementation "com.russhwolf:multiplatform-settings-test:$library_version" - - implementation kotlin('test') - implementation kotlin('test-annotations-common') - } - } - - androidMain { - dependencies { - implementation kotlin('stdlib') - } - } - androidTest { - dependencies { - implementation kotlin('test-junit') - } - } - - iosMain { - dependencies { - } - } - iosTest { - dependencies { - } - } - } -} - -android { - compileSdkVersion 28 - - defaultConfig { - minSdkVersion 15 - } -} - -task copyFramework { - def buildType = project.findProperty('kotlin.build.type') ?: 'DEBUG' - def framework = kotlin.targets.ios.compilations.main.target.binaries.findFramework("Shared", buildType) - dependsOn framework.linkTask - - doLast { - def srcFile = framework.outputFile - def targetDir = getProperty('configuration.build.dir') - copy { - from srcFile.parent - into targetDir - include 'Shared.framework/**' - include 'Shared.framework.dSYM' - } - } -} - -task iosTest(dependsOn: 'linkDebugTestIos') { - doLast { - def testBinaryPath = kotlin.targets.ios.binaries.getTest('DEBUG').outputFile.absolutePath - exec { - commandLine 'xcrun', 'simctl', 'spawn', "iPhone Xʀ", testBinaryPath - } - } -} -tasks.check.dependsOn iosTest - -// workaround for https://youtrack.jetbrains.com/issue/KT-27170 -configurations { - compileClasspath -} diff --git a/sample/shared/build.gradle.kts b/sample/shared/build.gradle.kts new file mode 100644 index 00000000..a0a849c6 --- /dev/null +++ b/sample/shared/build.gradle.kts @@ -0,0 +1,118 @@ +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget + +/* + * Copyright 2018 Russell Wolf + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("com.android.library") + kotlin("multiplatform") +} + +kotlin { + android() + + val iosTarget = if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true) { + presets.getByName("iosArm64") + } else { + presets.getByName("iosX64") + } + targetFromPreset(iosTarget, "ios") { + this as KotlinNativeTarget + binaries { + framework("Shared") + } + } + + sourceSets { + all { + languageSettings.apply { + useExperimentalAnnotation("kotlin.Experimental") + } + } + + commonMain { + dependencies { + implementation("com.russhwolf:multiplatform-settings:${rootProject.ext["library_version"]}") + implementation(kotlin("stdlib-common")) + } + } + commonTest { + dependencies { + implementation("com.russhwolf:multiplatform-settings-test:${rootProject.ext["library_version"]}") + + implementation(kotlin("test")) + implementation(kotlin("test-annotations-common")) + } + } + + val androidMain by getting { + dependencies { + implementation(kotlin("stdlib")) + } + } + val androidTest by getting { + dependencies { + implementation(kotlin("test-junit")) + } + } + + val iosMain by getting { + dependencies { + } + } + val iosTest by getting { + dependencies { + } + } + } +} + +android { + compileSdkVersion(28) + + defaultConfig { + minSdkVersion(15) + } +} + +task("copyFramework") { + val buildType = project.findProperty("kotlin.build.type") as? String ?: "DEBUG" + val framework = (kotlin.targets["ios"] as KotlinNativeTarget).compilations["main"].target.binaries.findFramework("Shared", buildType)!! + dependsOn(framework.linkTask) + + doLast { + val srcFile = framework.outputFile + val targetDir = project.property("configuration.build.dir") as? String ?: "" + copy { + from(srcFile.parent) + into(targetDir) + include("Shared.framework/**") + include("Shared.framework.dSYM") + } + } +} + +task("iosTest") { + dependsOn("linkDebugTestIos") + doLast { + val testBinaryPath = + (kotlin.targets["ios"] as KotlinNativeTarget).binaries.getTest("DEBUG").outputFile.absolutePath + exec { + commandLine("xcrun", "simctl", "spawn", "iPhone Xʀ", testBinaryPath) + } + } +} +tasks["check"].dependsOn("iosTest") diff --git a/settings.gradle b/settings.gradle.kts similarity index 52% rename from settings.gradle rename to settings.gradle.kts index 755490fa..46a3e1d3 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -16,16 +16,21 @@ pluginManagement { resolutionStrategy { eachPlugin { - if (requested.id.id == "kotlin-multiplatform") { - useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}") + when (requested.id.id) { + "org.jetbrains.kotlin.multiplatform" -> useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}") + "com.android.library" -> useModule("com.android.tools.build:gradle:${requested.version}") + "com.jfrog.bintray" -> useModule("com.jfrog.bintray.gradle:gradle-bintray-plugin:${requested.version}") } } } repositories { + google() mavenCentral() - maven { url 'https://plugins.gradle.org/m2/' } + maven(url = "https://plugins.gradle.org/m2/") + maven(url = "https://dl.bintray.com/jetbrains/kotlin-native-dependencies") + jcenter() } } -enableFeaturePreview('GRADLE_METADATA') -include ':multiplatform-settings', ':multiplatform-settings-test', ':tests' +enableFeaturePreview("GRADLE_METADATA") +include(":multiplatform-settings", ":multiplatform-settings-test", ":tests") diff --git a/tests/build.gradle b/tests/build.gradle deleted file mode 100644 index 1b5b5ba6..00000000 --- a/tests/build.gradle +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2019 Russell Wolf - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id 'kotlin-multiplatform' -} -apply plugin: 'com.android.library' - -kotlin { - android() - jvm() - iosArm64("ios") - iosX64("iosSim") - macosX64("macos") - js { - browser() - compilations.main { - tasks.getByName(compileKotlinTaskName).kotlinOptions { - metaInfo = true - sourceMap = true - moduleKind = 'umd' - } - } - } - sourceSets { - all { - languageSettings { - useExperimentalAnnotation('kotlin.Experimental') - } - } - commonMain { - dependencies { - implementation kotlin("stdlib-common") - - implementation project(":multiplatform-settings") - - implementation kotlin("test-common") - implementation kotlin("test-annotations-common") - } - } - - androidMain { - dependencies { - implementation kotlin("stdlib") - - implementation kotlin("test") - implementation kotlin("test-junit") - implementation 'junit:junit:4.12' - } - } - - jvmMain { - dependencies { - implementation kotlin("stdlib") - - implementation kotlin("test") - implementation kotlin("test-junit") - implementation 'junit:junit:4.12' - } - } - - iosSimMain.dependsOn iosMain - macosMain.dependsOn iosMain - - jsMain { - dependencies { - implementation kotlin('stdlib-js') - - implementation kotlin('test-js') - } - } - } -} - -android { - compileSdkVersion 28 - - defaultConfig { - minSdkVersion 15 - } -} - -// workaround for https://youtrack.jetbrains.com/issue/KT-27170 -configurations { - compileClasspath -} - diff --git a/tests/build.gradle.kts b/tests/build.gradle.kts new file mode 100644 index 00000000..c5cd61d6 --- /dev/null +++ b/tests/build.gradle.kts @@ -0,0 +1,102 @@ +import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile + +/* + * Copyright 2019 Russell Wolf + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + kotlin("multiplatform") + id("com.android.library") +} + +kotlin { + android() + jvm() + iosArm64("ios") + iosX64("iosSim") + macosX64("macos") + js { + browser() + compilations.all { + (tasks.getByName(compileKotlinTaskName) as Kotlin2JsCompile).kotlinOptions { + metaInfo = true + sourceMap = true + moduleKind = "umd" + } + } + } + sourceSets { + all { + languageSettings.apply { + useExperimentalAnnotation("kotlin.Experimental") + } + } + commonMain { + dependencies { + implementation(kotlin("stdlib-common")) + + implementation(project(":multiplatform-settings")) + + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } + } + + val androidMain by getting { + dependencies { + implementation(kotlin("stdlib")) + + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation("junit:junit:4.12") + } + } + + val jvmMain by getting { + dependencies { + implementation(kotlin("stdlib")) + + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + implementation("junit:junit:4.12") + } + } + + val iosMain by getting + + val iosSimMain by getting { + dependsOn(iosMain) + } + val macosMain by getting { + dependsOn(iosMain) + } + + val jsMain by getting { + dependencies { + implementation(kotlin("stdlib-js")) + + implementation(kotlin("test-js")) + } + } + } +} + +android { + compileSdkVersion(28) + + defaultConfig { + minSdkVersion(15) + } +}