简体   繁体   English

您可以将 ANT 构建文件用作 Phing 构建文件吗?

[英]Can you use an ANT build file as a Phing build file?

I just started playing around with Phing build scripts (built with PHP).我刚开始玩Phing构建脚本(用 PHP 构建)。 From what I have read is that Phing is based on Apache Ant (built with Java).据我所知,Phing 基于Apache Ant (用 Java 构建)。

Both use XML build files and have similar syntax, so I am asking someone with experience, if I find an Ant build file on Github or elsewhere, can it be used in a Phing script without changing the syntax of it any?两者都使用 XML 构建文件并且具有相似的语法,所以我问有经验的人,如果我在 Github 或其他地方找到 Ant 构建文件,是否可以在 Phing 脚本中使用它而不改变它的语法? Like a drop-in XML file that would work with Ant or Phing?就像可以与 Ant 或 Phing 一起使用的插入式 XML 文件? Or are there differences?还是有区别?

There are some slight differences.有一些细微的差异。 I would recommend taking the ant build file, and for each target, look up the target name in the phing documentation to make sure it's the same or not.我建议使用 ant 构建文件,对于每个目标,在 phing 文档中查找目标名称以确保它相同或不同。 I can't remember off the top of my head, but you can't just drop it in. There are also some phing only things you can do that are php related, like a phpdoc target, etc.我不记得我的头顶,但你不能把它放进去。 还有一些你可以做的与 php 相关的 phing 事情,比如 phpdoc 目标等。

I were recently facing the same issue and I found some diff :我最近面临同样的问题,我发现了一些差异:

  • antcall would be phingcall antcall将是phingcall
  • <if> tag only appear to be working on PHING (or with Ant-contribs library added) <if>标签似乎只在 PHING 上工作(或添加了Ant- contribs
  • <fixcrlf> tag only appear to be working on ANT <fixcrlf>标签似乎只在 ANT 上工作

Maybe there are some others.也许还有其他一些。

SOLUTION解决方案

The best solution for me was to rewrite missing tasks using adhocTask .对我来说最好的解决方案是使用adhocTask重写丢失的任务。 And if it is possible, based on an existing PhingTask.如果可能的话,基于现有的 PhingTask。

For example to make <antcall> to work, I simply extends PhingCallTask like this :例如,为了使<antcall>工作,我只是像这样扩展PhingCallTask

<adhoc-task name="antcall"><![CDATA[
  class AntCall extends PhingCallTask {}
]]></adhoc-task>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM