Skip to content

Commit

Permalink
Update build.gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
pdom0327 committed May 28, 2024
1 parent 37c1834 commit f93f136
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions java/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,38 @@ java {
}
}

def rustBasePath = "../"
// def rustBasePath = "../"

tasks.create(name: "cargo-output-dir", description: "Get cargo metadata") {
new ByteArrayOutputStream().withStream { os ->
exec {
commandLine 'cargo', 'metadata', '--format-version', '1'
workingDir rustBasePath
standardOutput = os
}
def outputAsString = os.toString()
def json = new groovy.json.JsonSlurper().parseText(outputAsString)
// tasks.create(name: "cargo-output-dir", description: "Get cargo metadata") {
// new ByteArrayOutputStream().withStream { os ->
// exec {
// commandLine 'cargo', 'metadata', '--format-version', '1'
// workingDir rustBasePath
// standardOutput = os
// }
// def outputAsString = os.toString()
// def json = new groovy.json.JsonSlurper().parseText(outputAsString)

logger.info("cargo target directory: ${json.target_directory}")
project.ext.cargo_target_directory = json.target_directory
}
}
// logger.info("cargo target directory: ${json.target_directory}")
// project.ext.cargo_target_directory = json.target_directory
// }
// }

tasks.create(name: "cargo-build", type: Exec, description: "Running Cargo build", dependsOn: "cargo-output-dir") {
workingDir rustBasePath
commandLine 'cargo', 'build', '--release', '--features=java'
}
// tasks.create(name: "cargo-build", type: Exec, description: "Running Cargo build", dependsOn: "cargo-output-dir") {
// workingDir rustBasePath
// commandLine 'cargo', 'build', '--release', '--features=java'
// }

tasks.create(name: "rust-deploy", type: Sync, dependsOn: "cargo-build") {
from "${project.ext.cargo_target_directory}/release"
include "*.dll", "*.dylib", "*.so"
into "src/main/resources"
}
// tasks.create(name: "rust-deploy", type: Sync, dependsOn: "cargo-build") {
// from "${project.ext.cargo_target_directory}/release"
// include "*.dll", "*.dylib", "*.so"
// into "src/main/resources"
// }

tasks.withType(ProcessResources) {
compileTask -> compileTask.dependsOn "rust-deploy"
}
// tasks.withType(ProcessResources) {
// compileTask -> compileTask.dependsOn "rust-deploy"
// }

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn "rust-deploy"
}
// tasks.withType(JavaCompile) {
// compileTask -> compileTask.dependsOn "rust-deploy"
// }

0 comments on commit f93f136

Please sign in to comment.