eclipse - Ant 移动将换行符放在属性末尾

标签 eclipse ant

我在 Eclipse 中有一个 Ant 任务来从文件获取版本:

<loadfile property="version" srcfile="version.txt">
  <filterchain>
    <linecontainsregexp>
      <regexp pattern="^#define version .(\d{1,10})\.(\d{1,10})\.(\d{1,10})\.(\d{1,10})."/>
    </linecontainsregexp>
    <replaceregex 
         pattern="^#define version .(\d{1,10})\.(\d{1,10})\.(\d{1,10})\.(\d{1,10})..*$" 
         replace="\1.\2.\3.\4" />
  </filterchain>
</loadfile>  
<echo message="Version ${version}"/>    

版本显示时不带换行符。在代码中,我想将该属性与移动任务一起使用:

<move file="${dir}\file.exe"
      tofile="${outputdir}\output-${version}-xxx.exe" 
      overwrite="true" 
      force="true" />

但是失败并显示消息

BUILD FAILED build.xml:26: Failed to copy path\file.exe to path\output_directory\output-1.0.0.0
-xxx.exe due to output-1.0.0.0
-xxx.exe (Název souboru či adresáře nebo jmenovka svazku je nesprávná)

(最后一行表示文件名无效,显然中间包含换行符)。

我哪里出错了?是特性本身吗?甚至添加行

<replaceregex pattern="&#10;" replace="" flags="s"/>    

或从属性中删除换行符的其他尝试没有改变任何内容。

最佳答案

您需要strip line breaks ,例如:

<filterchain>
  <linecontainsregexp ... />
  <replaceregex ... />

  <striplinebreaks />

</filterchain>

如果您修改您的<echo>至:

<echo message="Version -${version}-"/>

您会清楚地看到效果。

关于eclipse - Ant 移动将换行符放在属性末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16305671/

相关文章:

eclipse - Eclipse 中的 Liferay 开发

grails - ant 的 componentdef 错误

linux - Ant 中的 Exec 命令只执行第一个命令

java - Subversive 导致 Eclipse 不同步?

eclipse - Play框架+Eclipse : undefined method for ReverseApplication

java - 如何在 Jenkins 中执行 Selenium 2 测试

java - 哪些包被编译到 gnumail-providers.jar 中,JAR 的依赖项是什么?

Java 实现的 rpmbuild 工具的等价物?

java - 如何解决 'UnsatisfiedLinkError' - java.library.path 中没有 rxtxSerial - 在 JArduino 中?

eclipse - 如何刷新 FilteredItemsSelectionDialog