Skip to content

Commit

Permalink
feat: wallet-core module init
Browse files Browse the repository at this point in the history
  • Loading branch information
hamada147 committed Nov 10, 2022
1 parent 29f62bb commit 1f03a35
Show file tree
Hide file tree
Showing 17 changed files with 358 additions and 1 deletion.
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pluginManagement {

rootProject.name = "wallet-sdk"
include(":wallet-sdk")
include(":wallet-core-sdk")
204 changes: 204 additions & 0 deletions wallet-core-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput.Target

version = rootProject.version
val currentModuleName: String = "wallet-core-sdk"
val os: OperatingSystem = OperatingSystem.current()

plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
id("org.jetbrains.dokka")
}

kotlin {
android {
publishAllLibraryVariants()
}
jvm {
compilations.all {
kotlinOptions {
jvmTarget = "11"
}
}
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
if (os.isMacOsX) {
ios()
tvos()
watchos()
macosX64()
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
iosSimulatorArm64()
tvosSimulatorArm64()
watchosSimulatorArm64()
macosArm64()
}
}
js(IR) {
this.moduleName = currentModuleName
this.binaries.executable()
this.useCommonJs()
this.compilations["main"].packageJson {
this.version = rootProject.version.toString()
}
this.compilations["test"].packageJson {
this.version = rootProject.version.toString()
}
browser {
this.webpackTask {
this.output.library = currentModuleName
this.output.libraryTarget = Target.VAR
}
this.commonWebpackConfig {
this.cssSupport {
this.enabled = true
}
}
this.testTask {
this.useKarma {
this.useChromeHeadless()
}
}
}
nodejs {
this.testTask {
this.useKarma {
this.useChromeHeadless()
}
}
}
}

if (os.isMacOsX) {
cocoapods {
this.summary = "Wallet-Core-SDK"
this.version = rootProject.version.toString()
this.authors = "IOG"
this.ios.deploymentTarget = "13.0"
this.osx.deploymentTarget = "12.0"
this.tvos.deploymentTarget = "13.0"
this.watchos.deploymentTarget = "8.0"
framework {
this.baseName = currentModuleName
}
}
}

sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}
val androidMain by getting
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}
val jsMain by getting
val jsTest by getting
if (os.isMacOsX) {
val iosMain by getting
val iosTest by getting
val tvosMain by getting
val tvosTest by getting
val watchosMain by getting
val watchosTest by getting
val macosX64Main by getting
val macosX64Test by getting
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
val iosSimulatorArm64Main by getting {
this.dependsOn(iosMain)
}
val iosSimulatorArm64Test by getting {
this.dependsOn(iosTest)
}
val tvosSimulatorArm64Main by getting {
this.dependsOn(tvosMain)
}
val tvosSimulatorArm64Test by getting {
this.dependsOn(tvosTest)
}
val watchosSimulatorArm64Main by getting {
this.dependsOn(watchosMain)
}
val watchosSimulatorArm64Test by getting {
this.dependsOn(watchosTest)
}
val macosArm64Main by getting {
this.dependsOn(macosX64Main)
}
val macosArm64Test by getting {
this.dependsOn(macosX64Test)
}
}
}
all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
}
}

android {
compileSdk = 32
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 21
targetSdk = 32
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
/**
* Because Software Components will not be created automatically for Maven publishing from
* Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.
* disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new
* publishing DSL.
*/
publishing {
multipleVariants {
withSourcesJar()
withJavadocJar()
allVariants()
}
}
}

// Dokka implementation
tasks.withType<DokkaTask> {
moduleName.set(project.name)
moduleVersion.set(rootProject.version.toString())
description = """
This is a Kotlin Multiplatform Wallet-Core-SDK Library
""".trimIndent()
dokkaSourceSets {
// TODO: Figure out how to include files to the documentations
named("commonMain") {
includes.from("Module.md", "docs/Module.md")
}
}
}

// afterEvaluate {
// tasks.withType<AbstractTestTask> {
// testLogging {
// events("passed", "skipped", "failed", "standard_out", "standard_error")
// showExceptions = true
// showStackTraces = true
// }
// }
// }
2 changes: 2 additions & 0 deletions wallet-core-sdk/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="io.iohk.prism.walletcore" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.iohk.atala.prism.walletcore

internal actual object Platform {
actual val OS: String
get() = "Android ${android.os.Build.VERSION.SDK_INT}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.iohk.atala.prism.walletcore

internal expect object Platform {
val OS: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.iohk.atala.prism.walletcore

import platform.UIKit.UIDevice

internal actual object Platform {
actual val OS: String
get() = "${UIDevice.currentDevice.systemName()}-${UIDevice.currentDevice.systemVersion}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.iohk.atala.prism.walletcore

import platform.UIKit.UIDevice

internal actual object Platform {
actual val OS: String
get() = "${UIDevice.currentDevice.systemName()}-${UIDevice.currentDevice.systemVersion}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.iohk.atala.prism.walletcore

internal actual object Platform {
private val isNodeJs by lazy { js("(typeof process === 'object' && typeof require === 'function')").unsafeCast<Boolean>() }
actual val OS: String
get() = if (isNodeJs) {
"NodeJS"
} else {
"JS"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.iohk.atala.prism.walletcore

internal actual object Platform {
actual val OS: String
get() = "JVM - ${System.getProperty("java.version")}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.iohk.atala.prism.walletcore

import platform.Foundation.NSProcessInfo

internal actual object Platform {
actual val OS: String
get() {
val processInfo = NSProcessInfo.processInfo()
return "${processInfo.operatingSystemName()}-${processInfo.operatingSystemVersionString()}"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.iohk.atala.prism.walletcore

import platform.UIKit.UIDevice

internal actual object Platform {
actual val OS: String
get() = "${UIDevice.currentDevice.systemName()}-${UIDevice.currentDevice.systemVersion}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.iohk.atala.prism.walletcore

import platform.UIKit.UIDevice

internal actual object Platform {
actual val OS: String
get() = "${UIDevice.currentDevice.systemName()}-${UIDevice.currentDevice.systemVersion}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.iohk.atala.prism.walletcore

import platform.WatchKit.WKInterfaceDevice

internal actual object Platform {
actual val OS: String
get() {
val wkInterfaceDevice = WKInterfaceDevice.currentDevice()
return "${wkInterfaceDevice.systemName}-${wkInterfaceDevice.systemVersion}"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.iohk.atala.prism.walletcore

import platform.WatchKit.WKInterfaceDevice

internal actual object Platform {
actual val OS: String
get() {
val wkInterfaceDevice = WKInterfaceDevice.currentDevice()
return "${wkInterfaceDevice.systemName}-${wkInterfaceDevice.systemVersion}"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.iohk.atala.prism.walletcore

import platform.WatchKit.WKInterfaceDevice

internal actual object Platform {
actual val OS: String
get() {
val wkInterfaceDevice = WKInterfaceDevice.currentDevice()
return "${wkInterfaceDevice.systemName}-${wkInterfaceDevice.systemVersion}"
}
}
42 changes: 42 additions & 0 deletions wallet-core-sdk/wallet_core_sdk.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Pod::Spec.new do |spec|
spec.name = 'wallet_core_sdk'
spec.version = '1.0.0-alpha'
spec.homepage = ''
spec.source = { :http=> ''}
spec.authors = 'IOG'
spec.license = ''
spec.summary = 'Wallet-Core-SDK'
spec.vendored_frameworks = 'build/cocoapods/framework/wallet-core-sdk.framework'
spec.libraries = 'c++'
spec.ios.deployment_target = '13.0'
spec.osx.deployment_target = '12.0'
spec.tvos.deployment_target = '13.0'
spec.watchos.deployment_target = '8.0'


spec.pod_target_xcconfig = {
'KOTLIN_PROJECT_PATH' => ':wallet-core-sdk',
'PRODUCT_MODULE_NAME' => 'wallet-core-sdk',
}

spec.script_phases = [
{
:name => 'Build wallet_core_sdk',
:execution_position => :before_compile,
:shell_path => '/bin/sh',
:script => <<-SCRIPT
if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
exit 0
fi
set -ev
REPO_ROOT="$PODS_TARGET_SRCROOT"
"$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \
-Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
-Pkotlin.native.cocoapods.archs="$ARCHS" \
-Pkotlin.native.cocoapods.configuration="$CONFIGURATION"
SCRIPT
}
]

end
Loading

0 comments on commit 1f03a35

Please sign in to comment.