【问题标题】:executable jar using ant and ivy - CLASSPATH issues使用 ant 和 ivy 的可执行 jar - CLASSPATH 问题
【发布时间】:2018-03-25 12:05:18
【问题描述】:

我正在尝试使用由 ivy 管理的 ant 构建可执行 jar 文件,但被卡住了。我们最初的构建脚本或多或少地组装了 jar 文件。依赖项在 manifest.mf 中,但不在 Class-Path 下,而是在 Compile-Class-Path 条目下。

我可以简单地在清单文件中设置 Main-Class 条目,但在尝试获取 Class-Path 中的 ivy 依赖项时遇到了一个不可能的敌人。虽然使用 gradle 看起来很简单,但我找不到任何常春藤依赖项的解决方案。

有没有办法获得解决常春藤依赖项并将它们放在清单中?这些依赖项只是 jar 文件所在的网络位置的路径。

【问题讨论】:

    标签: ant ivy manifest.mf


    【解决方案1】:

    我给出了一个标准的方法来做到这一点。如果您可以提供您的实际构建文件,我可以在答案中更具体。

    您可以在 ant 目标中执行此操作以创建 jar。例如:

    <!-- create a classpath variable with all the jars needed for runtime -->
    <path id="cls.path">
       <!-- declare all the paths that you need. For ex: all resolved jars in "runtime" conf --> 
    </path>
    <!-- If your path has folder prefix, you'll have to do <pathconvert> -->
    <jar jarfile="${jar_name}" basedir="${classes.dir}">
       <manifest>
          <attribute name="Class-Path" value="${cls.path}"/>
          ...
          <!-- You can add standard jar properties and any custom property here -->
       </manifest>
    </jar>
    

    【讨论】:

    • 是的,我知道的很多,但我感兴趣的部分是:
    猜你喜欢
    • 2011-11-08
    • 2011-12-07
    • 2018-02-24
    • 2011-06-26
    • 2012-04-24
    • 2014-08-30
    • 2011-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多