Skip to content

Commit

Permalink
Merge pull request #153 from LtbLightning/cargokit-fix-pubdev-score
Browse files Browse the repository at this point in the history
Cargokit fix pubdev score
  • Loading branch information
BitcoinZavior authored Dec 7, 2024
2 parents ad86b7d + e3b7bfb commit cc3e0e2
Show file tree
Hide file tree
Showing 26 changed files with 481 additions and 448 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/precompile_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: android-actions/setup-android@v2
- name: Install Specific NDK
if: (matrix.os == 'ubuntu-20.04')
run: sdkmanager --install "ndk;24.0.8215888"
run: sdkmanager --install "ndk;25.1.8937393"
- name: Precompile (with iOS)
if: (matrix.os == 'macOS-latest')
run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/bdk-flutter
Expand All @@ -47,7 +47,7 @@ jobs:
PRIVATE_KEY: ${{ secrets.CARGOKIT_PRIVATE_KEY }}
- name: Precompile (with Android)
if: (matrix.os == 'ubuntu-20.04')
run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/bdk-flutter --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=24.0.8215888 --android-min-sdk-version=23
run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/bdk-flutter --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=25.1.8937393 --android-min-sdk-version=23
working-directory: cargokit/build_tool
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## [0.31.3]
#### Upgrades
- Updated `Flutter` dependencies to the latest version.
- Upgraded `Gradle` to version 8.4 and `Java` to version 17.
- Upgraded `android-ndk` to `25.1.8937393`.
#### Fixed
- Removed unnecessary class exports.
- Resolved the `txBuilder.setRecipients` error.

## [0.31.2]
Updated `flutter_rust_bridge` to `2.0.0`.
Expand Down
29 changes: 8 additions & 21 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
group 'io.bdk.f.bdk_flutter'
version '1.0-SNAPSHOT'
version '0.31.3'
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand All @@ -22,33 +20,22 @@ allprojects {
}

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

android {
compileSdkVersion 31
namespace "io.bdk.f.bdk_flutter"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
if (project.android.hasProperty("namespace")) {
namespace "io.bdk.f.bdk_flutter"
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
compileSdkVersion 33
ndkVersion android.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

defaultConfig {
minSdkVersion 23
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.databinding:databinding-runtime:7.2.1'
testImplementation 'junit:junit:4.13.2'
}
apply from: "../cargokit/gradle/plugin.gradle"

cargokit {
Expand Down
Binary file removed android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 0 additions & 5 deletions android/gradle/wrapper/gradle-wrapper.properties

This file was deleted.

6 changes: 3 additions & 3 deletions cargokit/.github/workflows/check_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
Flutter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 #v2.7.0
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d #1.6.0
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # 2.16.0
- name: Pub Get
run: dart pub get --no-precompile
working-directory: build_tool
Expand All @@ -22,5 +22,5 @@ jobs:
run: dart analyze
working-directory: build_tool
- name: Test
run: dart test
run: flutter test
working-directory: build_tool
8 changes: 6 additions & 2 deletions cargokit/.github/workflows/test_example_plugin_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
git clone -b advanced https://github.com/irondash/hello_rust_ffi_plugin
cd hello_rust_ffi_plugin
git subtree pull --prefix cargokit https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }} ${{ steps.extract_branch.outputs.branch }} --squash
- uses: subosito/flutter-action@cc97e1648fff6ca5cc647fa67f47e70f7895510b # 2.11.0
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # 2.16.0
with:
channel: "stable"
- name: Install GTK
Expand Down Expand Up @@ -77,6 +77,10 @@ jobs:
shell: bash
working-directory: ${{ env.EXAMPLE_DIR }}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
if [[ $(sysctl hw.optional.arm64) == *"hw.optional.arm64: 1"* ]]; then
export JAVA_HOME=$JAVA_HOME_17_arm64
else
export JAVA_HOME=$JAVA_HOME_11_X64
fi
flutter build apk --${{ matrix.build_mode }} -v
6 changes: 5 additions & 1 deletion cargokit/gradle/plugin.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ class CargoKitPlugin implements Plugin<Project> {
}

def cargoBuildDir = "${project.buildDir}/build"

// Determine if the project is an application or library
def isApplication = plugin.project.plugins.hasPlugin('com.android.application')
def variants = isApplication ? plugin.project.android.applicationVariants : plugin.project.android.libraryVariants

plugin.project.android.applicationVariants.all { variant ->
variants.all { variant ->

final buildType = variant.buildType.name

Expand Down
5 changes: 5 additions & 0 deletions cargokit/run_build_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ if [ ! -f "$PACKAGE_HASH_FILE" ]; then
echo "$PACKAGE_HASH" > "$PACKAGE_HASH_FILE"
fi

# Rebuild the tool if it was deleted by Android Studio
if [ ! -f "bin/build_tool_runner.dill" ]; then
"$DART" compile kernel bin/build_tool_runner.dart
fi

set +e

"$DART" bin/build_tool_runner.dill "$@"
Expand Down
57 changes: 16 additions & 41 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,56 +1,35 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
namespace = "io.bdk.f.bdk_flutter_example"
compileSdk = flutter.compileSdkVersion
ndkVersion "25.1.8937393"

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

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = JavaVersion.VERSION_17
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}


defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.bdk.f.bdk_flutter_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 23
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
minSdk = 23
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}

buildTypes {
Expand All @@ -60,13 +39,9 @@ android {
signingConfig signingConfigs.debug
}
}
namespace 'io.bdk.f.bdk_flutter_example'
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
19 changes: 3 additions & 16 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
}
3 changes: 1 addition & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
29 changes: 21 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.3.1" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
include ":app"
4 changes: 2 additions & 2 deletions ios/Classes/frb_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ typedef struct wire_cst_satisfiable_item {
} wire_cst_satisfiable_item;

void frbgen_bdk_flutter_wire__crate__api__blockchain__bdk_blockchain_broadcast(int64_t port_,
struct wire_cst_bdk_blockchain *that,
struct wire_cst_bdk_blockchain *ptr,
struct wire_cst_bdk_transaction *transaction);

void frbgen_bdk_flutter_wire__crate__api__blockchain__bdk_blockchain_create(int64_t port_,
Expand Down Expand Up @@ -1153,7 +1153,7 @@ void frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_get_psbt_input(int6
bool only_witness_utxo,
struct wire_cst_psbt_sig_hash_type *sighash_type);

WireSyncRust2DartDco frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_is_mine(struct wire_cst_bdk_wallet *that,
WireSyncRust2DartDco frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_is_mine(struct wire_cst_bdk_wallet *ptr,
struct wire_cst_bdk_script_buf *script);

WireSyncRust2DartDco frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_list_transactions(struct wire_cst_bdk_wallet *that,
Expand Down
Loading

0 comments on commit cc3e0e2

Please sign in to comment.