@@ -3,6 +3,15 @@ plugins {
33 id ' application'
44}
55
6+ dependencies {
7+ // JSON processing
8+ implementation ' com.google.code.gson:gson:2.10.1'
9+
10+ // Testing
11+ testImplementation ' org.junit.jupiter:junit-jupiter:5.10.1'
12+ testRuntimeOnly ' org.junit.platform:junit-platform-launcher'
13+ }
14+
615java {
716 toolchain {
817 languageVersion = JavaLanguageVersion . of(24 )
@@ -22,10 +31,24 @@ def bitcoinKernelHeader = file("${bitcoinCoreDir}/src/kernel/bitcoinkernel.h")
2231tasks. register(' buildBitcoinCore' , Exec ) {
2332 workingDir bitcoinCoreDir
2433
25- // Configure Bitcoin Core build
34+ // Configure Bitcoin Core build (matching rust-bitcoinkernel approach)
2635 commandLine ' cmake' , ' -B' , ' build' ,
36+ ' -DCMAKE_BUILD_TYPE=RelWithDebInfo' ,
2737 ' -DBUILD_KERNEL_LIB=ON' ,
28- ' -DBUILD_UTIL_CHAINSTATE=ON'
38+ ' -DBUILD_TESTS=OFF' ,
39+ ' -DBUILD_KERNEL_TEST=OFF' ,
40+ ' -DBUILD_TX=OFF' ,
41+ ' -DBUILD_WALLET_TOOL=OFF' ,
42+ ' -DENABLE_WALLET=OFF' ,
43+ ' -DENABLE_EXTERNAL_SIGNER=OFF' ,
44+ ' -DBUILD_UTIL=OFF' ,
45+ ' -DBUILD_BITCOIN_BIN=OFF' ,
46+ ' -DBUILD_DAEMON=OFF' ,
47+ ' -DBUILD_UTIL_CHAINSTATE=OFF' ,
48+ ' -DBUILD_CLI=OFF' ,
49+ ' -DBUILD_SHARED_LIBS=ON' ,
50+ ' -DCMAKE_INSTALL_LIBDIR=lib' ,
51+ ' -DENABLE_IPC=OFF'
2952
3053 // Only run if build directory doesn't exist or header has changed
3154// inputs.file bitcoinKernelHeader
@@ -65,4 +88,62 @@ application {
6588}
6689
6790// Ensure proper build order
68- compileJava. dependsOn compileBitcoinCore
91+ compileJava. dependsOn compileBitcoinCore
92+
93+ // Configure test task
94+ test {
95+ useJUnitPlatform()
96+ testLogging {
97+ events " passed" , " skipped" , " failed"
98+ exceptionFormat " full"
99+ }
100+ }
101+
102+ // Task to run conformance handler
103+ tasks. register(' conformanceHandler' , Exec ) {
104+ group = ' conformance'
105+ description = ' Run the conformance test handler (reads from stdin, writes to stdout)'
106+
107+ classpath = sourceSets. main. runtimeClasspath
108+ mainClass = ' org.bitcoinkernel.conformance.ConformanceTestHandler'
109+
110+ // Required for FFM
111+ jvmArgs = [' --enable-native-access=ALL-UNNAMED' ]
112+
113+ // Connect stdin/stdout
114+ standardInput = System . in
115+ standardOutput = System . out
116+ standardError = System . err
117+ }
118+
119+ // Build uber JAR with all dependencies
120+ tasks. register(' buildConformanceJar' , Jar ) {
121+ group = ' conformance'
122+ description = ' Build standalone conformance handler JAR with all dependencies'
123+
124+ archiveBaseName = ' java-bitcoinkernel-conformance-handler'
125+ archiveVersion = ' 0.1.0'
126+
127+ from sourceSets. main. output
128+
129+ // Include all dependencies
130+ from {
131+ configurations. runtimeClasspath. collect {
132+ it. isDirectory() ? it : zipTree(it)
133+ }
134+ }
135+
136+ // Avoid duplicate files
137+ duplicatesStrategy = DuplicatesStrategy . EXCLUDE
138+
139+ manifest {
140+ attributes(
141+ ' Main-Class' : ' org.bitcoinkernel.conformance.ConformanceTestHandler' ,
142+ ' Implementation-Title' : ' Java Bitcoin Kernel Conformance Handler' ,
143+ ' Implementation-Version' : archiveVersion. get()
144+ )
145+ }
146+ }
147+
148+ // Make conformance JAR depend on compilation
149+ buildConformanceJar. dependsOn compileJava
0 commit comments