在ant build -Error中使用ant1.7.1.jar作为外部库

时间:2014-05-08 03:38:30

标签: ant

我的ant版本是ANT1.6,这是Appserver自定义版本n,它定义了一些AppServer特定的自定义任务,它阻止我升级ANT,因为它与AppServer升级紧密结合,我们要求用户通过我必须检查文件列表是否存在于目标位置,如果它们存在则删除它们,如果它们不存在则抛出构建失败错误。经过一些故障排除后我决定使用ANT1.7作为外部库,下面是我的代码片段,用于验证文件是否存在

  <target name="validate.file" depends="defineResource,validate.dir">
    <echo message = " The Filelist is : ${file.list} "/>
    <condition property="is.missing">
      <resourcecount when="ne" count="0">
        <difference id="is.missing">
          <intersect>
            <filelist id="required" dir="${target.location}" files="${file.list}"/>
            <fileset id="existing" dir="${target.location}" includes="*.*"/>
          </intersect>
          <filelist refid="required"/>
        </difference>
      </resourcecount>
    </condition>
    <fail if="is.missing" message= " File ${toString:missing} is missing from the list of files provided for removing, please recheck and submit correct "/>
  </target>

我正在使用taskdef来加载ANT1.7.1.jar并尝试下面的代码片段

1方法

  <target name = "defineResource">
    <echo message = "Present in Resource Class "/>
    <taskdef name="resourcecount" classname="org.apache.tools.ant.taskdefs.ResourceCount">
      <classpath>
         <pathelement location="/jass/deploy-process/deploy-engine/build/lib/apache-ant-1.7.1.jar"/>
      </classpath>
    </taskdef>
    <taskdef name="difference" classname="org.apache.tools.ant.types.resources.Difference">
      <classpath>
          <pathelement location="/jass/deploy-process/deploy-engine/build/lib/apache-ant-1.7.1.jar"/>
      </classpath>
    </taskdef>
    <taskdef name="intersect" classname="org.apache.tools.ant.types.resources.Intersect">
      <classpath>
          <pathelement location="/jass/deploy-process/deploy-engine/build/lib/apache-ant-1.7.1.jar"/>
      </classpath>
    </taskdef>
  </target>

第二种方法

  <target name = "defineResource">
    <echo message = "Present in Resource Class "/>
    <taskdef name="resourcecount" classname="org.apache.tools.ant.taskdefs.ResourceCount,org.apache.tools.ant.types.resources.Difference,org.apache.tools.ant.types.resources.Intersect">
      <classpath>
         <pathelement location="/jass/deploy-process/deploy-engine/build/lib/apache-ant-1.7.1.jar"/>
      </classpath>
    </taskdef>
  </target>
  <target name = "defineDifference">
    <echo message = "Present in Difference Class "/>
    <taskdef name="difference" classname="org.apache.tools.ant.types.resources.Difference">
      <classpath>
          <pathelement location="/jass/deploy-process/deploy-engine/build/lib/apache-ant-1.7.1.jar"/>
      </classpath>
    </taskdef>
  </target>
  <target name = "defineIntersect">
    <echo message = "Present in Intersect Class "/>
    <taskdef name="intersect" classname="org.apache.tools.ant.types.resources.Intersect">
      <classpath>
          <pathelement location="/jass/deploy-process/deploy-engine/build/lib/apache-ant-1.7.1.jar"/>
      </classpath>
    </taskdef>
  </target>

但是我使用Taskdef的方法都没有用,他们正在抛出构建失败错误

类org.apache.tools.ant.types.resources.Difference中没有公共execute()

类org.apache.tools.ant.types.resources.Intersect中没有公共execute()

我真的很困惑如何解决这个问题,如果我正在采取正确的方法,请告诉我,否则,如果有任何其他方式可以实现我从文件列表中搜索文件的实际要求。

0 个答案:

没有答案