@@ -33,22 +33,6 @@ tasks.register("preparePluginPathDirs") {
3333publishing {
3434 publications {
3535 pluginZip(MavenPublication ) { publication ->
36- pom {
37- name = pluginName
38- description = pluginDescription
39- licenses {
40- license {
41- name = " The Apache License, Version 2.0"
42- url = " http://www.apache.org/licenses/LICENSE-2.0.txt"
43- }
44- }
45- developers {
46- developer {
47- name = " OpenSearch"
48- url = " https://github.com/opensearch-project/opensearch-plugin-template-java"
49- }
50- }
51- }
5236 }
5337 }
5438}
@@ -167,8 +151,58 @@ run {
167151
168152// updateVersion: Task to auto update version to the next development iteration
169153tasks. register(' buildRust' , Exec ) {
170- workingDir = file(" ${ projectDir} /src/main/rust" )
171- commandLine = [' cargo' , ' build' , ' --release' ]
154+ // workingDir = file("${projectDir}/src/main/rust")
155+ // commandLine = ['cargo', 'build', '--release']
156+
157+ description = ' Build the Rust JNI library using Cargo'
158+ group = ' build'
159+
160+ workingDir file(' src/main/rust' )
161+
162+ // Determine the target directory and library name based on OS
163+ def osName = System . getProperty(' os.name' ). toLowerCase()
164+ def libPrefix = osName. contains(' windows' ) ? ' ' : ' lib'
165+ def libExtension = osName. contains(' windows' ) ? ' .dll' : (osName. contains(' mac' ) ? ' .dylib' : ' .so' )
166+
167+ // Use debug build for development, release for production
168+ def buildType = project. hasProperty(' rustRelease' ) ? ' release' : ' debug'
169+ def targetDir = " target/${ buildType} "
170+
171+ // Find cargo executable - try common locations
172+ def cargoExecutable = ' cargo'
173+ def possibleCargoPaths = [
174+ System . getenv(' HOME' ) + ' /.cargo/bin/cargo' ,
175+ ' /usr/local/bin/cargo' ,
176+ ' cargo'
177+ ]
178+
179+ for (String path : possibleCargoPaths) {
180+ if (new File (path). exists()) {
181+ cargoExecutable = path
182+ break
183+ }
184+ }
185+
186+ def cargoArgs = [cargoExecutable, ' build' ]
187+ if (buildType == ' release' ) {
188+ cargoArgs. add(' --release' )
189+ }
190+
191+ if (osName. contains(' windows' )) {
192+ commandLine cargoArgs
193+ } else {
194+ commandLine cargoArgs
195+ }
196+
197+ // Set environment variables for cross-compilation if needed
198+ environment ' CARGO_TARGET_DIR' , file(' jni/target' ). absolutePath
199+
200+ inputs. files fileTree(' src/main/rust/src' )
201+ inputs. file ' src/main/rust/Cargo.toml'
202+ // outputs.files file("jni/${targetDir}/${libPrefix}opensearch_datafusion_jni${libExtension}")
203+ // System.out.println("Building Rust library in ${buildType} mode");
204+
205+
172206}
173207
174208tasks. register(' copyNativeLib' , Copy ) {
0 commit comments