添加多个jar文件罐类路径 [英] Adding multiple jar files to class path of jar

查看:180
本文介绍了添加多个jar文件罐类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Maven的antrun-插件做几件事情要经过包装的单一部署构件。不过,我使用的封装使关于它自己的插件不属于任何存储库的类路径的几个假设。我已经尝试添加插件文件到罐子,没有成功。我的下一步是让插件所在的文件夹旁边的结构如下jar文件:

I'm using the maven-antrun-plugin to do several things to a single deployable artifact after packaging. However, the package I'm using makes several assumptions about the class path of its own plugins which are not in any repository. I've tried adding the plugin files to the jar, with no success. My next step is to let the plugins reside in a folder next to the jar file with the following structure:

    .
    nutch2handler.jar
    plugins/
        plugin1/plugin1.jar
        plugin2/plugin2.jar
        plugin3/plugin3.jar
        etcetcetc

antrun做包装各种工件(JAR,插件,WWW,shell脚本等)后,它增加了一些配置的罐子上述同样的原因的根源,这部作品在这种情况下。我知道我可以创建一个属性容纳包括我要添加到类路径路径的字符串,但我不想在键入所有这些20+插件到该属性,如插件内容可能会有所不同。我如何递归这些jar文件添加到类路径?

After antrun is done packaging the various artifacts(jar, plugins, www, shell scripts etc), it adds some configuration to the root of the jar for the same reason as above, and this works in this case. I know I can create a property hold a string containing a path I want to add to the classpath, but I don't want to type in all of these 20+ plugins into that property, as the plugin content may vary. How do I recursively add these jar files to that class-path?

我目前有

    <property name="jar.class.path" value="" />

在我的目标配置,并且要插入像这样以

In my target configuration, and want to insert something like this with

    <attribute name="Class-Path" value="${jar.class.path}"/>

瓶子标签中。

推荐答案

如果您nutch2handler.jar和所有其他pluigns在文件夹名为lib目录

If your nutch2handler.jar and all other pluigns are in folder named "lib":

您可以定义类似下面所有的递归jar添加到类路径中:

you can define something like below to add all recursive jars to your classpath:

<path id="jar.class.path">
  <fileset dir="lib">
    <include name="**/*.jar" />
  </fileset>
</path>

然后你可以使用&LT;类路径REFID =jar.class.path/方式&gt; 来引用该属性在以往必要

and then you can use <classpath refid="jar.class.path" /> to refer to the property where ever necessary.

这篇关于添加多个jar文件罐类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆