使用ant创建ear文件
我是 ant 的新手,我提到了很多网站,我需要为我的项目构建 build.xml,其中包括 在两个模块中,我有 application.xml 文件,它代表相应的 war 文件
,所以我的问题是添加 application.xml 文件就足够了,
<ear destfile="${dist.dir}/${ant.project.name}.ear" appxml="${conf.dir}/application.xml">
<metainf dir="${build.dir}/META-INF"/>
<fileset dir="${dist.dir}" includes="*.jar,*.war"/>
</ear>
这是否会引用相应的 war 文件,或者我需要编译整个场景,请告诉我。怎么解决这个问题。
I am new to ant i referred many sites , i need to build.xml for my project which consists
of two modules i have application.xml file which represents corresponding war file
so my question is it sufficient to add the application.xml file
<ear destfile="${dist.dir}/${ant.project.name}.ear" appxml="${conf.dir}/application.xml">
<metainf dir="${build.dir}/META-INF"/>
<fileset dir="${dist.dir}" includes="*.jar,*.war"/>
</ear>
whether this will refer the corresponding war files or i need to compile the whole scenario please let me know. how solve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是 100% 确定你在问什么。
为了使用
任务,您需要编译所需的 jar 和 wars。如果这些 jars 和 wars 已经构建,您只需在
任务中引用它们,就像在示例中所做的那样。在构建 Ear 之前,application.xml
必须已经存在。application.xml
不会构建 jars 和 wars,你必须这样做。如果您还没有构建 wars 和 jars,则需要先这样做。
build.xml
的总体轮廓如下所示:基本上,它由一堆目标组成,每个目标执行一项任务。您可以让目标依赖于其他目标。例如,这个特定的
build.xml
将自动运行package
任务。 package 任务依赖于package.jar
任务,而package.jar
任务又依赖于compile
任务。因此,build.xml
文件将首先调用compile
,然后调用package.jar
,最后调用package
。需要记住的重要一点是,您没有指定事件的顺序。你让 Ant 弄清楚这一点,你也让 Ant 弄清楚你需要做什么。假设您修改了 java 源文件。 Ant 知道它只需重新编译该一个文件。它还知道可能必须重建包含该类文件的 jar 文件。然后它知道必须重建耳朵。大多数任务可以自行解决,并且您不必为每个构建执行
clean
。 (您会注意到clean
目标不是由package
或compile
调用的。您必须手动调用它)。我唯一建议的另一件事是尽量保持工作区域清洁。您创建的任何文件都应放入
${target.dir}
目录中。这样,当您执行clean
时,您只需删除该一个目录。我希望这能回答你的问题。
I'm not 100% sure what you're asking.
In order to use the
<ear>
task, you already need to have compiled the required jars and wars.If those jars and wars have already been built, you simply refer to them in your
<ear>
task as you did in your example. Theapplication.xml
must already exist before you build your ear. Theapplication.xml
doesn't build the jars and wars, you have to do that.If you haven't already built the wars and jars, you need to do that first. A general outline of a
build.xml
looks something like this:Basically, it consists of a bunch of targets and each target does one task. You can have targets depend upon other targets. For example, this particular
build.xml
will automatically run thepackage
task. The package task depends upon thepackage.jar
task which depends upon thecompile
task. Thus, thebuild.xml
file will first callcompile
, thenpackage.jar
, thenpackage
.The important thing to remember is that you don't specify the order of the events. You let Ant figure that out, and you let Ant figure out what you need to do. Let's say you've modified a java source file. Ant knows that it has to recompile only that one file. It also knows that it might have to rebuild the jarfile that contains that classfile. And, it then knows it has to rebuild the ear. Most tasks can figure it out on their own, and you don't do a
clean
for each build. (You notice that theclean
target isn't called bypackage
orcompile
. You have to call it manually).The only other thing I recommend is that you try to keep your work area clean. Any files you create should be put into the
${target.dir}
directory. That way, when you do aclean
, you only have to delete that one directory.I hope this answer your question.