Skip to content

Commit

Permalink
feat: Produce a self-contained .aar file for lib (algorandfoundation#19)
Browse files Browse the repository at this point in the history
* feat: Separates Android (with all-inclusive .aar) from Desktop

* fix: add .gitkeeps

* chore: remove debug printer

* feat: add .gitignore

* fix: since initialize.sh already builds, it is enough of a test

* docs: update README

* remove gradlew step that is part of initialize.sh

* feat: if any step in initialize fails, all fails

* updates gitignore and appcompat

* chore: comment out CBOR until it has been implemented elsewhere

* docs: clarify build

* docs: update workflow name

* fix: removes unnecessary check on decoded data

* docs: clarify github workflow
  • Loading branch information
HashMapsData2Value authored Mar 25, 2024
1 parent 1bd7de5 commit 4a68388
Show file tree
Hide file tree
Showing 40 changed files with 1,112 additions and 133 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/gradlew-test.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Run Gradle Test
name: Attempt a build with Gradle

on:
pull_request:
branches: [main]

jobs:
test-and-build:
run-initialize-sh:
runs-on: ubuntu-latest

steps:
Expand All @@ -23,11 +23,5 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Run Gradle Wrapper
run: chmod +x gradlew && gradle wrapper

- name: Initialize Repo and Jars
- name: Initialize submodule, generate jars, and build (including tests)
run: chmod +x initialize.sh && ./initialize.sh

- name: Run tests
run: ./gradlew test --info
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
hs_err_pid*
replay_pid*

# Ignore build outputs
dist/

# Ignore Gradle project-specific cache directory
.gradle

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ A Kotlin implementation of ARC-0052 Algorand, in accordance with the paper BIP32

Note that this library has not undergone audit and is not recommended for production use.

Currently there are two folders, one to create an .aar file for use in Android, another to prepare .jar files for use in standard Kotlin desktop use-cases.

## Installation

This library uses a forked version of LazySodium-Java that exposes Ed25519 operations. The fork has been added as a Git Submodule. It needs to be initialized, built and have its .jar files moved into lib/libs at the root level of this repository.
Expand All @@ -12,6 +14,8 @@ This library uses a forked version of LazySodium-Java that exposes Ed25519 opera
./initialize.sh
```

Running this will create a dist/ folder containing the .aar and .jar files respectively. These can be imported in your project.

### Note: For Linux Users

LazySodium-Java bundles up the LibSodium binaries and expose them as part of the .jar files. By default this library will attempt to use the bundled up binaries, but falls back to any system-wide installation of LibSodium.
Expand All @@ -26,6 +30,10 @@ apt-get install -y libsodium-dev

You might be required to install using `sudo` privileges.

## CI/CD

Github Workflows are used. `./initialize.sh`is called, which attempts to build the Android and Desktop libraries and output .aar respectively .jar files. By default `./gradlew build` also runs `./gradlew test`.

## How to Use

Initialize an instance of Bip32Ed25519 with seed bytes:
Expand Down
170 changes: 170 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Created by https://www.toptal.com/developers/gitignore/api/android,androidstudio
# Edit at https://www.toptal.com/developers/gitignore?templates=android,androidstudio

### Android ###
# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Log/OS Files
*.log

# Android Studio generated files and folders
captures/
.externalNativeBuild/
.cxx/
*.apk
output.json

# IntelliJ
*.iml
.idea/
misc.xml
deploymentTargetDropDown.xml
render.experimental.xml

# Keystore files
*.jks
*.keystore

# Google Services (e.g. APIs or Firebase)
google-services.json

# Android Profiling
*.hprof

### Android Patch ###
gen-external-apklibs

# Replacement of .externalNativeBuild directories introduced
# with Android Studio 3.5.

### AndroidStudio ###
# Covers files to be ignored for android development using Android Studio.

# Built application files
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle

# Signing files
.signing/

# Local configuration file (sdk path, etc)

# Proguard folder generated by Eclipse
proguard/

# Log Files

# Android Studio
/*/build/
/*/local.properties
/*/out
/*/*/build
/*/*/production
.navigation/
*.ipr
*~
*.swp

# Keystore files

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Android Patch

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# NDK
obj/

# IntelliJ IDEA
*.iws
/out/

# User-specific configurations
.idea/caches/
.idea/libraries/
.idea/shelf/
.idea/workspace.xml
.idea/tasks.xml
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
.idea/datasources.xml
.idea/dataSources.ids
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
.idea/assetWizardSettings.xml
.idea/gradle.xml
.idea/jarRepositories.xml
.idea/navEditor.xml

# Legacy Eclipse project files
.classpath
.project
.cproject
.settings/

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.war
*.ear

# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
hs_err_pid*

## Plugin-specific files:

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Mongo Explorer plugin
.idea/mongoSettings.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### AndroidStudio Patch ###

!/gradle/wrapper/gradle-wrapper.jar

# End of https://www.toptal.com/developers/gitignore/api/android,androidstudio

# Ignore the bip32ed25519kotlin .aar file
*.aar
16 changes: 16 additions & 0 deletions android/bip32ed25519/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions android/bip32ed25519/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions android/bip32ed25519/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions android/bip32ed25519/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version = "0.1.0"
group = "com.algorandfoundation.bip32ed25519"

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 34
buildToolsVersion "33.0.3"

buildFeatures {
viewBinding = true
}

defaultConfig {
namespace "com.algorandfoundation.bip32ed25519"
minSdkVersion 19
targetSdkVersion 33
versionCode 16
versionName "0.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}

lint {
baseline = file("lint-baseline.xml")
}

sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDirs = ['src/main/jniLibs']
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'net.java.dev.jna:jna:5.12.1'
implementation 'com.goterl:resource-loader:2.0.2'
implementation 'cash.z.ecc.android:kotlin-bip39:1.0.7'
implementation 'net.pwall.json:json-kotlin-schema:0.46'
implementation 'com.algorand:algosdk:2.4.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.1'
implementation 'com.fasterxml.jackson.core:jackson-core:2.16.1'
implementation 'org.msgpack:jackson-dataformat-msgpack:0.9.8'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.16.1'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5'
testImplementation libs.junit.jupiter.engine
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
api libs.commons.math3
implementation libs.guava
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
Empty file.
Loading

0 comments on commit 4a68388

Please sign in to comment.