使用蚂蚁和常春藤的可执行jar - CLASSPATH问题

时间:2017-10-13 11:04:35

标签: ant ivy manifest.mf

我试图使用常春藤管理的蚂蚁构建一个可执行的jar文件但是卡住了。我们的原始构建脚本或多或少都可以组装jar文件。依赖项位于manifest.mf中,但不在Class-Path下,而是在Compile-Class-Path条目下。

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

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

1 个答案:

答案 0 :(得分:0)

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

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

<!-- 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>
相关问题