在创建ear文件之前复制整个目录 [英] Copy entire directory before creating an ear file

查看:78
本文介绍了在创建ear文件之前复制整个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过一个蚂蚁脚本构建一个耳朵文件.有几个目标可以使用不同的项目来创建.jar和.war(将包含在耳朵中)文件,这些目标的构建没有问题,因此我将不包括它们.

I am trying to build an ear file from an ant script. There are several targets that create .jar and .war (to be contained within the ear) files using different projects and these are building without issue so I will not include them.

想象一下这个目录结构:-

Imagine this directory structure:-

Project1/
  build/ 
  lib/
  META-INF/
  build.xml

因此,当调用ant脚本时,将删除并重新构建构建目录,所有这些都是标准的东西.然后我从外部项目创建jar和war,并将它们存储在build/中-一切都很好.

So when the ant script is called the build directory is deleted and remade, all fairly standard stuff. Then I create the jar's and war's from external projects and store them in build/ - everything is fine.

但是我还想在耳文件中包含目录lib/和META-INF/.因此,我尝试使用此目标将它们复制到构建目录.

But I also want to include the directories lib/ and META-INF/ in the ear file. So I try to copy them to the build directory using this target.

<target name="file_cleanup">
    <copy todir="${build}">
        <fileset dir="lib/"/>
        <fileset dir="META-INF/"/>
    </copy>
</target>

此file_cleanup目标是创建耳朵的默认构建目标的依赖项,如下所示:

This file_cleanup target is a dependant of the default build target which creates the ear - shown below:

   <target name="ear" depends="initialise, file_cleanup, other targets...">
        <ear destfile="My.ear" appxml="META-INF/application.xml">
            <fileset dir="${build}" includes="*.jar,*.war"/>
        </ear>
    </target>

当我拔出耳朵时,我想看到的是:

What I want to see when I extract the ear is:

target1.jar
target2.war
lib/
META-INF/

但是我实际上得到的是:

But what I actually get is:

target1.jar
target2.war
and all of the contents of both the lib and META-INF directories...

推荐答案

我能够通过创建其他属性和目录并将目录结构复制到新目录来解决此问题:

I was able to resolve this issue by creating additional properties and directories and copying the directory structures to the new directories:

<target name="initialise">
    <delete dir="${build}"/>
    <mkdir dir="${build}"/>
    <mkdir dir="${build}/${lib}"/>
    <mkdir dir="${build}/${meta-inf}"/>
</target>


    <target name="file_cleanup">
        <copy todir="${build}/${lib}">
            <fileset dir="lib"/>
        </copy>
        <copy todir="${build}/${meta-inf}">
            <fileset dir="META-INF"/>
        </copy>
    </target>

这篇关于在创建ear文件之前复制整个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆