Skip to content

Commit

Permalink
Gradle Build: look for secp256k1 in ~/.nix-profile/lib
Browse files Browse the repository at this point in the history
This removes the need to use hard-coded paths.
  • Loading branch information
msgilligan committed Mar 8, 2024
1 parent 0e766f1 commit 5807e2a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
3 changes: 2 additions & 1 deletion secp256k1-examples-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 2 additions & 1 deletion secp256k1-examples-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 5807e2a

Please sign in to comment.