- 浏览: 581790 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (188)
- java (14)
- web (14)
- web service (3)
- 杂谈 (14)
- Version Control (13)
- software test (30)
- linux (17)
- database (3)
- distributed storage and computing (1)
- ejb (7)
- project building (46)
- spring & IOC (2)
- Thread (2)
- xml (2)
- tool software (0)
- [网站分类]1.网站首页原创Java技术区(对首页文章的要求: 原创、高质量、经过认真思考并精心写作。BlogJava管理团队会对首页的文章进行管理。) (0)
- project manager (9)
- OSGI (1)
- nosql (3)
最新评论
-
sp42:
好搞笑
你懂不懂xml! (2) -
cherishmmo2004:
感觉你们都很牛掰,我们做的一个运维平台也是用karaf的,用k ...
基于osgi开发大型的企业应用 -
liubey:
“自作聪明”的使用了读写锁,其实只使用ReentrantLoc ...
编码最佳实践(4)--小心LinkedHashMap的get()方法 -
liubey:
你这个代码是sublist后仍然一直持有这个sub的引用,一般 ...
编码最佳实践(5)--小心!这只是冰山一角 -
xiegqooo:
初学maven(5)-使用assembly plugin实现自定义打包
转一个blog,关于如何使用ivy来处理native的依赖,对于有使用JNI开发的朋友应该很有价值。
原文blog地址:http://www.cooljeff.co.uk/2009/08/01/handling-native-dependencies-with-apache-ivy/
---------------------------------
Being able to handle native dependencies with Ivy has cropped up a couple of times with no best practise solution being available. This blog entry discusses the various proposals that have been put forward in order to provide a solution that:
- Works with Ivy Ant tasks in order to help populate the java.library.path .
- Works with IvyDE in order to populate the Native Library Location of a classpath entry.
- Is able to deal with different platforms.
- Is suitable for building enterprise repositories in order to download by platform.
It is important to remember that the concept of a platform constitutes a permutation of various components not limited to Operating System and Endianess. A good example would be the C libraries available from the NAG (Numeric Algorithms Group) which have distributions that take into account the compiler version to. Occasionally you even see JARs being distributed by platform (e.g. IBM’s Java MQ Series Client), which although is arguably a bad practise, does happen and Ivy needs to be able to handle these edge cases. Having said this, in this blog entry I will only take into account Windows/Linux and 32-bit/64-bit combinations for brevity.
The following proposals are explored (from least to most favourite):
- Using configurations to declare native artifacts.
- Using the extra attribute to declare a JNI path.
- Using types to declare native artifacts.
- Using types and a platform attribute to declare native artifacts.
Using configurations to declare native artifacts
This solution would look as follows:
< info organisation ="mit" module ="kerberos" revision ="1.7.0" />
< configurations >
< conf name ="ia32.linux" description ="32-bit linux native dependencies" />
< conf name ="ia64.linux" description ="64-bit linux native dependencies" />
< conf name ="ia32.windows" description ="32-bit windows native dependencies" />
</ configurations >
< publications >
< artifact name ="kerb5_lib" type ="native" ext ="so" conf ="ia32.linux" />
< artifact name ="kerb5_lib" type ="native" ext ="so" conf ="ia64.linux" />
< artifact name ="kerb5_lib" type ="native" ext ="dll" conf ="ia32.windows" />
</ publications >
</ ivy-module >
Here we are using configurations to declare artifacts by platform. Something depending on this module would then explicitly depend on a specific platform through a configuration.
This solution has the following issues:
- Switching between platforms requires updates to Ivy files.
- Switching between platforms is not really possible for a transitive dependency.
- IvyDE does not support filtering by configuration (only by types).
- Repository structuring information is now in the dependency hierarchy.
Switching between platforms is a big issue here because we are abusing what configurations are designed for. A configuration is a way of using a module, not for describing what an artifact actually is. This is why you don’t see configurations labeled: jars , javadocs or source . Whilst I have to admit that I’ve not tried implementing this solution, I cannot see how it can work when resolving native dependencies transitively. Perhaps some conf mapping trickery could be used.
The owner of a 3rd party Ivy module (i.e. one found in some repository) does not know about the environment you are going to be working in. Hence if that module itself has native dependencies, the owner of the module would not be able to say which configuration to depend on when writing the ivy module, even though it clearly has a native dependency.
Even for the end user who does have a little more control over the configurations they directly pull in, you would not be able to switch between environments without updating the configurations you depend on. Being able to switch between environments is a common use case. Many people develop on Windows and deploy on Linux. The Ivy module should remain identical for both environments because in most use cases, the logical dependency stays the same. What changes is the physical artifact.
Finally, many shared libraries have the same file name for both 32-bit and 64-bit distributions. This means that you are going to have to use the configuration as a directory name to structure your repository, which is not ideal because repository structuring information is now directly in the dependency hierarchy that a user will use.
Using the extra attribute to declare a JNI path
This solution would look as follows:
< info organisation ="mit" module ="kerberos" revision ="1.7.0"
extra:jni ="native/lib" />
</ ivy-module >
Here we are using the ability to add additional custom attributes to the info element in order to describe where the native libraries can then be found. An Ivy trigger would then need to be implemented by the Ant build infrastructure to detect module resolution in order to pick up the extra attribute and populate the java.library.path correctly.
This was proposed by Arthur Branham on a comment to his JIRA requesting Ivy to support native library path construction [IVY-600] . This is something that I’ve actually seen implemented as a quick solution to get over native library dependency issues when running integration tests as part of a build using Ant.
This solution has the following issues:
- Resolving for different platforms cannot be done using the same Ivy file.
- Resolving for a specific platform against a remote repository is not possible.
- IvyDE does not have support for extra attributes.
In order to support multiple platform resolution, you need to allow the attribute to have tokens that the resolver is capable of substituting. Even then, whilst this works for a local file system, it does not help when dealing with an external repository on the web because Ivy will need to download the artifacts into the cache for local use. With this solution there are no native artifacts, the repository structure is instead pushed into the ivy module file which ideally should remain in the ivy settings file.
Using types to declare native artifacts
This solution would look as follows:
< info organisation ="mit" module ="kerberos" revision ="1.7.0" />
< configurations >
< conf name ="runtime" description ="Core runtime dependencies" />
</ configurations >
< publications >
< artifact name ="kerb5_lib" type ="ia32.linux" ext ="so" conf ="runtime" />
< artifact name ="kerb5_lib" type ="ia64.linux" ext ="so" conf ="runtime" />
< artifact name ="kerb5_lib" type ="ia32.windows" ext ="dll" conf ="runtime" />
</ publications >
</ ivy-module >
Here we are using the type to provide the platform information. To switch between platforms, you simply need to filter by type when performing an Ivy Retrieve or Ivy Cache Path to match the platform you wish to resolve by.
This solution has the following clear advantages:
- The supported platforms are clearly stated in the Ivy module descriptor.
- Repository structuring has not leaked into the dependency information.
- Types fit in well with IvyDE which already uses types for javadocs and source.
- Types are already used by default to segregate artifacts in a cache.
This solution has the following issue:
- The type can no longer be used for other platform specific artifacts.
The concern I have with this solution is that we are not really using the type for its intended usage. This can result in blocking the use of other artifacts which are associated to the same platform but not associated to the java.library.path .
Imagine if you have jar file which is platform specific but still goes onto the classpath. As mentioned in the introduction, distributions of the IBM Java MQ Series Client have slightly different jars for each platform. For this use case you would still expect the type to be jar , since this is the type you will filter on when populating the classpath using the cachepath ant task. Similarly take a repository that has scripts or executables available for download by platform, you would expect the types to be scripts or exe respectively.
If we were to take a step back, forget what we are trying to solve and use the type classification for its intended usage, we probably would have named the type for native library dependencies to go on the java.libary.path as type=”library” .
Using types and a platform attribute to declare native artifacts
This solution would look as follows:
< info organisation ="mit" module ="kerberos" revision ="1.7.0" />
< configurations >
< conf name ="runtime" description ="Core runtime dependencies" />
</ configurations >
< publications >
< artifact name ="kerb5_lib" type ="library" ext ="so" platform ="ia32.linux"
conf ="runtime" />
< artifact name ="kerb5_lib" type ="library" ext ="so" platform ="ia64.linux"
conf ="runtime" />
< artifact name ="kerb5_lib" type ="library" ext ="dll" platform ="ia32.windows"
conf ="runtime" />
</ publications >
</ ivy-module >
This solution has the same benefits as using the type alone to define the platform information, however it does not have the same disadvantage of blocking other platform specific artifacts that are unrelated to the java.library.path from using the same type name. To integrate the above solution into Ivy the following would need to be done:
- IvyDE would need to support a Native Library Type (default to library ).
- IvyDE would need to support a Platform.
- IvyDE would need to populate the Native Library Location of a classpath entry.
- Ivy would need to support platform as a filter option in retrieve and cachepath .
- Ivy would need to allow the user to set the platform easily in the Ivy settings.
When populating the Native Library Location IvyDE will need to create a directory tree to all of the artifacts and then remove all duplicate paths.
Conclusion
Handling native library dependencies is a gap in Ivy that will begin to impact enterprise users who have some native dependencies. Whilst types alone could be used to solve the problem, this potentially blocks using Ivy to resolve other platform specific dependencies that are not associated with the java.libary.path . The neatest solution would be to use type=”library” to group artifacts that are intended for the java.libary.path , along with a new attribute called platform . This solution will allow repositories to be structured well with platform specific information and also allow clients to resolve dependencies easily, regardless of the environment they happen to be currently working in.
Resources
- Official Apache Ivy website
- JNI and Endorsed directories ivy user mail thread
- Add ability to construct a native library path based on dependencies JIRA
发表评论
-
搜索maven依赖的网站推荐
2011-12-02 16:04 4306使用maven填写依赖的时候,常会遇到需要查一下gro ... -
hudson中subversion HEAD check out 的问题及疑惑
2010-09-30 10:56 40近期发现一个问题,hudson执行任务时,经常不能获取 ... -
你走你的阳光道,我走我的独木桥:整合ant ivy 和testng
2010-05-31 16:11 2071近期自己折腾自己,放着正统的maven + jun ... -
slf4j1.6.0-RC0和logback的0.9.20版本不兼容
2010-04-26 08:54 3508今天,尝试使用slf4j + logback的黄金组合,结果发 ... -
fisheye2.2.1 & Crucible 2.2.1 安装配置笔记
2010-04-27 16:48 31771) 下载 从atlassian网站 ... -
让ivy支持maven的classifier属性
2009-10-15 01:56 3179在maven中,对于一个依赖,除了groupId,ar ... -
ivy教程(1)-目录
2009-09-21 23:57 2941学习的最佳方式是实践!这是ivy教程将帮助你做到的 ... -
ivy教程(2)-快速开始
2009-09-22 11:48 3052在这个例子中,我们将看到使用ivy的一个最简单的方 ... -
ivy教程(3)-调整默认设置
2009-09-24 20:58 2345ivy绑定一些默认 ... -
ivy教程(4)-多解析器
2009-09-25 15:28 1790这个例子演示模块是如何被多解析器获得的。使用多解析 ... -
ivy教程(5)-双重解析器
2009-09-27 20:58 1710在一些情况下,会发生这样的事情:你的模块描述符(ivy ... -
ivy教程(6)-项目依赖
2009-09-29 23:32 2999这个示例将举例说明在两个项目之间的依赖。 depen ... -
ivy教程(7)-在多项目环境下使用ivy
2009-10-03 11:48 2361在上一个教程中,你已 ... -
ivy教程(8)-使用ivy模块配置
2009-10-04 10:15 2659这个教程介绍ivy文件中的模块配置的使用。ivy模块配置事实上 ... -
ivy教程(9)-架设仓库(1)-介绍
2009-10-04 13:42 1846install任务让你从一个仓库复制一个模块或者模 ... -
ivy教程(10)-架设仓库(2)-基础仓库复制
2009-10-04 15:04 3050在这个步骤中我们使用install任务来从mave ... -
ivy教程(11)-架设仓库(3)-使用命名空间
2009-10-09 21:04 2251现在你已经看到从一个已经存在的仓库创建你自己的仓库是如何的简单 ... -
ivy教程(12)-更多例子
2009-10-09 21:29 1815如果你已经成功的跟随并理解了所有的教程,可能你还是需要得到更好 ... -
ivy中文参考文档(21)-ant任务(9)-post resolve tasks
2009-09-15 14:17 14641) post resolve tasks ... -
ivy中文参考文档(20)-ant任务(8)-cachefileset
2009-09-03 23:11 13891) cachefileset 为配置构建一个有iv ...
相关推荐
ksoap2-android-assembly-2.5.4-jar-with-dependencies - withTimeOut.jar 自己下载的2.5.4版本有webservice的timeout设置,可是没有效果, 经反编译发现只是设置了timeout的空方法。 故根据网上的方法将方法完善。 ...
本压缩包“mqtt-xmeter-syl-jar-with-dependencies.rar”包含了一个名为“mqtt-xmeter-syl-jar-with-dependencies”的文件,这很可能是一个Java应用,用于测试和分析MQTT协议的性能。 首先,我们来深入了解MQTT协议...
"restclient-ui-3.2.2-jar-with-dependencies" 是这个工具的一个特定版本,该版本包含了所有必要的依赖项,使得用户可以直接运行而无需额外安装其他库。这个版本号表明它是RESTClient的3.2.2迭代,且“jar-with-...
jmeter的dubbo插件,jmeter-plugins-dubbo-2.7.8-jar-with-dependencies.jar,适用于JMeter5.4.1版本,将解压后的文件jmeter-plugins-dubbo-2.7.8-jar-with-dependencies放在Jmeter安装目录下的\lib\ext文件夹中,...
当两者结合,如"mqtt-xmeter-2.0.2-jar-with-dependencies.zip"所示,我们可以构建出针对MQTT服务器的高效性能测试方案。 该压缩包中的核心文件"mqtt-xmeter-2.0.2-jar-with-dependencies.jar"是一个包含所有依赖的...
本文将深入探讨“jmeter-plugins-dubbo-2.7.1-jar-with-dependencies”这一系统压测工具包,它专门针对基于Java的Dubbo服务进行性能测试。了解并熟练掌握这一工具,能帮助我们更好地优化服务性能,提升系统的稳定性...
《深入解析mycat2:基于mycat2-1.21-release-jar-with-dependencies.jar的分布式数据库中间件》 mycat2是一款开源的、高性能的、基于Java开发的分布式数据库中间件,它旨在解决大数据分布式存储和处理的问题。mycat...
JrebelBrainsLicenseServerforJava-1.0-SNAPSHOT-jar-with-dependencies.jar
restclient-ui-3.6.2-SNAPSHOT-with-dependencies
"mqtt-xmeter-2.0.2-jar-with-dependencies.jar" 文件就是这样的一个扩展,它使得JMeter能够支持对MQTT协议的测试。 这个jar文件包含了所有必要的依赖,使用户无需额外安装其他库即可在JMeter中执行MQTT相关的测试...
CertificateDownloader-1.2.0-jar-with-dependencies.jar
flume-0621-0.0.1-SNAPSHOT-jar-with-dependencies.jar
Apache Ivy 是一个强大的依赖管理工具,它主要用于Java项目,但也可以与其他语言的项目配合使用。Ivy这个名字来源于“依存性解决”的英文“dependency resolver”的缩写。在Ant构建系统中,Ivy作为一个插件引入,...
jmeter-plugins-dubbo with-dependencies jmeter-plugins-dubbo-2.7.7-jar-with-dependencies.jar
log-collector-1.0-SNAPSHOT-jar-with-dependencies.jar
odps-jdbc-3.2.9-jar-with-dependencies.jar 是阿里云 MaxCompute(开放数据处理服务,ODPS)平台的 JDBC 驱动程序,专为大数据处理和分析而设计。此版本的驱动程序包含所有必要的依赖库,简化了开发人员在 Java ...
mycat2 ui(assistant-1.22-release-jar-with-dependencies-2022-5-26.jar)
spring-framework-2.5.6-with-dependencies 有点大,就打了3个包。
本文将深入探讨"jmeter-plugins-dubbo-2.7.1-jar-with-dependencies (1)"这个压缩包中的关键知识点。 1. **JMeter Plugins for Dubbo** JMeter Plugins for Dubbo 是一个扩展了JMeter功能的插件,专门用于测试基于...
clickhouse-jdbc-0.2.4-jar-with-dependencies.jar