1
我有一個Gradle項目依賴於Sigar庫,它使用本機庫(作爲它的傳遞依賴項)。這是依賴關係樹的相關片段:Gradle爲本機依賴項生成錯誤的Eclipse類路徑
+--- sigar:sigar:2.0
| +--- libsigar-amd64-linux:libsigar-amd64-linux:1.0
| +--- libsigar-ia64-linux:libsigar-ia64-linux:1.0
| +--- libsigar-x86-linux:libsigar-x86-linux:1.0
| +--- sigar-amd64-winnt:sigar-amd64-winnt:1.0
| \--- sigar-x86-winnt:sigar-x86-winnt:1.0
不幸的是,搖籃似乎沒有認識到這些是本地庫,並將它們添加到eclipse的classpath就像他們經常jar
秒。這會在Eclipse中導致錯誤:
Archive for required library: '/home/ghik/.gradle/caches/artifacts-23/filestore/libsigar-x86-linux/libsigar-x86-linux/1.0/so/c9af548445db750ad46e8beb3e77c58ff2315f3f/libsigar-x86-linux-1.0.so' in project 'myproject' cannot be read or is not a valid ZIP file
Archive for required library: '/home/ghik/.gradle/caches/artifacts-23/filestore/libsigar-ia64-linux/libsigar-ia64-linux/1.0/so/19d7aa37a3c40b6812a80eca518c6b81fd5c8416/libsigar-ia64-linux-1.0.so' in project 'myproject' cannot be read or is not a valid ZIP file
Archive for required library: '/home/ghik/.gradle/caches/artifacts-23/filestore/libsigar-amd64-linux/libsigar-amd64-linux/1.0/so/9481ceafe276c92327f8f3389c5e1c791eac6a81/libsigar-amd64-linux-1.0.so' in project 'myproject' cannot be read or is not a valid ZIP file
Archive for required library: '/home/ghik/.gradle/caches/artifacts-23/filestore/sigar-x86-winnt/sigar-x86-winnt/1.0/lib/1a608efcfd2e8358862b7dce02892fa98d63c97b/sigar-x86-winnt-1.0.lib' in project 'myproject' cannot be read or is not a valid ZIP file myproject
Archive for required library: '/home/ghik/.gradle/caches/artifacts-23/filestore/sigar-x86-winnt/sigar-x86-winnt/1.0/dll/14dfa28510c62eee00812e8d231f72ec69ac45b9/sigar-x86-winnt-1.0.dll' in project 'myproject' cannot be read or is not a valid ZIP file myproject
Archive for required library: '/home/ghik/.gradle/caches/artifacts-23/filestore/sigar-amd64-winnt/sigar-amd64-winnt/1.0/dll/b326449439e280c723ac45ada770a8d65a1272cc/sigar-amd64-winnt-1.0.dll' in project 'myproject' cannot be read or is not a valid ZIP file myproject
The project cannot be built until build path errors are resolved myproject
我該如何解決這個問題?
編輯:
我試圖排除月食類路徑依賴本土像這樣:
configurations {
natives
compile.extendsFrom(natives)
}
eclipse {
classpath {
minusConfigurations += configurations.natives
...
}
}
dependencies {
...
compile("sigar:sigar:2.0")
natives("libsigar-amd64-linux:libsigar-amd64-linux:1.0")
natives("libsigar-ia64-linux:libsigar-ia64-linux:1.0")
natives("libsigar-x86-linux:libsigar-x86-linux:1.0")
natives("sigar-amd64-winnt:sigar-amd64-winnt:1.0")
natives("sigar-x86-winnt:sigar-x86-winnt:1.0")
...
}
這隻有部分。搖籃不再添加dll
和so
文件到Eclipse的類路徑,但仍增加了lib
文件:
Archive for required library: '/home/ghik/.gradle/caches/artifacts-23/filestore/sigar-x86-winnt/sigar-x86-winnt/1.0/lib/1a608efcfd2e8358862b7dce02892fa98d63c97b/sigar-x86-winnt-1.0.lib' in project 'myproject' cannot be read or is not a valid ZIP file
我猜想你不希望你的Gradle類路徑上的本地依賴關係(至少不是全部)?你現在如何聲明'sigar'依賴? – 2013-03-14 19:00:28
Sigar依賴被聲明爲'compile(「sigar:sigar:2.0」)'。排除這些依賴關係不是不好的解決方案,但並不理想。問題僅在於Eclipse。 Gradle自己構建項目沒有問題。 – ghik 2013-03-15 13:37:18
@PeterNiederwieser我試圖從Eclipse類路徑中排除本機依賴關係(請參閱我的編輯),但即使這樣也無法按預期工作。 – ghik 2013-03-15 13:53:17