首页 文章

使用 Ant 和常 Spring 藤的可执行jar - CLASSPATH问题

提问于
浏览
0

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

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

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

1 回答

  • 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>
    

相关问题