From 247604e6963df0b01a5af72897af673d1b5f60b9 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 9 Jul 2020 22:45:23 +0200 Subject: [PATCH] Made BankFinder a multiplatform project --- tools/BankFinder/build.gradle | 171 +++++++++++++++--- .../banking/bankfinder/BankFinderBase.kt | 0 .../dankito/banking/bankfinder/BankInfo.kt | 0 .../dankito/banking/bankfinder/IBankFinder.kt | 0 .../banking/bankfinder/InMemoryBankFinder.kt | 0 .../resources/BankList.json | 0 .../banking/bankfinder/BankFinderTestBase.kt | 0 .../bankfinder/InMemoryBankFinderTest.kt | 0 tools/BankFinder/src/main/AndroidManifest.xml | 7 + 9 files changed, 156 insertions(+), 22 deletions(-) rename tools/BankFinder/src/{main => commonMain}/kotlin/net/dankito/banking/bankfinder/BankFinderBase.kt (100%) rename tools/BankFinder/src/{main => commonMain}/kotlin/net/dankito/banking/bankfinder/BankInfo.kt (100%) rename tools/BankFinder/src/{main => commonMain}/kotlin/net/dankito/banking/bankfinder/IBankFinder.kt (100%) rename tools/BankFinder/src/{main => commonMain}/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt (100%) rename tools/BankFinder/src/{main => commonMain}/resources/BankList.json (100%) rename tools/BankFinder/src/{test => commonTest}/kotlin/net/dankito/banking/bankfinder/BankFinderTestBase.kt (100%) rename tools/BankFinder/src/{test => commonTest}/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinderTest.kt (100%) create mode 100644 tools/BankFinder/src/main/AndroidManifest.xml diff --git a/tools/BankFinder/build.gradle b/tools/BankFinder/build.gradle index 49bd2390..a41178b9 100644 --- a/tools/BankFinder/build.gradle +++ b/tools/BankFinder/build.gradle @@ -1,35 +1,162 @@ -apply plugin: 'java-library' -apply plugin: 'kotlin' +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "com.android.library" + id "maven-publish" +} ext.artifactName = "bank-finder" -sourceCompatibility = "7" -targetCompatibility = "7" + +kotlin { + jvm { + compilations.main.kotlinOptions { + jvmTarget = "1.6" + } + } + + targets { + // Select iOS target for real device or emulator. + final def iOSIsRealDevice = System.getenv('SDK_NAME')?.startsWith("iphoneos") + final def iOSTarget = iOSIsRealDevice ? presets.iosArm64 : presets.iosX64 + + // iOS target. + fromPreset(iOSTarget, 'ios') { + binaries { + framework { + baseName = "fints4k" + } + } + } + } -dependencies { - api "net.dankito.utils:java-utils:$javaUtilsVersion" + sourceSets { + commonMain { + dependencies { + implementation kotlin("stdlib-common") + } + } + + commonTest { + dependencies { + implementation kotlin("test-common") + implementation kotlin("test-annotations-common") + + implementation "ch.tutteli.atrium:atrium-fluent-en_GB:$atriumVersion" + } + } - testImplementation "org.junit.jupiter:junit-jupiter:$junit5Version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" + jvmMain { + dependencies { + api "net.dankito.utils:java-utils:$javaUtilsVersion" + } + } - testImplementation "org.assertj:assertj-core:$assertJVersion" - testImplementation "org.mockito:mockito-core:$mockitoVersion" + jvmTest { + dependencies { + implementation kotlin("test-junit") + + implementation "org.junit.jupiter:junit-jupiter:$junit5Version" + runtimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" + + implementation "org.assertj:assertj-core:$assertJVersion" + implementation "org.mockito:mockito-core:$mockitoVersion" + + implementation "ch.tutteli.atrium:atrium-api-fluent-en_GB-jdk8:$atriumVersion" + } + + } + + + iosMain { + dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion" + } + } + + } +} + + +// Task to generate iOS framework for xcode projects. +task packForXCode(type: Sync) { + + final File frameworkDir = new File(buildDir, "xcode-frameworks") + final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG' + + final def framework = kotlin.targets.ios.binaries.getFramework("", mode) + + inputs.property "mode", mode + dependsOn framework.linkTask + + from { framework.outputFile.parentFile } + into frameworkDir + + doLast { + new File(frameworkDir, 'gradlew').with { + text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n" + setExecutable(true) + } + } +} + +// Run packForXCode when building. +tasks.build.dependsOn packForXCode + + +android { + compileSdkVersion androidCompileSdkVersion + + + defaultConfig { + minSdkVersion androidMinSdkVersion + targetSdkVersion androidTargetSdkVersion + + versionName version + versionCode appVersionCode + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + packagingOptions { + pickFirst 'META-INF/ktor-http.kotlin_module' + pickFirst 'META-INF/kotlinx-io.kotlin_module' + pickFirst 'META-INF/atomicfu.kotlin_module' + pickFirst 'META-INF/ktor-utils.kotlin_module' + pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module' + pickFirst 'META-INF/ktor-client-core.kotlin_module' + pickFirst 'META-INF/DEPENDENCIES' + pickFirst 'META-INF/NOTICE' + pickFirst 'META-INF/LICENSE' + pickFirst 'META-INF/LICENSE.txt' + pickFirst 'META-INF/NOTICE.txt' + } + + lintOptions { + abortOnError false + } } -task jarTest (type: Jar) { - from sourceSets.test.output - classifier = 'test' -} - -configurations { - testOutput -} - -artifacts { - testOutput jarTest -} \ No newline at end of file +//task jarTest (type: Jar) { +// from sourceSets.jvmTest.output +// classifier = 'test' +//} +// +//configurations { +// testOutput +//} +// +//artifacts { +// testOutput jarTest +//} \ No newline at end of file diff --git a/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/BankFinderBase.kt b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/BankFinderBase.kt similarity index 100% rename from tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/BankFinderBase.kt rename to tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/BankFinderBase.kt diff --git a/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/BankInfo.kt b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/BankInfo.kt similarity index 100% rename from tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/BankInfo.kt rename to tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/BankInfo.kt diff --git a/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/IBankFinder.kt b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/IBankFinder.kt similarity index 100% rename from tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/IBankFinder.kt rename to tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/IBankFinder.kt diff --git a/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt similarity index 100% rename from tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt rename to tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt diff --git a/tools/BankFinder/src/main/resources/BankList.json b/tools/BankFinder/src/commonMain/resources/BankList.json similarity index 100% rename from tools/BankFinder/src/main/resources/BankList.json rename to tools/BankFinder/src/commonMain/resources/BankList.json diff --git a/tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/BankFinderTestBase.kt b/tools/BankFinder/src/commonTest/kotlin/net/dankito/banking/bankfinder/BankFinderTestBase.kt similarity index 100% rename from tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/BankFinderTestBase.kt rename to tools/BankFinder/src/commonTest/kotlin/net/dankito/banking/bankfinder/BankFinderTestBase.kt diff --git a/tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinderTest.kt b/tools/BankFinder/src/commonTest/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinderTest.kt similarity index 100% rename from tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinderTest.kt rename to tools/BankFinder/src/commonTest/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinderTest.kt diff --git a/tools/BankFinder/src/main/AndroidManifest.xml b/tools/BankFinder/src/main/AndroidManifest.xml new file mode 100644 index 00000000..933bfcdb --- /dev/null +++ b/tools/BankFinder/src/main/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file