maven2中执行Ant任务

    技术2022-05-11  75

    在maven中有完整的开发生命周期,但有时候却不能按自己的想法灵活的设置一些任务,这就想到了ANT(我想到的maven的开发者们也想到了,所以有一个maven-antrun-plugin),可以在maven中执行ant任务.        在Maven中执行ant任务有两种方法:        1、在pom.xml中直接写ANT任务    < build >      < plugins >         < plugin >          < artifactId > maven-antrun-plugin </ artifactId >          < executions >            < execution >              < phase > generate-sources </ phase >              < goals >                < goal > run </ goal >              </ goals >              < configuration >                < tasks >                  < copy  todir ="E:workspaceRB_MyFaces argetclasses" >                    < fileset  includes ="hibernate.cfg.xml"  dir ="E:workspaceRB_MyFacessrcmainjava" ></ fileset >                    < fileset  includes ="MessageResources.properties"  dir ="E:workspaceRB_MyFacessrcmainjava" ></ fileset >                  </ copy >                </ tasks >              </ configuration >            </ execution >          </ executions >        </ plugin >      </ plugins >    </ build >        2、在pom.xml中调用ANT文件        把上例中的<tasks></tasks>中的任务移到一个build.xml文件中,然后加入下面这句话 < ant  antfile ="build.xml"  target ="default"   /> 就可以执行build.xml文件中 default任务了.

    最新回复(0)