Rename gradle modules to jvm and android

This commit is contained in:
Steve Myers
2021-06-20 18:48:48 -07:00
parent 9e5aac759d
commit a830d9b082
12 changed files with 49 additions and 41 deletions

View File

@@ -0,0 +1,75 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
//task buildRust(type: Exec) {
// workingDir '../'
// commandLine './build.sh'
//}
afterEvaluate {
// android.libraryVariants.all { variant ->
// variant.javaCompileProvider.get().dependsOn(buildRust)
// }
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'org.bitcoindevkit'
artifactId = 'bdk'
version = '0.0.1-dev'
}
// Creates a Maven publication called “debug”.
debug(MavenPublication) {
// Applies the component for the debug build variant.
from components.debug
groupId = 'org.bitcoindevkit'
artifactId = 'bdk-debug'
version = '0.0.1-dev'
}
}
}
}
dependencies {
implementation (project(':jvm')) {
exclude group: 'net.java.dev.jna', module: 'jna'
}
api 'net.java.dev.jna:jna:5.8.0@aar'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.core:core-ktx:1.5.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
}

View File

26
bdk-kotlin/android/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,26 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# for JNA
-dontwarn java.awt.*
-keep class com.sun.jna.* { *; }
-keepclassmembers class * extends com.sun.jna.* { public *; }

View File

@@ -0,0 +1,64 @@
package org.bitcoindevkit.bdk
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.sun.jna.Native
import org.junit.*
import org.junit.runner.RunWith
import org.junit.Assert.*
//import org.bitcoindevkit.bdkjni.Types.Network
//import org.bitcoindevkit.bdkjni.Types.WalletConstructor
//import org.bitcoindevkit.bdkjni.Types.WalletPtr
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class AndroidLibTest {
companion object {
private val bdkFfi: Lib = Native.load("bdk_ffi", Lib::class.java)
private lateinit var wallet: Lib.WalletPtr_t
@BeforeClass
@JvmStatic
fun create_wallet() {
val name = "test_wallet"
val desc =
"wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)"
val change =
"wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/1/*)"
wallet = bdkFfi.new_wallet(name, desc, change)
Log.d("create_wallet", "wallet created")
}
@AfterClass
@JvmStatic
fun free_wallet() {
bdkFfi.free_wallet(wallet)
Log.d("free_wallet", "wallet freed")
}
}
@Test
fun sync() {
bdkFfi.sync_wallet(wallet)
Log.d("sync", "wallet synced")
}
@Test
fun new_address() {
val pointer = bdkFfi.new_address(wallet)
val address = pointer.getString(0)
bdkFfi.free_string(pointer)
//println("address created from kotlin: $address")
assertEquals(address, "tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e")
Log.d("new_address", "new address: $address")
}
}

View File

@@ -0,0 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.bitcoindevkit.bdk" >
<uses-permission android:name="android.permission.INTERNET" />
</manifest>