gpt4 book ai didi

java - 使用 Putty、Gradle 和 Gradle Git 插件时如何修复 "incompatible JNA native library"?

转载 作者:搜寻专家 更新时间:2023-10-30 21:34:26 27 4
gpt4 key购买 nike

我有这个简单的构建脚本:

import org.ajoberstar.grgit.Grgit

apply plugin: 'application'
apply plugin: 'org.ajoberstar.release-opinion'

task wrapper(type:Wrapper) {
gradleVersion = '2.1'
}

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.ajoberstar:gradle-git:0.11.+'
}
}

release {
grgit = Grgit.open(project.file('.'))
}

我创建了一个 HelloWorld 风格的项目并初始化了 git 存储库。当我为远程源使用目录时,我可以运行

.\gradlew.bat release

就好了。但是当我对远程源使用 ssh 目标时,我得到以下输出:

16:39:55.355 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':prepare'.
16:39:55.355 [INFO] [org.gradle.api.Task] Fetching changes from remote: origin
16:39:55.387 [INFO] [org.ajoberstar.grgit.auth.TransportOpUtil] The following authentication options are allowed (though they may not be available): [
HARDCODED, PAGEANT, SSHAGENT, INTERACTIVE]
16:39:55.402 [INFO] [org.ajoberstar.grgit.auth.TransportOpUtil] using interactive credentials, if needed
16:39:55.480 [INFO] [org.ajoberstar.grgit.auth.JschAgentProxySessionFactory] ssh-agent not available
16:39:55.511 [INFO] [org.ajoberstar.grgit.auth.JschAgentProxySessionFactory] pageant available
16:39:55.527 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':prepare'
16:39:55.527 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :prepare FAILED
16:39:55.543 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :prepare (Thread[main,5,main]) completed. Took 0.219 secs.
16:39:55.543 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 0.219 secs, idle: 0.0
secs
16:39:55.543 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.543 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
16:39:55.543 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':prepare'.
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] >
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] There is an incompatible JNA native library installed on this system.
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] To resolve this issue you may do one of the following:
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] - remove or uninstall the offending library
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] - set the system property jna.nosys=true
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] - set jna.boot.library.path to include the path to the version of the
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter] jnidispatch library included with the JNA jar file you are using
16:39:55.558 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.574 [ERROR] [org.gradle.BuildExceptionReporter]
16:39:55.574 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
16:39:55.574 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
16:39:55.574 [LIFECYCLE] [org.gradle.BuildResultLogger]
16:39:55.574 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED

我使用 --stacktrace 重新运行,这是此错误的部分堆栈跟踪(似乎暗示 Jsch):

Caused by: java.lang.Error:
at com.sun.jna.Native.<clinit>(Native.java:142)
at com.jcraft.jsch.agentproxy.connector.PageantConnector$User32.<clinit>(PageantConnector.java:85)
at com.jcraft.jsch.agentproxy.connector.PageantConnector.<init>(PageantConnector.java:61)
at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory$_closure2.doCall(JschAgentProxySessionFactory.groovy:122)
at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory$_closure2.doCall(JschAgentProxySessionFactory.groovy)
at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory$_determineConnector_closure5.doCall(JschAgentProxySessionFactory.groovy:86)
at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory.determineConnector(JschAgentProxySessionFactory.groovy:85)
at org.ajoberstar.grgit.auth.JschAgentProxySessionFactory.getJSch(JschAgentProxySessionFactory.groovy:65)
at org.eclipse.jgit.transport.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:191)
at org.eclipse.jgit.transport.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:150)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:109)
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:306)
at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:152)
at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:154)
at org.eclipse.jgit.transport.Transport.push(Transport.java:1173)
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:156)
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:79)
at java_util_concurrent_Callable$call$0.call(Unknown Source)
at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy:104)
at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at java_util_concurrent_Callable$call.call(Unknown Source)
at org.ajoberstar.grgit.util.OpSyntaxUtil.tryOp(OpSyntaxUtil.groovy:45)
at org.ajoberstar.grgit.Grgit.methodMissing(Grgit.groovy:190)
at org.ajoberstar.gradle.git.release.GrgitReleasePlugin$_addReleaseTask_closure4_closure14.doCall(GrgitReleasePlugin.groovy:134)
... 56 more

关于如何让它工作的任何想法?

我使用的是Gradle 2.1,Gradle-git 0.11.0(在构建脚本中可以看到),Java 1.7.0_71 64-bit(系统上还有其他版本的Java,但是设置了PATH对于此版本和 java -version 输出 1.7.0_71 64 位)、Putty 0.60 和 git 1.9.0 msysgit。

最佳答案

一些可能的原因是:

  • Gradle 中至少有一个错误,即 Gradle 端 JNA“泄漏”到其他地方,请参阅 https://issues.gradle.org/browse/GRADLE-3288 , 然而它主要是在 Gradle 2.4 的 RC 版本中
  • 在一个案例中,我确实通过

    将系统属性从 Gradle 传递到单元测试

    测试{ systemProperties = 系统属性

这导致 Gradle 将 JNA 系统属性传递给单元测试。这是通过以下方式为我解决的:

test {
systemProperties = System.properties

systemProperties['jna.boot.library.path'] = null
}

关于java - 使用 Putty、Gradle 和 Gradle Git 插件时如何修复 "incompatible JNA native library"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26434884/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com