由于路径中的空间,Phing任务失败

时间:2013-12-10 10:59:19

标签: phing

当尝试将php代码嗅探器日志写入包含空格的路径时,我收到此错误:

[exec] ERROR: The file "calendar/build/checkstyle-codesniffer.xml" does not exist.

该文件的完整路径为/home/jenkins/ci/workspace/full calendar/build/checkstyle-codesniffer.xml

我尝试将报告文件包装在单引号中,例如--report-file='${project.basedir}/build/checkstyle-codesniffer.xml'

但这只是将错误更改为此

[exec] ERROR: The file "/home/jenkins/ci/workspace/full" does not exist.

analyze-phpcs目标:

<target name="analyze-phpcs" depends="prepare">
  <exec command="phpcs --report=checkstyle --report-file=${project.basedir}/build/checkstyle-codesniffer.xml --standard=Drupal --extensions=php,module,install,inc,profile,test --ignore=*/contrib/*,*/development/*,*.features.*,*.field_group.*,*.layouts.*,*.pages_default.*,*.panelizer.*,*.panels_default.*,*.strongarm.*,*.views_default.* ${project.basedir}" logoutput="true" />
</target>

prepare目标:

<patternset id="php">
  <include name="**/*.php" />
  <include name="**/*.module" />
  <include name="**/*.install" />
  <include name="**/*.inc" />
  <include name="**/*.profile" />
  <include name="**/*.test" />
</patternset>

<patternset id="generated">
  <exclude name="**/*.features.*" />
  <exclude name="**/*.field_group.inc" />
  <exclude name="**/*.layouts.inc" />
  <exclude name="**/*.pages_default.inc" />
  <exclude name="**/*.panelizer.inc" />
  <exclude name="**/*.panels_default.inc" />
  <exclude name="**/*.strongarm.inc" />
  <exclude name="**/*.views_default.inc" />
</patternset>

<patternset id="contrib">
  <exclude name="**/contrib/**/*.*" />
  <exclude name="**/development/**/*.*" />
  <exclude name="**/libraries/**/*.*" />
</patternset>

<fileset id="src.php" dir="${project.basedir}">
  <patternset refid="php"/>
  <patternset refid="generated"/>
  <patternset refid="contrib"/>
</fileset>

有解决方法吗?或者我只是做错了?

1 个答案:

答案 0 :(得分:0)

我发现了错误。当我在reportFile参数周围添加单引号时它起作用,错误输出与最后一个参数(要分析的文件)有关。

所以解决方案是在这个参数中添加单引号:

phpcs --report=checkstyle --report-file='${project.basedir}/build/checkstyle-codesniffer.xml' --standard=Drupal --extensions=php,module,install,inc,profile,test --ignore=*/contrib/*,*/development/*,*.features.*,*.field_group.*,*.layouts.*,*.pages_default.*,*.panelizer.*,*.panels_default.*,*.strongarm.*,*.views_default.* '${project.basedir}'