bash Ant 未加载 Salesforce 任务定义?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16379247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 05:21:29  来源:igfitidea点击:

Ant not loading salesforce task definitions?

bashantsalesforce

提问by Ralph Callaway

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?

我正在尝试在 linux 机器上使用 Force.com 迁移工具(一个自定义 ant 库),但终生无法弄清楚如何让 ant 看到该库。我究竟做错了什么?

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 antand 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 gistwith the full output from ant -diagnostics.

我使用安装了 ant yum install ant,然后将 Force.com 迁移工具 (ant-salesforce.jar) 放入/usr/share/ant/lib. 我可以在运行时看到这个库ant -diagnostics,但没有看到该库的任何任务(应该看到部署、检索等)。我已经上传了一个包含完整输出的要点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. 设置 $ANT_HOME export ANT_HOME=/usr/share/ant
  2. 摆弄权限 chmod +x /usr/share/ant/lib/salesforce-jar
  3. 摆弄团体 chown root:root /usr/share/ant/lib/salesforce-jar
  4. 使用 -lib 在课堂上传递 ant -lib /usr/share/ant/lib/salesforce-jar retrieve ...
  5. 使用 -lib 传入 lib 文件夹 ant -lib /usr/share/ant/lib retrieve ...
  6. 将 $ANT_HOME 添加到 $PATH export PATH=$PATH:$ANT_HOME/bin

回答by smooth reggae

How about keeping ant-salesforce.jarunder /home/ec2-user/ant/ucpand then change the taskdefelement to look like this:

如何保持ant-salesforce.jar下方/home/ec2-user/ant/ucp然后将taskdef元素更改为如下所示:

<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.xmlwill help you eliminate issues with permissions.

再次运行您的构建,看看情况是否更好。将 JAR 放在同一文件夹build.xml中将帮助您消除权限问题。

回答by Ralph Callaway

Based on @smooth_reggae's answerwas 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.

根据@smooth_reggae 的回答,能够在将 ant-salesforce.jar 保留在默认 ant lib 目录中的同时使事情正常进行。看起来这应该已经发生了,但是哦,好吧。

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