From 43e1f34bb51f671bd8c0694cd8aa07d71014c426 Mon Sep 17 00:00:00 2001 From: Joey Harward Date: Tue, 21 Jul 2020 19:51:00 -0400 Subject: [PATCH 1/7] starting to move to Gradle Kotlin --- README.md | 67 ++++++++++++------- build.gradle | 58 ---------------- build.gradle.kts | 29 ++++++++ docs/build.gradle | 20 ------ docs/src/orchid/resources/config.yml | 13 ---- protonsdk/build.gradle | 32 ++++++++- protonsdk/src/orchid/resources/config.yml | 42 ++++++++++++ .../src/orchid/resources/homepage.md | 0 settings.gradle | 4 -- settings.gradle.kts | 10 +++ 10 files changed, 154 insertions(+), 121 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 docs/build.gradle delete mode 100644 docs/src/orchid/resources/config.yml create mode 100644 protonsdk/src/orchid/resources/config.yml rename {docs => protonsdk}/src/orchid/resources/homepage.md (100%) delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/README.md b/README.md index 0cbaacc4..c6d92f7e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ # Proton Kotlin Wallet SDK (Beta) 🚧 -Kotlin library for handling Proton Chain operations. The main -purpose for this library is for account and key management, but also -handles signing and pushing transactions. +![Bintray](https://img.shields.io/bintray/v/protonprotocol/ProtonKotlin/com.metallicus.protonsdk) +![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/ProtonProtocol/ProtonKotlin?include_prereleases) +![GitHub](https://img.shields.io/github/license/ProtonProtocol/ProtonKotlin) -**Important:** *This library is currently under heavy development. Please be aware that all functionality is subject to change at anytime. Documentation and examples are also being worked on and will be added over time as well.* +Kotlin library for handling Proton Chain operations. The main purpose +for this library is for account and key management, but also handles +signing and pushing transactions. + +**Important:** *This library is currently under heavy development. +Please be aware that all functionality is subject to change at anytime. +Documentation and examples are also being worked on and will be added +over time as well.* # Installation @@ -38,16 +45,19 @@ encapsulates all the needed functions. First you will need to initialize with either a MainNet or TestNet url. MainNet: + ``` https://api.protonchain.com ``` TestNet: + ``` https://api-dev.protonchain.com ``` This is recommended during app startup. + ```kotlin override fun onCreate() { super.onCreate() @@ -69,10 +79,14 @@ Once an active account has been set you can: - Update account name and avatar - Transfer tokens from active account to another account -Most of these functions require network connectivity and will return a LiveData resource. -This LiveData can be observed and will emit the current state of the action. +Most of these functions require network connectivity and will return a +LiveData resource. +This LiveData can be observed and will emit the current state of the +action. + +Here is an example of fetching Chain Provider info with the appropriate +observable states: -Here is an example of fetching Chain Provider info with the appropriate observable states: ```kotlin Proton.getInstance(context).getChainProvider().observe(this, Observer { chainProviderResource -> when (chainProviderResource?.status) { @@ -88,7 +102,9 @@ Proton.getInstance(context).getChainProvider().observe(this, Observer { chainPro } }) ``` -You can follow this format for most of the functions called within `Proton`. + +You can follow this format for most of the functions called within +`Proton`. # Credits @@ -101,21 +117,22 @@ Key Storage inspired by Copyright (c) 2020 Proton Chain LLC, Delaware -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 911c570e..00000000 --- a/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -buildscript { - ext.kotlin_version = '1.3.72' - ext.dokka_version = '0.10.1' - - repositories { - jcenter() - google() - } - - dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - } -} - -allprojects { - repositories { - jcenter() - google() - } - - // Dokka - apply plugin: 'org.jetbrains.dokka' - dokka { - outputFormat = 'html' - outputDirectory = "$buildDir/dokka" - - configuration { - perPackageOption { - prefix = "com.metallicus.protonsdk.api" - suppress = true - } - perPackageOption { - prefix = "com.metallicus.protonsdk.db" - suppress = true - } - perPackageOption { - prefix = "com.metallicus.protonsdk.di" - suppress = true - } - perPackageOption { - prefix = "com.metallicus.protonsdk.repository" - suppress = true - } - perPackageOption { - prefix = "com.metallicus.protonsdk.worker" - suppress = true - } - } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..2cd5cc36 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,29 @@ +buildscript { + repositories { + jcenter() + google() + maven("https://dl.bintray.com/kotlin/kotlin-eap") + } + + dependencies { + classpath("com.android.tools.build:gradle:4.0.1") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72") + classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.10.1") + classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5") + classpath("com.github.dcendents:android-maven-gradle-plugin:2.1") + } +} + +plugins { + id("org.jetbrains.dokka") version "0.10.1" + id("com.eden.orchidPlugin") version "0.21.0" +} + +allprojects { + repositories { + jcenter() + google() + maven("https://dl.bintray.com/kotlin/kotlin-eap") + maven("https://kotlin.bintray.com/kotlinx") + } +} \ No newline at end of file diff --git a/docs/build.gradle b/docs/build.gradle deleted file mode 100644 index 59a9ec5a..00000000 --- a/docs/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -plugins { - id "com.eden.orchidPlugin" version "0.21.0" -} - -dependencies { - orchidRuntimeOnly "io.github.javaeden.orchid:OrchidDocs:0.21.0" - orchidRuntimeOnly "io.github.javaeden.orchid:OrchidKotlindoc:0.21.0" - orchidRuntimeOnly "io.github.javaeden.orchid:OrchidPluginDocs:0.21.0" -} - -repositories { - jcenter() - maven { url = "https://kotlin.bintray.com/kotlinx/" } -} - -orchid { - theme = "Editorial" - baseUrl = "https://username.github.io/project" - version = "1.0.0" -} \ No newline at end of file diff --git a/docs/src/orchid/resources/config.yml b/docs/src/orchid/resources/config.yml deleted file mode 100644 index c8b98d70..00000000 --- a/docs/src/orchid/resources/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -site: - about: - siteName: Proton Kotlin SDK - siteDescription: Kotlin library for handling Proton Chain operations. -Editorial: - primaryColor: '#582ACB' - social: - github: 'username/project' - metaComponents: # this is the replacement for the deprecated automatic search addition - - type: 'orchidSearch' -kotlindoc: - sourceDirs: - - './../../../../protonsdk/src/main/java' \ No newline at end of file diff --git a/protonsdk/build.gradle b/protonsdk/build.gradle index 4d1898f0..670fcc6e 100644 --- a/protonsdk/build.gradle +++ b/protonsdk/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' +apply plugin: 'org.jetbrains.dokka' apply plugin: 'maven-publish' apply plugin: 'com.jfrog.bintray' apply plugin: 'com.github.dcendents.android-maven' @@ -39,7 +40,7 @@ android { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72" // Unit Testing testImplementation "junit:junit:4.13" @@ -102,6 +103,35 @@ dependencies { //implementation "com.greymass:esrsdk:1.0.1" } +//dokkaHtml { +// outputFormat = 'html' +// outputDirectory = "$buildDir/dokka" +// dokkaSourceSets { +// main { +// perPackageOption { +// prefix = "com.metallicus.protonsdk.api" +// suppress = true +// } +// perPackageOption { +// prefix = "com.metallicus.protonsdk.db" +// suppress = true +// } +// perPackageOption { +// prefix = "com.metallicus.protonsdk.di" +// suppress = true +// } +// perPackageOption { +// prefix = "com.metallicus.protonsdk.repository" +// suppress = true +// } +// perPackageOption { +// prefix = "com.metallicus.protonsdk.worker" +// suppress = true +// } +// } +// } +//} + ext { bintrayRepo = "ProtonKotlin" bintrayName = "com.metallicus.protonsdk" diff --git a/protonsdk/src/orchid/resources/config.yml b/protonsdk/src/orchid/resources/config.yml new file mode 100644 index 00000000..42ca5a65 --- /dev/null +++ b/protonsdk/src/orchid/resources/config.yml @@ -0,0 +1,42 @@ +site: + about: + siteName: Proton Kotlin SDK + siteDescription: Kotlin library for handling Proton Chain operations. + +Editorial: + primaryColor: '#582ACB' + legacySearch: false + social: + github: 'ProtonProtocol/ProtonKotlin' + metaComponents: # this is the replacement for the deprecated automatic search addition + - type: 'orchidSearch' + menu: + - type: 'separator' + title: 'API Docs' + - type: 'sourcedocPages' + moduleType: 'kotlindoc' + node: 'classes' + asSubmenu: true + submenuTitle: 'Classes' + - type: 'sourcedocPages' + moduleType: 'kotlindoc' + node: 'packages' + asSubmenu: true + submenuTitle: 'Packages' + +kotlindoc: + sourceDirs: + - './../../../../protonsdk/src/main/java' + sourcePages: + menu: + - type: 'sourcedocPageLinks' + moduleType: 'kotlindoc' + itemTitleType: 'SIGNATURE' + includeItems: true + +services: + publications: + stages: + - type: 'githubPages' + username: 'joey-harward' + repo: 'ProtonProtocol/ProtonKotlin' \ No newline at end of file diff --git a/docs/src/orchid/resources/homepage.md b/protonsdk/src/orchid/resources/homepage.md similarity index 100% rename from docs/src/orchid/resources/homepage.md rename to protonsdk/src/orchid/resources/homepage.md diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 0b0125c4..00000000 --- a/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -rootProject.name = 'Proton Kotlin SDK' - -include ':protonsdk' -include ':docs' \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..8df8c31b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,10 @@ +rootProject.name = "Proton Kotlin SDK" + +include(":protonsdk") + +pluginManagement { + repositories { + gradlePluginPortal() + maven("https://dl.bintray.com/kotlin/kotlin-eap") + } +} \ No newline at end of file From c32d72ea91d70916cc7d531c2ff969b3867cb3e5 Mon Sep 17 00:00:00 2001 From: Joey Harward Date: Wed, 22 Jul 2020 11:35:38 -0400 Subject: [PATCH 2/7] adding Kotlin Gradle specific files fixed unit tests --- build.gradle.kts | 28 +- buildSrc/build.gradle.kts | 11 + buildSrc/src/main/kotlin/Dependencies.kt | 99 ++++++ protonsdk/build.gradle | 282 ------------------ protonsdk/build.gradle.kts | 280 +++++++++++++++++ .../protonsdk/ExampleInstrumentedTest.kt | 7 +- 6 files changed, 411 insertions(+), 296 deletions(-) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/Dependencies.kt delete mode 100644 protonsdk/build.gradle create mode 100644 protonsdk/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index 2cd5cc36..fe37e90a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,29 +1,35 @@ buildscript { repositories { - jcenter() google() - maven("https://dl.bintray.com/kotlin/kotlin-eap") + jcenter() + +// maven("https://dl.bintray.com/kotlin/kotlin-eap") } dependencies { - classpath("com.android.tools.build:gradle:4.0.1") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72") - classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.10.1") - classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5") - classpath("com.github.dcendents:android-maven-gradle-plugin:2.1") + classpath(BuildPlugins.androidGradlePlugin) + classpath(BuildPlugins.kotlinGradlePlugin) + +// classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.10.1") +// classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5") +// classpath("com.github.dcendents:android-maven-gradle-plugin:2.1") } } plugins { id("org.jetbrains.dokka") version "0.10.1" - id("com.eden.orchidPlugin") version "0.21.0" +// id("com.eden.orchidPlugin") version "0.21.0" } allprojects { repositories { - jcenter() google() - maven("https://dl.bintray.com/kotlin/kotlin-eap") - maven("https://kotlin.bintray.com/kotlinx") + jcenter() +// maven("https://dl.bintray.com/kotlin/kotlin-eap") +// maven("https://kotlin.bintray.com/kotlinx") } +} + +tasks.register("clean").configure { + delete("build") } \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..5aa40ec4 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + `kotlin-dsl` +} + +repositories { + jcenter() +} + +kotlinDslPluginOptions { + experimentalWarning.set(false) +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt new file mode 100644 index 00000000..3acb40aa --- /dev/null +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2020 Proton Chain LLC, Delaware + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +const val kotlinVersion = "1.3.72" + +object BuildPlugins { + object Versions { + const val gradlePlugin = "4.0.1" + } + + const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.gradlePlugin}" + const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" + const val androidLibrary = "com.android.library" + const val kotlinAndroid = "android" + const val kotlinAndroidExtensions = "android.extensions" + const val kotlinKapt = "kapt" + const val mavenPublish = "maven-publish" + const val dokka = "org.jetbrains.dokka" +} + +object AndroidSdk { + const val min = 21 + const val compile = 30 + const val target = compile + + const val versionCode = 13 + const val versionName = "0.5.1" +} + +object Libraries { + private object Versions { + const val ktx = "1.5.0-alpha01" + const val lifecycleLiveData = "2.3.0-alpha05" + const val room = "2.2.5" + const val workManager = "2.3.4" + const val okhttp3 = "4.8.0" + const val retrofit = "2.9.0" + const val dagger = "2.28.1" + const val daggerAssistedInject = "0.5.2" + const val coroutines = "1.3.4" + const val timber = "4.7.1" + const val gson = "2.8.6" + const val guava = "29.0-jre" + } + + const val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" + const val ktxCore = "androidx.core:core-ktx:${Versions.ktx}" + const val lifeCycleLiveData = "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.lifecycleLiveData}" + const val roomKtx = "androidx.room:room-ktx:${Versions.room}" + const val roomCompiler = "androidx.room:room-compiler:${Versions.room}" + const val workManagerKtx = "androidx.work:work-runtime-ktx:${Versions.workManager}" + const val okhttp3 = "com.squareup.okhttp3:okhttp:${Versions.okhttp3}" + const val okhttp3Logging = "com.squareup.okhttp3:logging-interceptor:${Versions.okhttp3}" + const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofit}" + const val retrofitGsonConverter = "com.squareup.retrofit2:converter-gson:${Versions.retrofit}" + const val dagger = "com.google.dagger:dagger:${Versions.dagger}" + const val daggerAndroidSupport = "com.google.dagger:dagger-android-support:${Versions.dagger}" + const val daggerAndroidProcessor = "com.google.dagger:dagger-android-processor:${Versions.dagger}" + const val daggerAndroidCompiler = "com.google.dagger:dagger-compiler:${Versions.dagger}" + const val daggerAssistedInjectAnnotations = "com.squareup.inject:assisted-inject-annotations-dagger2:${Versions.daggerAssistedInject}" + const val daggerAssistedInjectProcessor = "com.squareup.inject:assisted-inject-processor-dagger2:${Versions.daggerAssistedInject}" + const val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}" + const val coroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}" + const val timber = "com.jakewharton.timber:timber:${Versions.timber}" + const val gson = "com.google.code.gson:gson:${Versions.gson}" + const val guava = "com.google.guava:guava:${Versions.guava}" + + // Greymass ESR + //implementation "com.greymass:esrsdk:1.0.1" +} + +object TestLibraries { + private object Versions { + const val junit = "4.13" + const val testExt = "1.1.1" + const val espresso = "3.2.0" + } + const val junit = "junit:junit:${Versions.junit}" + const val testExt = "androidx.test.ext:junit:${Versions.testExt}" + const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}" +} \ No newline at end of file diff --git a/protonsdk/build.gradle b/protonsdk/build.gradle deleted file mode 100644 index 670fcc6e..00000000 --- a/protonsdk/build.gradle +++ /dev/null @@ -1,282 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'kotlin-kapt' -apply plugin: 'org.jetbrains.dokka' -apply plugin: 'maven-publish' -apply plugin: 'com.jfrog.bintray' -apply plugin: 'com.github.dcendents.android-maven' - -android { - compileSdkVersion 30 - buildToolsVersion "30.0.1" - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() - } - - defaultConfig { - minSdkVersion 21 - targetSdkVersion 30 - - versionCode 13 - versionName "0.5.1" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles 'consumer-rules.pro' - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72" - - // Unit Testing - testImplementation "junit:junit:4.13" - androidTestImplementation "androidx.test.ext:junit:1.1.1" - androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0" - - // KTX - implementation "androidx.core:core-ktx:1.5.0-alpha01" - - // Lifecycle - implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-alpha05" - - // Room - def room_version = '2.2.5' - implementation "androidx.room:room-ktx:$room_version" - kapt "androidx.room:room-compiler:$room_version" - - // WorkManager - implementation "androidx.work:work-runtime-ktx:2.3.4" - - // OkHttp - def okhttp3_version = '4.8.0' - implementation "com.squareup.okhttp3:okhttp:$okhttp3_version" - implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3_version" - - // Retrofit - def retrofit_version = '2.9.0' - implementation("com.squareup.retrofit2:retrofit:$retrofit_version") { - exclude module: 'okhttp' - } - implementation "com.squareup.retrofit2:converter-gson:$retrofit_version" - - // Dagger - def dagger_version = '2.28.1' - implementation "com.google.dagger:dagger:$dagger_version" - implementation "com.google.dagger:dagger-android-support:$dagger_version" - kapt "com.google.dagger:dagger-android-processor:$dagger_version" - kapt "com.google.dagger:dagger-compiler:$dagger_version" - - // Assisted Inject (Dagger) - def assisted_inject_version = '0.5.2' - compileOnly "com.squareup.inject:assisted-inject-annotations-dagger2:$assisted_inject_version" - kapt "com.squareup.inject:assisted-inject-processor-dagger2:$assisted_inject_version" - - // Coroutines - def coroutines_version = '1.3.4' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" - - // Timber - implementation "com.jakewharton.timber:timber:4.7.1" - - // Gson - implementation "com.google.code.gson:gson:2.8.6" - - // Guava - implementation "com.google.guava:guava:29.0-jre" - - // Greymass ESR - //implementation "com.greymass:esrsdk:1.0.1" -} - -//dokkaHtml { -// outputFormat = 'html' -// outputDirectory = "$buildDir/dokka" -// dokkaSourceSets { -// main { -// perPackageOption { -// prefix = "com.metallicus.protonsdk.api" -// suppress = true -// } -// perPackageOption { -// prefix = "com.metallicus.protonsdk.db" -// suppress = true -// } -// perPackageOption { -// prefix = "com.metallicus.protonsdk.di" -// suppress = true -// } -// perPackageOption { -// prefix = "com.metallicus.protonsdk.repository" -// suppress = true -// } -// perPackageOption { -// prefix = "com.metallicus.protonsdk.worker" -// suppress = true -// } -// } -// } -//} - -ext { - bintrayRepo = "ProtonKotlin" - bintrayName = "com.metallicus.protonsdk" - userOrganization = "protonprotocol" - - libraryName = "protonsdk" - - publishedGroupId = "com.metallicus" - artifact = "protonsdk" - libraryVersion = android.defaultConfig.versionName - - libraryDescription = "Kotlin library for handling Proton Chain operations" - siteUrl = "https://github.com/ProtonProtocol/ProtonKotlin" - gitUrl = "https://github.com/ProtonProtocol/ProtonKotlin.git" - developerId = "joey-harward" - developerName = "Metallicus Inc." - developerEmail = "joey@metalpay.co" - licenseName = "MIT License" - licenseUrl = "https://opensource.org/licenses/MIT" - allLicenses = ["MIT"] -} - -group = publishedGroupId -version = libraryVersion - -task sourcesJar(type: Jar) { - archiveClassifier.set('sources') - from android.sourceSets.main.java.srcDirs -} - -def pomConfig = { - licenses { - license { - name licenseName - url licenseUrl - } - } - developers { - developer { - id developerId - name developerName - email developerEmail - } - } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl - } -} - -project.afterEvaluate { - publishing { - publications { - ProtonSDKDebug(MavenPublication) { - groupId = 'com.metallicus' - artifactId = "${project.getName()}-debug" - version = android.defaultConfig.versionName - - artifact bundleDebugAar - - pom.withXml { - def root = asNode() - root.appendNode('name', libraryName) - root.appendNode('description', libraryDescription) - root.appendNode('url', siteUrl) - root.children().last() + pomConfig - - def dependenciesNode = root.appendNode('dependencies') - configurations.implementation.allDependencies.each { - if (it.group != null && it.name != null && it.version != null && - it.name != 'unspecified' && it.version != 'unspecified') { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', it.group) - dependencyNode.appendNode('artifactId', it.name) - dependencyNode.appendNode('version', it.version) - } - } - } - } - - ProtonSDKRelease(MavenPublication) { - groupId = 'com.metallicus' - artifactId project.getName() - version = android.defaultConfig.versionName - - artifact bundleReleaseAar - artifact sourcesJar - - pom.withXml { - def root = asNode() - root.appendNode('name', libraryName) - root.appendNode('description', libraryDescription) - root.appendNode('url', siteUrl) - root.children().last() + pomConfig - - def dependenciesNode = root.appendNode('dependencies') - configurations.implementation.allDependencies.each { - if (it.group != null && it.name != null && it.version != null && - it.name != 'unspecified' && it.version != 'unspecified') { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', it.group) - dependencyNode.appendNode('artifactId', it.name) - dependencyNode.appendNode('version', it.version) - } - } - } - } - } - } -} - -project.afterEvaluate { - bintray { - if (project.rootProject.file('local.properties').exists()) { - Properties properties = new Properties() - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - - user = properties.getProperty("bintray.user") - key = properties.getProperty("bintray.apikey") - - publications = ['ProtonSDKRelease'] - - pkg { - repo = bintrayRepo - name = bintrayName - userOrg = userOrganization - desc = libraryDescription - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = allLicenses - publish = true - publicDownloadNumbers = true - version { - name = libraryVersion - desc = libraryDescription - released = new Date() - -// gpg { -// sign = true //Determines whether to GPG sign the files. The default is false -// passphrase = properties.getProperty("bintray.gpg.password") -// //Optional. The passphrase for GPG signing' -// } - } - } - } - } -} diff --git a/protonsdk/build.gradle.kts b/protonsdk/build.gradle.kts new file mode 100644 index 00000000..fc0e2523 --- /dev/null +++ b/protonsdk/build.gradle.kts @@ -0,0 +1,280 @@ +import org.jetbrains.dokka.gradle.DokkaTask + +plugins { + id(BuildPlugins.androidLibrary) + kotlin(BuildPlugins.kotlinAndroid) + kotlin(BuildPlugins.kotlinAndroidExtensions) + kotlin(BuildPlugins.kotlinKapt) + id(BuildPlugins.mavenPublish) + id(BuildPlugins.dokka) + + //apply plugin: 'com.jfrog.bintray' + //apply plugin: 'com.github.dcendents.android-maven' +} + +android { + compileSdkVersion(AndroidSdk.compile) + buildToolsVersion("30.0.1") + + defaultConfig { + //applicationId = "com.gradle.kotlindsl" + minSdkVersion(AndroidSdk.min) + targetSdkVersion(AndroidSdk.target) + versionCode = AndroidSdk.versionCode + versionName = AndroidSdk.versionName + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } +} + +dependencies { + implementation(Libraries.kotlinStdLib) + + // Unit Testing + testImplementation(TestLibraries.junit) + androidTestImplementation(TestLibraries.testExt) + androidTestImplementation(TestLibraries.espresso) + + // KTX + implementation(Libraries.ktxCore) + + // Lifecycle + implementation(Libraries.lifeCycleLiveData) + + // Room + implementation(Libraries.roomKtx) + kapt(Libraries.roomCompiler) + + // WorkManager + implementation(Libraries.workManagerKtx) + + // OkHttp + implementation(Libraries.okhttp3) + implementation(Libraries.okhttp3Logging) + + // Retrofit + implementation(Libraries.retrofit) + implementation(Libraries.retrofitGsonConverter) + + // Dagger + implementation(Libraries.dagger) + implementation(Libraries.daggerAndroidSupport) + kapt(Libraries.daggerAndroidProcessor) + kapt(Libraries.daggerAndroidCompiler) + + // Assisted Inject (Dagger) + compileOnly(Libraries.daggerAssistedInjectAnnotations) + kapt(Libraries.daggerAssistedInjectProcessor) + + // Coroutines + implementation(Libraries.coroutinesCore) + implementation(Libraries.coroutinesAndroid) + + // Timber + implementation(Libraries.timber) + + // Gson + implementation(Libraries.gson) + + // Guava + implementation(Libraries.guava) + + // Greymass ESR + //implementation "com.greymass:esrsdk:1.0.1" +} + +// Dokka +tasks { + val dokka by getting(DokkaTask::class) { + outputFormat = "html" + outputDirectory = "$buildDir/dokka" + + configuration { + perPackageOption { + prefix = "com.metallicus.protonsdk.api" + suppress = true + } + perPackageOption { + prefix = "com.metallicus.protonsdk.db" + suppress = true + } + perPackageOption { + prefix = "com.metallicus.protonsdk.di" + suppress = true + } + perPackageOption { + prefix = "com.metallicus.protonsdk.repository" + suppress = true + } + perPackageOption { + prefix = "com.metallicus.protonsdk.worker" + suppress = true + } + } + } +} + +//ext { +// bintrayRepo = "ProtonKotlin" +// bintrayName = "com.metallicus.protonsdk" +// userOrganization = "protonprotocol" +// +// libraryName = "protonsdk" +// +// publishedGroupId = "com.metallicus" +// artifact = "protonsdk" +// libraryVersion = android.defaultConfig.versionName +// +// libraryDescription = "Kotlin library for handling Proton Chain operations" +// siteUrl = "https://github.com/ProtonProtocol/ProtonKotlin" +// gitUrl = "https://github.com/ProtonProtocol/ProtonKotlin.git" +// developerId = "joey-harward" +// developerName = "Metallicus Inc." +// developerEmail = "joey@metalpay.co" +// licenseName = "MIT License" +// licenseUrl = "https://opensource.org/licenses/MIT" +// allLicenses = ["MIT"] +//} +// +//group = publishedGroupId +//version = libraryVersion +// +//task sourcesJar(type: Jar) { +// archiveClassifier.set('sources') +// from android.sourceSets.main.java.srcDirs +//} +// +//def pomConfig = { +// licenses { +// license { +// name licenseName +// url licenseUrl +// } +// } +// developers { +// developer { +// id developerId +// name developerName +// email developerEmail +// } +// } +// scm { +// connection gitUrl +// developerConnection gitUrl +// url siteUrl +// } +//} +// +//project.afterEvaluate { +// publishing { +// publications { +// ProtonSDKDebug(MavenPublication) { +// groupId = 'com.metallicus' +// artifactId = "${project.getName()}-debug" +// version = android.defaultConfig.versionName +// +// artifact bundleDebugAar +// +// pom.withXml { +// def root = asNode() +// root.appendNode('name', libraryName) +// root.appendNode('description', libraryDescription) +// root.appendNode('url', siteUrl) +// root.children().last() + pomConfig +// +// def dependenciesNode = root.appendNode('dependencies') +// configurations.implementation.allDependencies.each { +// if (it.group != null && it.name != null && it.version != null && +// it.name != 'unspecified' && it.version != 'unspecified') { +// def dependencyNode = dependenciesNode.appendNode('dependency') +// dependencyNode.appendNode('groupId', it.group) +// dependencyNode.appendNode('artifactId', it.name) +// dependencyNode.appendNode('version', it.version) +// } +// } +// } +// } +// +// ProtonSDKRelease(MavenPublication) { +// groupId = 'com.metallicus' +// artifactId project.getName() +// version = android.defaultConfig.versionName +// +// artifact bundleReleaseAar +// artifact sourcesJar +// +// pom.withXml { +// def root = asNode() +// root.appendNode('name', libraryName) +// root.appendNode('description', libraryDescription) +// root.appendNode('url', siteUrl) +// root.children().last() + pomConfig +// +// def dependenciesNode = root.appendNode('dependencies') +// configurations.implementation.allDependencies.each { +// if (it.group != null && it.name != null && it.version != null && +// it.name != 'unspecified' && it.version != 'unspecified') { +// def dependencyNode = dependenciesNode.appendNode('dependency') +// dependencyNode.appendNode('groupId', it.group) +// dependencyNode.appendNode('artifactId', it.name) +// dependencyNode.appendNode('version', it.version) +// } +// } +// } +// } +// } +// } +//} +// +//project.afterEvaluate { +// bintray { +// if (project.rootProject.file('local.properties').exists()) { +// Properties properties = new Properties() +// properties.load(project.rootProject.file('local.properties').newDataInputStream()) +// +// user = properties.getProperty("bintray.user") +// key = properties.getProperty("bintray.apikey") +// +// publications = ['ProtonSDKRelease'] +// +// pkg { +// repo = bintrayRepo +// name = bintrayName +// userOrg = userOrganization +// desc = libraryDescription +// websiteUrl = siteUrl +// vcsUrl = gitUrl +// licenses = allLicenses +// publish = true +// publicDownloadNumbers = true +// version { +// name = libraryVersion +// desc = libraryDescription +// released = new Date() +// +//// gpg { +//// sign = true //Determines whether to GPG sign the files. The default is false +//// passphrase = properties.getProperty("bintray.gpg.password") +//// //Optional. The passphrase for GPG signing' +//// } +// } +// } +// } +// } +//} diff --git a/protonsdk/src/androidTest/java/com/metallicus/protonsdk/ExampleInstrumentedTest.kt b/protonsdk/src/androidTest/java/com/metallicus/protonsdk/ExampleInstrumentedTest.kt index 5a740205..650df991 100644 --- a/protonsdk/src/androidTest/java/com/metallicus/protonsdk/ExampleInstrumentedTest.kt +++ b/protonsdk/src/androidTest/java/com/metallicus/protonsdk/ExampleInstrumentedTest.kt @@ -2,7 +2,8 @@ package com.metallicus.protonsdk import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry -import org.junit.Assert.assertEquals +import org.hamcrest.CoreMatchers.containsString +import org.junit.Assert.assertThat import org.junit.Test import org.junit.runner.RunWith @@ -14,9 +15,9 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { @Test - fun useAppContext() { + fun checkPackage() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.proton.protonchain.test", appContext.packageName) + assertThat(appContext.packageName, containsString("com.metallicus.protonsdk")) } } From a2db8d57f1503a630e8e69f43b3a577aa2041566 Mon Sep 17 00:00:00 2001 From: Joey Harward Date: Fri, 24 Jul 2020 10:02:00 -0400 Subject: [PATCH 3/7] converted orchid, publishing, and bintray to Kotlin DSL --- build.gradle.kts | 27 +- buildSrc/settings.gradle.kts | 1 + buildSrc/src/main/kotlin/Dependencies.kt | 106 +++++--- protonsdk/build.gradle.kts | 316 +++++++++++------------ settings.gradle.kts | 2 +- 5 files changed, 244 insertions(+), 208 deletions(-) create mode 100644 buildSrc/settings.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index fe37e90a..3d384904 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,34 +2,35 @@ buildscript { repositories { google() jcenter() - -// maven("https://dl.bintray.com/kotlin/kotlin-eap") } dependencies { classpath(BuildPlugins.androidGradlePlugin) - classpath(BuildPlugins.kotlinGradlePlugin) - -// classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.10.1") -// classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5") -// classpath("com.github.dcendents:android-maven-gradle-plugin:2.1") } } plugins { - id("org.jetbrains.dokka") version "0.10.1" -// id("com.eden.orchidPlugin") version "0.21.0" + kotlin("jvm") version kotlinVersion + id(BuildPlugins.dokka) version BuildPlugins.Versions.dokka + id(BuildPlugins.orchid) version orchidVersion + `maven-publish` + id(BuildPlugins.bintray) version BuildPlugins.Versions.bintray } allprojects { repositories { google() jcenter() -// maven("https://dl.bintray.com/kotlin/kotlin-eap") -// maven("https://kotlin.bintray.com/kotlinx") } } -tasks.register("clean").configure { - delete("build") +dependencies { + orchidRuntimeOnly(Libraries.orchid) +} + +orchid { + theme = "Editorial" + version = ProtonSdk.versionName + srcDir = "protonsdk/src/orchid/resources" + destDir = "protonsdk/build/docs/orchid" } \ No newline at end of file diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 00000000..ab05cfea --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "ProtonKotlinSDK DSL" \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 3acb40aa..2eef1d96 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -20,29 +20,42 @@ * SOFTWARE. */ const val kotlinVersion = "1.3.72" +const val orchidVersion = "0.21.1" + +object ProtonSdk { + const val versionCode = 14 + const val versionName = "0.5.2" +} object BuildPlugins { object Versions { - const val gradlePlugin = "4.0.1" + const val gradle = "4.0.1" + const val dokka = "0.10.1" + const val bintray = "1.8.5" } - const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.gradlePlugin}" - const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" + const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.gradle}" const val androidLibrary = "com.android.library" const val kotlinAndroid = "android" const val kotlinAndroidExtensions = "android.extensions" const val kotlinKapt = "kapt" const val mavenPublish = "maven-publish" const val dokka = "org.jetbrains.dokka" + const val orchid = "com.eden.orchidPlugin" + const val bintray = "com.jfrog.bintray" } -object AndroidSdk { - const val min = 21 - const val compile = 30 - const val target = compile +object Android { + const val minSdk = 21 + const val compileSdk = 30 + const val targetSdk = compileSdk + const val buildTools = "30.0.1" - const val versionCode = 13 - const val versionName = "0.5.1" + object Progaurd { + const val consumeFile = "consumer-rules.pro" + const val optimizeFile = "proguard-android-optimize.txt" + const val rulesFile = "proguard-rules.pro" + } } object Libraries { @@ -61,27 +74,28 @@ object Libraries { const val guava = "29.0-jre" } - const val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" - const val ktxCore = "androidx.core:core-ktx:${Versions.ktx}" - const val lifeCycleLiveData = "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.lifecycleLiveData}" - const val roomKtx = "androidx.room:room-ktx:${Versions.room}" - const val roomCompiler = "androidx.room:room-compiler:${Versions.room}" - const val workManagerKtx = "androidx.work:work-runtime-ktx:${Versions.workManager}" - const val okhttp3 = "com.squareup.okhttp3:okhttp:${Versions.okhttp3}" - const val okhttp3Logging = "com.squareup.okhttp3:logging-interceptor:${Versions.okhttp3}" - const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofit}" - const val retrofitGsonConverter = "com.squareup.retrofit2:converter-gson:${Versions.retrofit}" - const val dagger = "com.google.dagger:dagger:${Versions.dagger}" - const val daggerAndroidSupport = "com.google.dagger:dagger-android-support:${Versions.dagger}" - const val daggerAndroidProcessor = "com.google.dagger:dagger-android-processor:${Versions.dagger}" - const val daggerAndroidCompiler = "com.google.dagger:dagger-compiler:${Versions.dagger}" - const val daggerAssistedInjectAnnotations = "com.squareup.inject:assisted-inject-annotations-dagger2:${Versions.daggerAssistedInject}" - const val daggerAssistedInjectProcessor = "com.squareup.inject:assisted-inject-processor-dagger2:${Versions.daggerAssistedInject}" - const val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}" - const val coroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}" - const val timber = "com.jakewharton.timber:timber:${Versions.timber}" - const val gson = "com.google.code.gson:gson:${Versions.gson}" - const val guava = "com.google.guava:guava:${Versions.guava}" + const val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" + const val ktxCore = "androidx.core:core-ktx:${Versions.ktx}" + const val lifeCycleLiveData = "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.lifecycleLiveData}" + const val roomKtx = "androidx.room:room-ktx:${Versions.room}" + const val roomCompiler = "androidx.room:room-compiler:${Versions.room}" + const val workManagerKtx = "androidx.work:work-runtime-ktx:${Versions.workManager}" + const val okhttp3 = "com.squareup.okhttp3:okhttp:${Versions.okhttp3}" + const val okhttp3Logging = "com.squareup.okhttp3:logging-interceptor:${Versions.okhttp3}" + const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofit}" + const val retrofitGsonConverter = "com.squareup.retrofit2:converter-gson:${Versions.retrofit}" + const val dagger = "com.google.dagger:dagger:${Versions.dagger}" + const val daggerAndroidSupport = "com.google.dagger:dagger-android-support:${Versions.dagger}" + const val daggerAndroidProcessor = "com.google.dagger:dagger-android-processor:${Versions.dagger}" + const val daggerAndroidCompiler = "com.google.dagger:dagger-compiler:${Versions.dagger}" + const val daggerAssistedInjectAnnotations = "com.squareup.inject:assisted-inject-annotations-dagger2:${Versions.daggerAssistedInject}" + const val daggerAssistedInjectProcessor = "com.squareup.inject:assisted-inject-processor-dagger2:${Versions.daggerAssistedInject}" + const val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}" + const val coroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}" + const val timber = "com.jakewharton.timber:timber:${Versions.timber}" + const val gson = "com.google.code.gson:gson:${Versions.gson}" + const val guava = "com.google.guava:guava:${Versions.guava}" + const val orchid = "io.github.javaeden.orchid:OrchidAll:$orchidVersion" // Greymass ESR //implementation "com.greymass:esrsdk:1.0.1" @@ -93,7 +107,33 @@ object TestLibraries { const val testExt = "1.1.1" const val espresso = "3.2.0" } - const val junit = "junit:junit:${Versions.junit}" - const val testExt = "androidx.test.ext:junit:${Versions.testExt}" - const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}" + const val junit = "junit:junit:${Versions.junit}" + const val testExt = "androidx.test.ext:junit:${Versions.testExt}" + const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}" + const val testRunner = "androidx.test.runner.AndroidJUnitRunner" +} + +object Publishing { + object Publications { + const val debug = "ProtonSDKDebug" + const val release = "ProtonSDKRelease" + } + const val bintrayRepo = "ProtonKotlin" + const val bintrayName = "com.metallicus.protonsdk" + const val userOrganization = "protonprotocol" + + const val libraryName = "protonsdk" + const val libraryVersion = ProtonSdk.versionName + + const val publishedGroupId = "com.metallicus" + + const val libraryDescription = "Kotlin library for handling Proton Chain operations" + const val siteUrl = "https://github.com/ProtonProtocol/ProtonKotlin" + const val gitUrl = "https://github.com/ProtonProtocol/ProtonKotlin.git" + const val developerId = "joey-harward" + const val developerName = "Metallicus Inc." + const val developerEmail = "joey@metalpay.co" + const val licenseName = "MIT License" + const val licenseUrl = "https://opensource.org/licenses/MIT" + const val allLicenses = "MIT" } \ No newline at end of file diff --git a/protonsdk/build.gradle.kts b/protonsdk/build.gradle.kts index fc0e2523..9cfd573d 100644 --- a/protonsdk/build.gradle.kts +++ b/protonsdk/build.gradle.kts @@ -1,3 +1,4 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties import org.jetbrains.dokka.gradle.DokkaTask plugins { @@ -7,23 +8,21 @@ plugins { kotlin(BuildPlugins.kotlinKapt) id(BuildPlugins.mavenPublish) id(BuildPlugins.dokka) - - //apply plugin: 'com.jfrog.bintray' - //apply plugin: 'com.github.dcendents.android-maven' + id(BuildPlugins.bintray) } android { - compileSdkVersion(AndroidSdk.compile) - buildToolsVersion("30.0.1") + compileSdkVersion(Android.compileSdk) + buildToolsVersion(Android.buildTools) defaultConfig { - //applicationId = "com.gradle.kotlindsl" - minSdkVersion(AndroidSdk.min) - targetSdkVersion(AndroidSdk.target) - versionCode = AndroidSdk.versionCode - versionName = AndroidSdk.versionName - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles("consumer-rules.pro") + //applicationId = "com.metallicus.protonsdk" + minSdkVersion(Android.minSdk) + targetSdkVersion(Android.targetSdk) + versionCode = ProtonSdk.versionCode + versionName = ProtonSdk.versionName + testInstrumentationRunner = TestLibraries.testRunner + consumerProguardFiles(Android.Progaurd.consumeFile) } compileOptions { @@ -38,7 +37,7 @@ android { buildTypes { getByName("release") { isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + proguardFiles(getDefaultProguardFile(Android.Progaurd.optimizeFile), Android.Progaurd.rulesFile) } } } @@ -130,151 +129,146 @@ tasks { } } -//ext { -// bintrayRepo = "ProtonKotlin" -// bintrayName = "com.metallicus.protonsdk" -// userOrganization = "protonprotocol" -// -// libraryName = "protonsdk" -// -// publishedGroupId = "com.metallicus" -// artifact = "protonsdk" -// libraryVersion = android.defaultConfig.versionName -// -// libraryDescription = "Kotlin library for handling Proton Chain operations" -// siteUrl = "https://github.com/ProtonProtocol/ProtonKotlin" -// gitUrl = "https://github.com/ProtonProtocol/ProtonKotlin.git" -// developerId = "joey-harward" -// developerName = "Metallicus Inc." -// developerEmail = "joey@metalpay.co" -// licenseName = "MIT License" -// licenseUrl = "https://opensource.org/licenses/MIT" -// allLicenses = ["MIT"] -//} -// -//group = publishedGroupId -//version = libraryVersion -// -//task sourcesJar(type: Jar) { -// archiveClassifier.set('sources') -// from android.sourceSets.main.java.srcDirs -//} -// -//def pomConfig = { -// licenses { -// license { -// name licenseName -// url licenseUrl -// } -// } -// developers { -// developer { -// id developerId -// name developerName -// email developerEmail -// } -// } -// scm { -// connection gitUrl -// developerConnection gitUrl -// url siteUrl -// } -//} -// -//project.afterEvaluate { -// publishing { -// publications { -// ProtonSDKDebug(MavenPublication) { -// groupId = 'com.metallicus' -// artifactId = "${project.getName()}-debug" -// version = android.defaultConfig.versionName -// -// artifact bundleDebugAar -// -// pom.withXml { -// def root = asNode() -// root.appendNode('name', libraryName) -// root.appendNode('description', libraryDescription) -// root.appendNode('url', siteUrl) -// root.children().last() + pomConfig -// -// def dependenciesNode = root.appendNode('dependencies') -// configurations.implementation.allDependencies.each { -// if (it.group != null && it.name != null && it.version != null && -// it.name != 'unspecified' && it.version != 'unspecified') { -// def dependencyNode = dependenciesNode.appendNode('dependency') -// dependencyNode.appendNode('groupId', it.group) -// dependencyNode.appendNode('artifactId', it.name) -// dependencyNode.appendNode('version', it.version) -// } -// } -// } -// } -// -// ProtonSDKRelease(MavenPublication) { -// groupId = 'com.metallicus' -// artifactId project.getName() -// version = android.defaultConfig.versionName -// -// artifact bundleReleaseAar -// artifact sourcesJar -// -// pom.withXml { -// def root = asNode() -// root.appendNode('name', libraryName) -// root.appendNode('description', libraryDescription) -// root.appendNode('url', siteUrl) -// root.children().last() + pomConfig -// -// def dependenciesNode = root.appendNode('dependencies') -// configurations.implementation.allDependencies.each { -// if (it.group != null && it.name != null && it.version != null && -// it.name != 'unspecified' && it.version != 'unspecified') { -// def dependencyNode = dependenciesNode.appendNode('dependency') -// dependencyNode.appendNode('groupId', it.group) -// dependencyNode.appendNode('artifactId', it.name) -// dependencyNode.appendNode('version', it.version) -// } -// } -// } -// } -// } -// } -//} -// -//project.afterEvaluate { -// bintray { -// if (project.rootProject.file('local.properties').exists()) { -// Properties properties = new Properties() -// properties.load(project.rootProject.file('local.properties').newDataInputStream()) -// -// user = properties.getProperty("bintray.user") -// key = properties.getProperty("bintray.apikey") -// -// publications = ['ProtonSDKRelease'] -// -// pkg { -// repo = bintrayRepo -// name = bintrayName -// userOrg = userOrganization -// desc = libraryDescription -// websiteUrl = siteUrl -// vcsUrl = gitUrl -// licenses = allLicenses -// publish = true -// publicDownloadNumbers = true -// version { -// name = libraryVersion -// desc = libraryDescription -// released = new Date() -// -//// gpg { -//// sign = true //Determines whether to GPG sign the files. The default is false -//// passphrase = properties.getProperty("bintray.gpg.password") -//// //Optional. The passphrase for GPG signing' -//// } -// } -// } -// } -// } -//} +group = Publishing.publishedGroupId +version = Publishing.libraryVersion + +val sourcesJar by tasks.creating(Jar::class) { + archiveClassifier.set("sources") + from(android.sourceSets["main"].java.srcDirs) +} + +afterEvaluate { + publishing { + publications { + create(Publishing.Publications.debug) { + groupId = "com.metallicus" + artifactId = "${Publishing.libraryName}-debug" + version = Publishing.libraryVersion + + //artifact(buildOutputs["debug"].outputFile) + artifact("$buildDir/outputs/aar/protonsdk-debug.aar") + artifact(sourcesJar) + + pom { + name.set(Publishing.libraryName) + description.set(Publishing.libraryDescription) + url.set(Publishing.siteUrl) + + licenses { + license { + name.set(Publishing.licenseName) + url.set(Publishing.licenseUrl) + } + } + + developers { + developer { + id.set(Publishing.developerId) + name.set(Publishing.developerName) + email.set(Publishing.developerEmail) + } + } + + scm { + connection.set(Publishing.gitUrl) + developerConnection.set(Publishing.gitUrl) + url.set(Publishing.siteUrl) + } + + pom.withXml { + val dependenciesNode = asNode().appendNode("dependencies") + configurations.implementation.get().allDependencies.forEach { + if (it.group != null && it.version != null && + it.name != "unspecified" && it.version != "unspecified") { + dependenciesNode.appendNode("dependency").apply { + appendNode("groupId", it.group) + appendNode("artifactId", it.name) + appendNode("version", it.version) + } + } + } + } + } + } + + create(Publishing.Publications.release) { + groupId = "com.metallicus" + artifactId = Publishing.libraryName + version = Publishing.libraryVersion + + //artifact(buildOutputs["release"].outputFile) + artifact("$buildDir/outputs/aar/protonsdk-release.aar") + artifact(sourcesJar) + + pom { + name.set(Publishing.libraryName) + description.set(Publishing.libraryDescription) + url.set(Publishing.siteUrl) + + licenses { + license { + name.set(Publishing.licenseName) + url.set(Publishing.licenseUrl) + } + } + + developers { + developer { + id.set(Publishing.developerId) + name.set(Publishing.developerName) + email.set(Publishing.developerEmail) + } + } + + scm { + connection.set(Publishing.gitUrl) + developerConnection.set(Publishing.gitUrl) + url.set(Publishing.siteUrl) + } + + pom.withXml { + val dependenciesNode = asNode().appendNode("dependencies") + configurations.implementation.get().allDependencies.forEach { + if (it.group != null && it.version != null && + it.name != "unspecified" && it.version != "unspecified" + ) { + dependenciesNode.appendNode("dependency").apply { + appendNode("groupId", it.group) + appendNode("artifactId", it.name) + appendNode("version", it.version) + } + } + } + } + } + } + } + } + + bintray { + user = gradleLocalProperties(rootDir).getProperty("bintray.user") + key = gradleLocalProperties(rootDir).getProperty("bintray.apikey") + publish = true + + setPublications(Publishing.Publications.release) + + pkg.apply { + repo = Publishing.bintrayRepo + name = Publishing.bintrayName + userOrg = Publishing.userOrganization + desc = Publishing.libraryDescription + websiteUrl = Publishing.siteUrl + vcsUrl = Publishing.gitUrl + setLicenses(Publishing.allLicenses) + publish = true + publicDownloadNumbers = true + + version.apply { + name = Publishing.libraryVersion + desc = Publishing.libraryDescription +// gpg.sign = true +// gpg.passphrase = gradleLocalProperties(rootDir).getProperty("bintray.gpg.password") + } + } + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 8df8c31b..6dc07d83 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,4 @@ -rootProject.name = "Proton Kotlin SDK" +rootProject.name = "ProtonKotlinSDK" include(":protonsdk") From 56aa7c6c691d40f8150bd6e6cddfbf6c5cbe9758 Mon Sep 17 00:00:00 2001 From: Joey Harward Date: Fri, 24 Jul 2020 10:50:18 -0400 Subject: [PATCH 4/7] condensing orchid output --- build.gradle.kts | 5 ++++- buildSrc/settings.gradle.kts | 2 +- buildSrc/src/main/kotlin/Dependencies.kt | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3d384904..bf3e49b9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,7 +25,9 @@ allprojects { } dependencies { - orchidRuntimeOnly(Libraries.orchid) + orchidRuntimeOnly(Libraries.orchidDocs) + orchidRuntimeOnly(Libraries.orchidKotlindoc) + orchidRuntimeOnly(Libraries.orchidPluginDocs) } orchid { @@ -33,4 +35,5 @@ orchid { version = ProtonSdk.versionName srcDir = "protonsdk/src/orchid/resources" destDir = "protonsdk/build/docs/orchid" + baseUrl = "https://protonprotocol.github.io/ProtonKotlin" } \ No newline at end of file diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index ab05cfea..b943098e 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -1 +1 @@ -rootProject.name = "ProtonKotlinSDK DSL" \ No newline at end of file +rootProject.name = "DSL" \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 2eef1d96..8ccf45f7 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -95,7 +95,9 @@ object Libraries { const val timber = "com.jakewharton.timber:timber:${Versions.timber}" const val gson = "com.google.code.gson:gson:${Versions.gson}" const val guava = "com.google.guava:guava:${Versions.guava}" - const val orchid = "io.github.javaeden.orchid:OrchidAll:$orchidVersion" + const val orchidDocs = "io.github.javaeden.orchid:OrchidDocs:$orchidVersion" + const val orchidKotlindoc = "io.github.javaeden.orchid:OrchidKotlindoc:$orchidVersion" + const val orchidPluginDocs = "io.github.javaeden.orchid:OrchidPluginDocs:$orchidVersion" // Greymass ESR //implementation "com.greymass:esrsdk:1.0.1" From 03720ce1be57c4da48eebab12853645721a63366 Mon Sep 17 00:00:00 2001 From: Joey Harward Date: Fri, 24 Jul 2020 11:11:13 -0400 Subject: [PATCH 5/7] Github Pages deploy using Orchid --- build.gradle.kts | 5 +++++ buildSrc/src/main/kotlin/Dependencies.kt | 1 + 2 files changed, 6 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index bf3e49b9..e6973569 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,5 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties + buildscript { repositories { google() @@ -28,6 +30,7 @@ dependencies { orchidRuntimeOnly(Libraries.orchidDocs) orchidRuntimeOnly(Libraries.orchidKotlindoc) orchidRuntimeOnly(Libraries.orchidPluginDocs) + orchidRuntimeOnly(Libraries.orchidGithub) } orchid { @@ -36,4 +39,6 @@ orchid { srcDir = "protonsdk/src/orchid/resources" destDir = "protonsdk/build/docs/orchid" baseUrl = "https://protonprotocol.github.io/ProtonKotlin" + + githubToken = gradleLocalProperties(rootDir).getProperty("github.token") } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 8ccf45f7..8bbc7053 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -98,6 +98,7 @@ object Libraries { const val orchidDocs = "io.github.javaeden.orchid:OrchidDocs:$orchidVersion" const val orchidKotlindoc = "io.github.javaeden.orchid:OrchidKotlindoc:$orchidVersion" const val orchidPluginDocs = "io.github.javaeden.orchid:OrchidPluginDocs:$orchidVersion" + const val orchidGithub = "io.github.javaeden.orchid:OrchidGithub:$orchidVersion" // Greymass ESR //implementation "com.greymass:esrsdk:1.0.1" From f6efbf07d22125ad08f83989ba28ceff7f537d6d Mon Sep 17 00:00:00 2001 From: Joey Harward Date: Fri, 24 Jul 2020 20:31:59 -0400 Subject: [PATCH 6/7] fixed lint error with PeriodicWorkRequest intervals added task dependencies for publishToMavenLocal and bintrayUpload added task to clean all build dirs in project --- build.gradle.kts | 4 ++++ protonsdk/build.gradle.kts | 9 +++++++++ .../main/java/com/metallicus/protonsdk/WorkersModule.kt | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e6973569..9eb56490 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,4 +41,8 @@ orchid { baseUrl = "https://protonprotocol.github.io/ProtonKotlin" githubToken = gradleLocalProperties(rootDir).getProperty("github.token") +} + +tasks.register("cleanProton").configure { + delete("build", "buildSrc/build", "protonsdk/build") } \ No newline at end of file diff --git a/protonsdk/build.gradle.kts b/protonsdk/build.gradle.kts index 9cfd573d..24beb637 100644 --- a/protonsdk/build.gradle.kts +++ b/protonsdk/build.gradle.kts @@ -1,5 +1,6 @@ import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties import org.jetbrains.dokka.gradle.DokkaTask +import com.jfrog.bintray.gradle.tasks.BintrayUploadTask plugins { id(BuildPlugins.androidLibrary) @@ -127,6 +128,14 @@ tasks { } } } + + withType { + dependsOn(assemble) + } + + withType { + dependsOn(publishToMavenLocal) + } } group = Publishing.publishedGroupId diff --git a/protonsdk/src/main/java/com/metallicus/protonsdk/WorkersModule.kt b/protonsdk/src/main/java/com/metallicus/protonsdk/WorkersModule.kt index 9133922f..6c568e27 100644 --- a/protonsdk/src/main/java/com/metallicus/protonsdk/WorkersModule.kt +++ b/protonsdk/src/main/java/com/metallicus/protonsdk/WorkersModule.kt @@ -90,9 +90,9 @@ class WorkersModule { .enqueue() // start periodic worker to update exchange rates - val updateTokenContractRates = PeriodicWorkRequest.Builder(UpdateTokenContractRatesWorker::class.java, 15, TimeUnit.MINUTES) + val updateTokenContractRates = PeriodicWorkRequest.Builder(UpdateTokenContractRatesWorker::class.java, 15L, TimeUnit.MINUTES) .setConstraints(constraints) - .setInitialDelay(1, TimeUnit.MINUTES) + .setInitialDelay(1L, TimeUnit.MINUTES) .build() workManager.enqueueUniquePeriodicWork(UPDATE_RATES, ExistingPeriodicWorkPolicy.REPLACE, updateTokenContractRates) } From cf1bd3636770b37f688319e0d2f9db07d88f69b3 Mon Sep 17 00:00:00 2001 From: Joey Harward Date: Sun, 26 Jul 2020 22:44:52 -0400 Subject: [PATCH 7/7] cleanup, update README --- README.md | 2 +- build.gradle.kts | 2 +- protonsdk/build.gradle.kts | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c6d92f7e..fb62c7a9 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Then add the following dependency to your module's build.gradle ```gradle dependencies { ... - implementation "com.metallicus:protonsdk:0.5.1" + implementation "com.metallicus:protonsdk:0.5.2" } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 9eb56490..2cd99e69 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -43,6 +43,6 @@ orchid { githubToken = gradleLocalProperties(rootDir).getProperty("github.token") } -tasks.register("cleanProton").configure { +tasks.register("cleanAll").configure { delete("build", "buildSrc/build", "protonsdk/build") } \ No newline at end of file diff --git a/protonsdk/build.gradle.kts b/protonsdk/build.gradle.kts index 24beb637..9b288fb7 100644 --- a/protonsdk/build.gradle.kts +++ b/protonsdk/build.gradle.kts @@ -101,6 +101,7 @@ dependencies { // Dokka tasks { + // Dokka Task val dokka by getting(DokkaTask::class) { outputFormat = "html" outputDirectory = "$buildDir/dokka" @@ -129,10 +130,12 @@ tasks { } } + // publishing depends on build withType { - dependsOn(assemble) + dependsOn(build) } + // uploading to Bintray depends on publications withType { dependsOn(publishToMavenLocal) } @@ -257,7 +260,6 @@ afterEvaluate { bintray { user = gradleLocalProperties(rootDir).getProperty("bintray.user") key = gradleLocalProperties(rootDir).getProperty("bintray.apikey") - publish = true setPublications(Publishing.Publications.release)