Ant not loading salesforce task definitions?

拥有回忆 提交于 2019-12-07 08:21:58

问题


The Question

I'm trying to use the Force.com Migration Tool (a custom ant library) on a linux box and can't for the life of me figure out how to get ant to see that library. What am I doing wrong?

The Error Message

BUILD FAILED
/home/ec2-user/ant/ucp/build.xml:48: Problem: failed to create 
task or type antlib:com.salesforce:retrieve
Cause: The name is undefined.

The Background

I installed ant using yum install ant and then I dropped the Force.com Migration Tool (ant-salesforce.jar) into /usr/share/ant/lib. I'm able to see this library when I run ant -diagnostics, but none of the tasks for that library (should be seeing deploy, retrieve, etc.). I've uploaded a gist with the full output from ant -diagnostics.

-------------------------------------------
 ANT_HOME/lib jar listing
-------------------------------------------
ant.home: /usr/share/ant
ant-bootstrap.jar (19837 bytes)
ant-salesforce.jar (3293054 bytes)
ant.jar (1942059 bytes)
ant-launcher.jar (18418 bytes)

After lots of googling and manual reading I tried the following to no avail (NB: the above diagnostics is without any of the below changes). I know I'm missing something obvious :(

  1. Setting $ANT_HOME export ANT_HOME=/usr/share/ant
  2. Fiddling with permissions chmod +x /usr/share/ant/lib/salesforce-jar
  3. Fiddling with groups chown root:root /usr/share/ant/lib/salesforce-jar
  4. Passing in class with -lib ant -lib /usr/share/ant/lib/salesforce-jar retrieve ...
  5. Passing in lib folder with -lib ant -lib /usr/share/ant/lib retrieve ...
  6. Adding $ANT_HOME to $PATH export PATH=$PATH:$ANT_HOME/bin

回答1:


How about keeping ant-salesforce.jar under /home/ec2-user/ant/ucp and then change the taskdef element to look like this:

<taskdef resource="com/salesforce/antlib.xml" classpath="ant-salesforce.jar" />

Run your build again and see if things look better. Having the JAR in the same folder as build.xml will help you eliminate issues with permissions.




回答2:


Based on @smooth_reggae's answer was able to get things working while keeping ant-salesforce.jar in the default ant lib directory. Seems like this should already be happening, but oh-well.

<taskdef resource="com/salesforce/antlib.xml"
    classPath="${ant.library.dir}/ant-salesforce.jar"
    uri="antlib:com.salesforce"/>


来源:https://stackoverflow.com/questions/16379247/ant-not-loading-salesforce-task-definitions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!