Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions secp-examples-jshell/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import org.codehaus.groovy.runtime.GStringImpl

plugins {
id 'java'
id 'application'
id 'org.beryx.jlink' version '3.1.4-rc'
}

ext.moduleName = 'org.bitcoinj.secp.jshell'
ext.libSecpDir = System.getenv("LIBSECP_DIR")
ext.javaHome = System.getenv("JAVA_HOME")

dependencies {
implementation project(':secp-api')
implementation project(':secp-bouncy')
implementation project(':secp-ffm')
}

tasks.withType(JavaCompile).configureEach {
// Override Default release version
options.release = 25
}

jar {
inputs.property("moduleName", moduleName)
manifest {
attributes 'Implementation-Title': 'Placeholder App for secp256k1-jdk JShell Example',
'Main-Class': application.mainClass,
'Implementation-Version': archiveVersion.get()
}
}

application {
mainModule = 'org.bitcoinj.secp.jshell'
mainClass = 'org.bitcoinj.secp.jshell.Hello'
applicationName = 'hello'
}

run {
jvmArgs += '--enable-native-access=org.bitcoinj.secp.ffm'
}

jlink {
options = ['--add-modules', 'org.bitcoinj.secp.ffm',
'--add-modules', 'org.bitcoinj.secp.bouncy', '--ignore-signing-information',
'--add-modules', 'jdk.jshell']
launcher {
name = application.applicationName
}
}

tasks.register('copyNativeLibraries', Copy) {
dependsOn tasks.jlink
from(libSecpDir) { include 'libsecp256k1.*' }
into("${tasks.jlink.imageDir}/lib")
}

tasks.register('copyJdkSource', Copy) {
dependsOn tasks.jlink
from {
def javaHome = System.getenv('JAVA_HOME') ?: System.getProperty('java.home')
file("$javaHome/lib/src.zip")
}
into("${tasks.jlink.imageDir}/lib")
finalizedBy(tasks.named('addJshellWrapper'))
}

tasks.register('addJshellWrapper') {
dependsOn tasks.copyJdkSource
doLast {
def jshellScript = file("${tasks.jlink.imageDir}/bin/secp-shell")
jshellScript.text = """#!/bin/bash
DIR=\$(dirname "\$0")
"\$DIR/jshell" "\$@"
"""
jshellScript.setExecutable(true)
}
}

tasks.jlink {
finalizedBy(tasks.copyNativeLibraries, tasks.copyJdkSource) // tasks.copyProjectJavadoc
}

21 changes: 21 additions & 0 deletions secp-examples-jshell/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2023-2025 secp256k1-jdk Developers.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* JShell Example.
*/
module org.bitcoinj.secp.jshell {
requires org.bitcoinj.secp;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2023-2025 secp256k1-jdk Developers.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp.jshell;

public class Hello {
void main() {
IO.println("Hello! Try running the `secp-shell` executable for JShell with secp256k1-jdk built-in.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2023-2025 secp256k1-jdk Developers.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// Contains a placeholder application for a custom JShell build.
package org.bitcoinj.secp.jshell;
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ include 'secp-graalvm' // GraalVM Foreign Function Registration suppor
include 'secp-bitcoinj' // bitcoinj integration utilities and tests (P2TR address generation, etc.)
include 'secp-integration-test' // Integration tests of API implementations (ffm and bouncy)
include 'secp-examples-java' // Java examples
include 'secp-examples-jshell' // jshell example
include 'secp-examples-kotlin' // Kotlin examples