From 660af53553b93f898eb06affbf711b36c3cba68e Mon Sep 17 00:00:00 2001 From: JohnE Date: Mon, 13 May 2019 11:48:53 -0700 Subject: [PATCH] NEW: updated the build to publish to local maven repo for flutter purposes, updated docs because I confused myself..arrg --- README_DEV.rst | 15 +++++++++++---- build.gradle | 2 ++ {nc-libs => dist}/wolfssl-jni.aar | Bin nc-jni/build.gradle | 2 +- nc-jni/build.sh | 3 ++- settings.gradle | 9 +++++++-- wolfssl-jni/build.gradle | 30 ++++++++++++++++++++++++++---- 7 files changed, 49 insertions(+), 12 deletions(-) rename {nc-libs => dist}/wolfssl-jni.aar (100%) diff --git a/README_DEV.rst b/README_DEV.rst index 6edb9ff..6160312 100644 --- a/README_DEV.rst +++ b/README_DEV.rst @@ -3,18 +3,25 @@ DEVELOPER README ================ -application details -------------------- +Project Details +--------------- * ./wolfssl-lib - builds source from OEM WolfSSL repository!! =) - only needs to be built once (when you want a new library) + - generates BOTH shared (.so) and static (.a) + - static (.a) is really just a zip of all the files compiled staticly * ./wolfssl-jni - JNI for the WolfSSL library + - contains BOTH C and Java files (for JNI to work dummy) + - expects "libwolfssl.a" file to link with during cmake compile + - example: ./wolfssl-jni/libs/wolfssl-lib/arm64-v8a + - OUTPUT: "wolfssl-jni.aar" * ./ccc-jni (default main source code) - - JNI, java connections to the native binaries - - C files + - TEST: test code only, does nothing more, no C files at this time + - no C files at this time, just java files to test lib + - broken!! maybe replace diff --git a/build.gradle b/build.gradle index ccc8345..313fe34 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ buildscript { repositories { + mavenLocal() google() jcenter() } @@ -12,6 +13,7 @@ buildscript { allprojects { repositories { + mavenLocal() google() jcenter() } diff --git a/nc-libs/wolfssl-jni.aar b/dist/wolfssl-jni.aar similarity index 100% rename from nc-libs/wolfssl-jni.aar rename to dist/wolfssl-jni.aar diff --git a/nc-jni/build.gradle b/nc-jni/build.gradle index e020ce1..56237c1 100644 --- a/nc-jni/build.gradle +++ b/nc-jni/build.gradle @@ -30,7 +30,7 @@ android { sourceSets { main { // let gradle pack the shared library into apk - jniLibs.srcDirs = ['lib/wolfssl-jni'] + jniLibs.srcDirs = ['nc-libs/wolfssl-jni'] } } // externalNativeBuild { diff --git a/nc-jni/build.sh b/nc-jni/build.sh index 161fee2..b127589 100644 --- a/nc-jni/build.sh +++ b/nc-jni/build.sh @@ -7,4 +7,5 @@ gradle clean # there is a bug in the cleaner task, we need to blow away this artifact directory too rm -rf .externalNativeBuild/ # build and copy the libs -gradle build copyLibs +# copy maven local so that flutter can find the lib (because Goog sucks at engineering) +gradle build copyLibs publishToMavenLocal diff --git a/settings.gradle b/settings.gradle index 53852da..6e6f487 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,9 @@ // include this at the top, for shared libraries // include ':wolfssl-lib' -// include ':wolfssl-jni' -include ':ccc-jni' + +// contains Java and C for JNI purposes +// will generate a .aar file in ./dist folder +include ':wolfssl-jni' + +// broken, was test code, but now we use .aar file +// include ':nc-jni' diff --git a/wolfssl-jni/build.gradle b/wolfssl-jni/build.gradle index 8d99335..b1a5871 100644 --- a/wolfssl-jni/build.gradle +++ b/wolfssl-jni/build.gradle @@ -28,22 +28,44 @@ android { } } + +// we are going to "publish" to local maven repository +apply plugin: 'maven-publish' +project.afterEvaluate { + publishing { + publications { + library(MavenPublication) { + groupId 'io.malloc.ccc' + artifactId 'nc-jni' + version "1.1" + artifact(bundleReleaseAar) + } + } + } +} + // Copies files to the dist/ folder, adds a timestamp // instead of using a bash script I ventured out to try this file copy in Groovy (Gradle) // ...and yay, I was successful =) task copyLibs(type: Copy) { def thisDate = new Date().format('yyyyMMdd_HHmmssSSS') + def destDir = "dist/wolfssl-jni_${thisDate}" + + // copy the library package + from('build/outputs/aar/') { + include '**/*.aar' + } from('build/intermediates/cmake/debug/obj/') { include '**/*.so' - into 'debug' + into 'libwolfssl-jni/debug/' } from('build/intermediates/cmake/release/obj/') { include '**/*.so' - into 'release' + into 'libwolfssl-jni/release/' } - into "dist/wolfssl-jni_${thisDate}/" -} + into "${destDir}/" +} dependencies { testImplementation 'junit:junit:4.12'