包括Java库到自己的图书馆 [英] Include java libraries into own library
问题描述
我创造了我自己一点点的框架,我想在多个项目中使用。我也想了分布式的jar文件包含所有外部库,使我的项目只需要包含我的媒体库访问所有外部库。
I created a little framework for myself which I want to use in multiple projects. I also want the distributed jar-file to include all external libraries so that my projects just need to include my library to access all external libraries.
我需要这简化更新的外部库。
I need this to simplify updating the external libraries.
所以我把这个在我的build.xml它增加了所有的库从DIST / lib放到我自己的jar文件。
So I placed this in my build.xml which adds all libraries from dist/lib into my own jar-file.
<target name="-post-jar">
<!-- Include all java libraries -->
<fileset dir="dist/lib" id="extern.libs">
<include name="*.jar" />
</fileset>
<!-- Add the libraries from the fileset to the project.jar -->
<jar jarfile="${dist.jar}" update="true">
<zipgroupfileset refid="extern.libs"/>
</jar>
</target>
但是,当我尝试使用外部库,如与org.zkoss.zk.ui.Component我得到这个库未能发现错误。
But when I try to use external libraries like "org.zkoss.zk.ui.Component" I get the error that this library could not be found.
有没有更好的办法,包括外部库到我自己的图书馆,这样我的项目使用它们?
Is there a better way to include the external libraries into my own library so that my project can use them?
推荐答案
您可以发布的Maven 神器,这那么你的架构的用户都可以使用,而不必包含依赖自己 - 你的POM是足够的。
You can publish a Maven artifact, which users of your framework can then use without having to include the dependencies yourself--your pom is enough.
如果你想创建一个全合一的神器,可以考虑像 OneJar 或 jarjar 或Maven的的阴影插件来创建一个没有外部依赖的JAR。
If you want to create an "all-in-one" artifact, consider something like OneJar or jarjar or Maven's Shade plugin to create a jar that has no external dependencies.
这篇关于包括Java库到自己的图书馆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!