Java IntelliJ生成的Ant build会覆盖我的MANIFEST.MF

Java IntelliJ生成的Ant build会覆盖我的MANIFEST.MF,java,intellij-idea,ant,Java,Intellij Idea,Ant,我在IntelliJ中有一个简单的项目,在那里我转到项目结构->工件->从具有依赖项的模块添加Jar->复制到输出目录,并通过清单链接(清单放在%ProjectDir%/resources/manifests/META-INF/manifest.MF)->确定->确定 现在,如果我运行make,jar将被放置在out/artifacts下,如果我查看jar内部并打开META-INF/MANIFEST.MF文件,它将包含正确的类路径信息。如果我随后返回IntelliJ,生成一个ant构建并运行它,

我在IntelliJ中有一个简单的项目,在那里我转到项目结构->工件->从具有依赖项的模块添加Jar->复制到输出目录,并通过清单链接(清单放在%ProjectDir%/resources/manifests/META-INF/manifest.MF)->确定->确定

现在,如果我运行
make
,jar将被放置在
out/artifacts
下,如果我查看jar内部并打开META-INF/MANIFEST.MF文件,它将包含正确的类路径信息。如果我随后返回IntelliJ,生成一个ant构建并运行它,那么编译的jar中META-INF/MANIFEST.MF的内容现在如下所示:

清单版本:1.0
Ant版本:ApacheAnt1.9.4
创建人:1.7.0_80-b15(Oracle公司)

如您所见,
类路径
条目已被完全删除,这使我无法从其他地方使用jar

所以我的问题是:有人知道为什么intellij生成的ant构建会覆盖intellij中内置的
make
功能使用的MANIFEST.MF吗

我还可以补充一点,我之所以生成这个ant构建,是因为我想做一些简单的事情,比如编译后将构建的jar复制到不同的位置

编辑


如果我手动将生成的ant脚本中的
更改为
,则至少原始MANIFEST.MF中的
类路径会出现在复制到jar文件中的MANIFEST.MF中。但是,我确实希望避免以这种方式手动更改生成的ant脚本。

您需要使用-m选项。要查看可用JAR选项的列表,请键入不带参数的JAR,输出将提供参数列表和示例。在您的情况下,您可能需要修改一些Ant或IntelliJ命令,以使用提供的MANIFEST.MF文件生成JAR

Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
Options:
    -c  create new archive
    -t  list table of contents for archive
    -x  extract named (or all) files from archive
    -u  update existing archive
    -v  generate verbose output on standard output
    -f  specify archive file name
    -m  include manifest information from specified manifest file
    -e  specify application entry point for stand-alone application
        bundled into an executable jar file
    -0  store only; use no ZIP compression
    -P  preserve leading '/' (absolute path) and ".." (parent directory) components from file names
    -M  do not create a manifest file for the entries
    -i  generate index information for the specified jar files
    -C  change to the specified directory and include the following file
If any file is a directory then it is processed recursively.
The manifest file name, the archive file name and the entry point name are
specified in the same order as the 'm', 'f' and 'e' flags.

Example 1: to archive two class files into an archive called classes.jar:
       jar cvf classes.jar Foo.class Bar.class
Example 2: use an existing manifest file 'mymanifest' and archive all the
           files in the foo/ directory into 'classes.jar':
       jar cvfm classes.jar mymanifest -C foo/ .

我真的无法在IntelliJ中找到一个地方来包含这个我afraid@MartinRindarøy可能有帮助: