2014-10-17 8 views
10

我有這個簡單的構建腳本:如何在使用Putty,Gradle和Gradle Git插件時修復「不兼容的JNA本機庫」?

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位(系統上還有其他版本的Java,但PATH是爲此版本設置,java -version輸出1.7.0_71 64位),Putty 0.60和git 1.9.0 msysgit。

+0

錯誤消息中的哪些建議您嘗試過? – technomage 2014-10-21 02:44:17

+1

啊,是的,所以這是我的問題的一部分...我怎麼知道哪個庫是違規的庫?那個庫位於我的文件系統上?我怎麼知道哪個Jar有一個JNA庫?我確實嘗試了第二個建議:設置jna.nosys = true並且沒有任何更改。另外,Gradle設置了jna.boot.library.path,以便使用它的特定jnidispatch庫,所以我不清楚另一個jar是否有另一個調度庫。 – Jason 2014-10-23 15:32:27

+0

不確定爲什麼Gradle會附帶提取的jnidispatch.dll。我會說刪除jna.boot.library.path是值得一試的(如果這是設置jna.nosys被忽略) – user2543253 2014-10-23 16:32:12

回答

1

這一些可能的原因是:

  • 有在搖籃至少一個錯誤在搖籃邊JNA「泄露」到其他地方,看到https://issues.gradle.org/browse/GRADLE-3288,但它主要是在RC版本搖籃2.4
  • 我有一個情況下我經由

    測試{ systemProperties = System.properties }

  • 做通系統特性從搖籃到單元測試

這導致Gradle將JNA系統屬性傳遞給單元測試。這爲我解決了以下問題:

test { 
    systemProperties = System.properties 

    systemProperties['jna.boot.library.path'] = null 
} 
相關問題