【发布时间】:2017-03-23 07:23:59
【问题描述】:
我正在使用 IntelliJ 进行 JavaEE 应用程序开发。 Artefacts 包括 ****.gar(Coherence 应用程序),大约 5 个 *****.ear(EJB 应用程序和 Web 应用程序)。
据我了解,ant 用于构建应用程序 jar、war、ear 等。但我不打算使用 ant 来构建或重建我的应用程序,因为 IntelliJ 会以自己的方式完成。
我现在正在尝试什么?当我构建或重建我的 JavaEE 工件时,我正在尝试使用 ant 创建一个 MANIFEST.MF 文件并将其放入我的应用程序 src/META-INF/ 中。由于 IntelliJ 提供了一种方法来执行一些预处理或后处理 ant 任务,以配合 IntelliJ 构建过程。
我试图在 Internet 上找到一些示例 ant 构建代码,例如:build.xml。不幸的是,他们都在谈论创建一个 jar/ear/war 或其他包含 MANIFEST.MF 的东西。
我的问题是:有没有办法只通过 ant 创建一个 MANIFEST.MF,如果是,请分享那个 build.xml!
非常感谢!
在得到朋友@Santosh 的建议后,他评论了我的帖子。我知道它现在可以正常工作了。
XML 文件示例为:
<?xml version="1.0"?>
<project name="OzsscJPACoherence" basedir=".">
<property name="projectName" value="OzsscJPACoherence" />
<property name="libsSrc" value="libs"/>
<property name="srcDir" value="../../src"/>
<property name="artDir" value="../../../out/artifacts"/>
<property name="distDir" value="${artDir}/OzsscJPACoherence_jar"/>
<property name="build" value="build"/>
<property name="classes" value="build/classes"/>
<property name="jar" value="build/jar"/>
<property name="libs" value="build/libs"/>
<property name="version" value="2.5"/>
<tstamp>
<format property="TODAY" pattern="yyMMdd-HHmmss" locale="en,AU" />
</tstamp>
<path id="classpath">
<fileset dir="${libsSrc}" includes="*.jar"/>
</path>
<target name="jpacoh">
<mkdir dir="${distDir}/META-INF" />
<manifest file="${distDir}/META-INF/MANIFEST.MF">
<attribute name="Manifest-Version" value="1.0"/>
<attribute name="Extension-List" value="coherence active-cache"/>
<attribute name="coherence-Extension-Name" value="coherence"/>
<attribute name="active-cache-Extension-Name" value="active-cache"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Specification-Title" value="${projectName}"/>
<attribute name="Specification-Version" value="${version}"/>
<attribute name="Specification-Vendor" value="StorageWay Australia"/>
<attribute name="Implementation-Title" value="${projectName}"/>
<attribute name="Implementation-Version" value="${version} ${TODAY}"/>
<attribute name="Implementation-Vendor" value="StorageWay Australia"/>
</manifest>
<jar manifest="${distDir}/META-INF/MANIFEST.MF" jarfile="${distDir}/OzsscJPACoherence.jar"/>
</target>
</project>
并将ant任务添加到相关模块作为预处理任务,重建工件。 MANIFEST.MF 已正确创建。
希望这个帖子能帮助遇到同样情况的其他人。
谢谢大家帮忙!
【问题讨论】:
标签: java intellij-idea ant build manifest