From b0c2a6d4825841d8c1dd02cac55eacee757c7638 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Thu, 7 Mar 2024 10:47:13 -0800 Subject: [PATCH] Gradle Build: look for secp256k1 in ~/.nix-profile/lib This removes the need to use hard-coded paths. --- README.adoc | 4 +++- build.gradle | 3 ++- secp256k1-examples-java/build.gradle | 3 ++- secp256k1-examples-kotlin/build.gradle | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.adoc b/README.adoc index 572f024..13fbde9 100644 --- a/README.adoc +++ b/README.adoc @@ -59,13 +59,15 @@ We are currently using a Nix flake to install the native `libsecp256k1` and usin If necessary copy updated, extracted headers into `src/main/java/org/consensusj/secp256k1/` +Make sure you have installed the current version of `secp256k1` with `nix profile install nixpkgs#secp256k1` + . `./gradlew build` == Running with Gradle Wrapper (This assumes a specific hash/version of secp256k1 was installed with nixpkgs) -. `./gradlew -PjavaPath="/nix/store/j9mf1fh4wbb8c3x1zwqfs218bhml1rbw-secp256k1-0.4.0/lib/" secp256k1-examples-java:run` +. `./gradlew secp256k1-examples-java:run` == Building with Nix diff --git a/build.gradle b/build.gradle index 09fe394..705c5ce 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,8 @@ subprojects { test { useJUnitPlatform() - systemProperty "java.library.path", findProperty("javaPath") ?: "/nix/store/j9mf1fh4wbb8c3x1zwqfs218bhml1rbw-secp256k1-0.4.0/lib/" + def userHome = System.getProperty("user.home") + systemProperty "java.library.path", findProperty("javaPath") ?: "${userHome}/.nix-profile/lib" jvmArgs += '--enable-preview' jvmArgs += '--enable-native-access=ALL-UNNAMED' } diff --git a/secp256k1-examples-java/build.gradle b/secp256k1-examples-java/build.gradle index 55d42c1..36799c4 100644 --- a/secp256k1-examples-java/build.gradle +++ b/secp256k1-examples-java/build.gradle @@ -30,5 +30,6 @@ application { } run { - systemProperty "java.library.path", findProperty("javaPath") ?: "" + def userHome = System.getProperty("user.home") + systemProperty "java.library.path", findProperty("javaPath") ?: "${userHome}/.nix-profile/lib" } diff --git a/secp256k1-examples-kotlin/build.gradle b/secp256k1-examples-kotlin/build.gradle index 956e1be..8a94609 100644 --- a/secp256k1-examples-kotlin/build.gradle +++ b/secp256k1-examples-kotlin/build.gradle @@ -15,6 +15,7 @@ application { } run { - systemProperty "java.library.path", findProperty("javaPath") ?: "" + def userHome = System.getProperty("user.home") + systemProperty "java.library.path", findProperty("javaPath") ?: "${userHome}/.nix-profile/lib" }