Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant中的条件令牌替换_Ant - Fatal编程技术网

Ant中的条件令牌替换

Ant中的条件令牌替换,ant,Ant,我试图在Ant构建文件中进行令牌替换,但前提是该令牌位于具有特定内容的行中 文件中的样例实体模型片段: <script type="text/javascript" src="scripts/someFolder/someFile1.js"></script> <script type="text/javascript" src="scripts/otherFolder/fileName.js"></script> <script type=

我试图在Ant构建文件中进行令牌替换,但前提是该令牌位于具有特定内容的行中

文件中的样例实体模型片段:

<script type="text/javascript" src="scripts/someFolder/someFile1.js"></script>
<script type="text/javascript" src="scripts/otherFolder/fileName.js"></script>
<script type="text/javascript" src="scripts/aFolder/file3.js"></script>
<script type="text/javascript" src="scripts/someFolder/aFile.js"></script>
<script type="text/javascript" src="scripts/someFolder/subfolder/anotherFile.js"></script>
<body>
<p>Stuff</p>

东西

在本例中,我想向来自“somefolder”的任何js文件附加?时间戳。 我已经尝试过这些方法(实际的正则表达式是不同的):



但这只会生成一个文件,其中只包含修改过的行。我需要设置什么标志来保留所有文件内容?我需要整个文件,只需要一些条件替换。

您可以将多个筛选器链放在一起。过滤链过滤掉包含正则表达式的行。您需要的是第二个过滤器链以将其添加回

完全未经测试:

<copy file="xyz.jsp" tofile="${staging}/jsp/Links-test.jsp">
    <filterchain>
       <linecontainsregexp>
           <regexp pattern="someFolder" />
       </linecontainsregexp>
           <replacestring from=".js" to=".js?blahblah" />               
     </filterchain>
     <filterchain>
         <linecontainsregexp negate="true">
           <regexp pattern="someFolder" />
        </linecontainsregexp>
     </filterchain>               
</copy>

您可以将多个过滤链放在一起。过滤链过滤掉包含正则表达式的行。您需要的是第二个过滤器链以将其添加回

完全未经测试:

<copy file="xyz.jsp" tofile="${staging}/jsp/Links-test.jsp">
    <filterchain>
       <linecontainsregexp>
           <regexp pattern="someFolder" />
       </linecontainsregexp>
           <replacestring from=".js" to=".js?blahblah" />               
     </filterchain>
     <filterchain>
         <linecontainsregexp negate="true">
           <regexp pattern="someFolder" />
        </linecontainsregexp>
     </filterchain>               
</copy>