【问题标题】:How add antlib declaration to project in eclipse?如何将antlib声明添加到eclipse中的项目?
【发布时间】:2015-08-14 12:36:21
【问题描述】:

我创建了一个名为“antt”的项目,以使用来自 Eclipse 的迁移工具来测试 ant。 我在eclipse中创建了java项目并尝试从那里运行“test”。

build.xml 中的“测试”:

 <!-- Test out deploy and retrieve verbs for package 'mypkg' -->
    <target name="test">
      <!-- Upload the contents of the "mypkg" package -->
      <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="mypkg" rollbackOnError="true"/>
      <mkdir dir="retrieveOutput"/>
      <!-- Retrieve the contents into another directory -->
      <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="unpackaged" packageNames="MyPkg"/>
    </target>

错误:

Buildfile: C:\SF\workspacenew\antt\build.xml test:

BUILD FAILED C:\SF\workspacenew\antt\build.xml:19: Problem: failed to create task or type antlib:com.salesforce:deploy Cause: The name is undefined.  Action: Check the spelling.  Action: Check that any custom tasks/types have been declared.  Action: Check that any <presetdef>/<macrodef> declarations have taken place. No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration.  Action: Check that the implementing library exists in one of:
        -C:\eclipse\plugins\org.apache.ant_1.8.4.v201303080030\lib
        -C:\Users\User\.ant\lib
        -a directory added on the command line with the -lib argument


Total time: 560 milliseconds

【问题讨论】:

    标签: eclipse ant sfdc-migration-tool


    【解决方案1】:

    参考我对here的回答,

    1. 在项目根目录下创建一个 lib 目录,并将 maven-ant-tasks.jar 文件放入其中。
    2. 在您的 build.xml 中包含导入语句

      <path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
      <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />
      

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-16
      • 1970-01-01
      • 2011-06-06
      • 1970-01-01
      • 2018-08-22
      • 2015-05-17
      • 1970-01-01
      相关资源
      最近更新 更多