NAnt:返回/设置对象集合的任务?

发布于 2024-10-15 14:35:43 字数 588 浏览 8 评论 0原文

我想通过添加 p4 标签NAntContrib 的 Perforce 任务集> 任务。

p4labels 任务必须返回标签集合,甚至理想情况下,返回标签信息集合:名称、日期/时间、描述。

查看 NAntContrib 的其他调用代码 (p4info< /a> 例如),看起来从任务返回简单字符串相当容易,但我还没有找到返回标签集合的方法。例如,潜在的用途是稍后将此集合传递给函数以获取集合中的最新标签,或传递给 foreach 任务以迭代以处理集合中的每个标签。

这在 NAnt 中可能吗?从我所看到的来看,您似乎可以声明集合和集合,但不能从任务或函数中返回它们。

作为记录,我声明了一个 LabelInfo NAnt 类型以及一个 LabelInfoCollection,但实际上我不知道如何从任务中返回一个类型。

欢迎任何提示。

I'd like to augment NAntContrib's set of Perforce tasks by adding the p4 labels task.

The p4labels task would have to return a collection of labels, or even ideally, a collection of label info: name, date/time, description.

Looking into NAntContrib's code for other call (p4info for example), it looks like it's rather easy to return simple strings from a task, but I've not managed to find a way to return a collection of labels. A potential use would be to later pass this collection to a function to get the latest label in the collection or to a foreach task to iterate over to deal with each within the collection, for example.

Is this even possible in NAnt? From all I've seen, it seems you can declare sets and collections, but not return them from a task or a function.

For the record, I've declared a LabelInfo NAnt type as well as a LabelInfoCollection, but really I don't know how I would return one from a task.

Any tips are welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ㄖ落Θ余辉 2024-10-22 14:35:43

查看 NAntContribsql task 处理返回一组值的策略,似乎解决方案是将数据存储在文件并将该文件传递给需要数据的任何函数或任务。

然后可以将其传递到文件 foreach< /code> 任务可以迭代 。以 CSV 格式存储的数据非常容易解析:

<p4labels user="bob" filter="*VerifiedBuild*" max=100 output="myfile.csv" />
<foreach item="Line" in="myfile.csv" delim="," property="label,date,comment">
  <echo message="Label: ${label} Created on: ${date}   -   ${comment}" />
</foreach>

Looking at NAntContrib's sql task's strategy to deal with returning a set of values, it seems a solution would be to store the data in a file and pass that file to whatever function or task requiring the data.

It'd then possible to pass this to file to a foreach task that can iterate over the lines in the file. Data stored in CSV format is very easy to parse:

<p4labels user="bob" filter="*VerifiedBuild*" max=100 output="myfile.csv" />
<foreach item="Line" in="myfile.csv" delim="," property="label,date,comment">
  <echo message="Label: ${label} Created on: ${date}   -   ${comment}" />
</foreach>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文