1

这是我的构建文件:

<project name="ant-in-eclipse" basedir="."
         xmlns:ant4eclipse="antlib:org.ant4eclipse"
         xmlns:antcontrib="antlib:net.sf.antcontrib" default="compileAndJar" >

  <taskdef uri="antlib:net.sf.antcontrib"
           resource="net/sf/antcontrib/antlib.xml" />

  <!-- define ant4eclipse tasks -->
  <taskdef uri="antlib:org.ant4eclipse"
           resource="org/ant4eclipse/ant/antlib.xml" />

  <import file="/data/temp/ANT/ANT4/macros/a4e-jdt-macros.xml"/>
  <target name="compileAndJar">
      <macrodef name="build">
          <attribute name="workspaceDirectory" default="deploy" />
          <sequential>
              <echo>Hi</echo>
          </sequential>
      </macrodef>

      <buildJdtProject workspaceDirectory="${workspaceDirectory}"
                       projectname="wfn-common.jar">
      <finish>
          <jar destfile="deploy/wfn-common.jar">
              <ant4eclipse:jdtProjectFileSet destination="."
               projectname="${buildJdtProject.project.name}" />
          </jar>
      </finish>
      </buildJdtProject>
   </target>
</project>

我收到此错误

/data/temp/ANT/PTO_Build/WFN_Framework/wfn-common/sample.xml:21: The following error occurred while executing this line:
/data/temp/ANT/ANT4/macros/a4e-jdt-macros.xml:105: ant4eclipse:executeJdtProject doesn't support the "workspaceid" attribute
    at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:396)
    at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:344)
    at org.apache.tools.ant.Task.maybeConfigure(Task.java:202)
    at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:196)
    at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
    at org.apache.tools.ant.Task.perform(Task.java:347)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: ant4eclipse:executeJdtProject doesn't support the "workspaceid" attribute.
    at org.ant4eclipse.ant.jdt.containerargs.JdtClasspathContainerArgumentDelegate.setDynamicAttribute(JdtClasspathContainerArgumentDelegate.java:70)
    at org.ant4eclipse.ant.jdt.AbstractExecuteJdtProjectTask.setDynamicAttribute(AbstractExecuteJdtProjectTask.java:63)
    at org.apache.tools.ant.IntrospectionHelper.setAttribute(IntrospectionHelper.java:394)
    at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:388)
    ... 31 more

谁能帮帮我?

4

1 回答 1

1

错误在您导入的文件中:

<导入文件="/data/temp/ANT/ANT4/macros/a4e-jdt-macros.xml"/>

我猜您的buildJDTProject目标是在那里定义的,并且它的定义方式存在错误。

  • 看看那个文件/data/temp/ANT/ANT4/macros/a4e-jdt-macros.xml
  • 查看第 105 行,这是您的构建失败的地方

我猜它会buildJDTProject瞄准目标。我猜目标包含workspaceid属性,这似乎是非法的。

您可以删除该属性,或弄清楚为什么首先包含它。也许它适用于您的 ant jdt 库的不同版本?

还有两个猜测(顺便说一句,我不熟悉 ant4eclipse)。关于ant4eclipse的buildJdtProject任务...

文件说

必须指定“workspaceDirectory”或“workspaceId”

您正在构建脚本中传递workspaceDirectory目标。workspaceId默认情况下,在该导入文件的宏中指定了可能。如果是这样,也许您最终会同时定义workspaceDirectoryAND workspaceId,这是非法的。但是,该想法与您收到的错误消息不匹配。

或者,也许 ant4eclipse 对属性名称是区分大小写的。这对 Ant 来说是不寻常的,它通常不区分大小写。但是 ant4eclipse 文档给出了属性名称 asworkspaceId并且您的错误消息说不workspaceid支持。因此,也许尝试更改该导入文件中的大小写。

于 2011-06-15T11:26:39.843 回答