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
File io Ant构建只在子目录上运行_File Io_Ant_Ant Contrib - Fatal编程技术网

File io Ant构建只在子目录上运行

File io Ant构建只在子目录上运行,file-io,ant,ant-contrib,File Io,Ant,Ant Contrib,我正在尝试创建一个Ant构建,它将在文件夹中的每个子文件夹中运行一个目标。我特别需要这个只在子文件夹级别运行,因为如果我从顶部文件夹运行它并告诉它包含子文件夹,它会扰乱结果 我从我看到的建议中总结了以下内容,看起来很接近,但不起作用。关于这一点,有两点: 当我运行此程序时,我得到“C:\Developer\SVN\trunk\DITA\xxx\u conversion\test\${subdir}不存在。”(子目录确实存在,我有…\test\testsub\xxx\u xxx.DITA) 名为

我正在尝试创建一个Ant构建,它将在文件夹中的每个子文件夹中运行一个目标。我特别需要这个只在子文件夹级别运行,因为如果我从顶部文件夹运行它并告诉它包含子文件夹,它会扰乱结果

我从我看到的建议中总结了以下内容,看起来很接近,但不起作用。关于这一点,有两点:

  • 当我运行此程序时,我得到“C:\Developer\SVN\trunk\DITA\xxx\u conversion\test\${subdir}不存在。”(子目录确实存在,我有…\test\testsub\xxx\u xxx.DITA)

  • 名为“script”的目标本身可以完美地工作。如果我把它指向一个文件夹,它会转换其中的内容,并给出我需要的结果

  • foreach
    任务中,如果我将测试更改为just
    ,则构建成功,但它基本上只是按原样运行
    “script”
    目标

  • 在名为“script”的目标中,如果我将
    “*.dita”
    更改为
    “***.dita”
    ,则它会在其操作中包含顶级文件夹,因此结果不是我需要的,只需获取每个子文件夹中的每个.dita文件,并将其包装到与dita文件同名的文件夹中:

起始状态:
testsub\xxx\u xxx.dita

所需结果:
testsub\xxx\uxxx\xxx\uxxx.dita

加扰结果:
testsub\xxx\u xxx\testsub\xxx\u xxx.dita

如果有人能告诉我这(可能有很多事情)有什么问题,那就太好了:

<project name="move_and_wrap_dita_topics" default="script" basedir="C:\Developer\SVN\trunk\DITA\xxx_conversion\test">

<taskdef resource="net/sf/antcontrib/antlib.xml">
</taskdef>

<foreach target="script" param="worksheet" inheritall="true">
  <path>
      <dirset dir="${subDir}">
           <include name="*"/>
      </dirset>
  </path>
</foreach>

<target name="script">
   <copy todir="C:\Developer\SVN\trunk\DITA\xxx_conversion\cleaned" verbose="true">
     <fileset dir="C:\Developer\SVN\trunk\DITA\xxx_conversion\test">
        <include name="*.dita"/> 
     </fileset>
        <scriptmapper language="javascript">
   self.addMappedName(source.replace(source.split('.')[0], source.split('.')[0] + "/" + source.split('.')[0]));
      </scriptmapper>
  </copy>
</target>

</project>

self.addMappedName(source.replace(source.split('.')[0],source.split('.')[0]+“/”+source.split('.')[0]);
作为一种替代方法,如果有某种方法只需在
“script”
任务中编写
“include name”
,这样它就可以完全跳过顶部文件夹,只从子文件夹开始重写,那就更简单了。我试过
和其他各种变体,但没有成功

起始状态:
testsub\xxx\u xxx.dita

所需结果:
testsub\xxx\uxxx\xxx\uxxx.dita

这应该可以通过单个正则表达式映射器实现,您根本不需要
foreach

<copy todir="C:\Developer\SVN\trunk\DITA\xxx_conversion\cleaned" verbose="true">
  <fileset dir="C:\Developer\SVN\trunk\DITA\xxx_conversion\test"
           includes="*/*.dita" />
  <!-- use handledirsep to treat \ as if it were / in the source file name -->
  <regexpmapper handledirsep="true" from="^(.*)/([^/]*)\.dita$"
                to="\1/\2/\2.dita" />
</copy>


includes=“*/*.dita”
将匹配文件集基本目录下一级的
.dita
文件,正则表达式将源中的
testsub/xxx.dita
转换为目标中的
testsub/xxx/xxx.dita
。如果要查找一个或多个级别的文件,请改用
*/***.dita

在哪里定义
子目录
属性?啊,对了。我不是。那么,将其定义为给定top dir的每个子目录,是如何实现的呢?很好。我试过一个正则表达式映射器,但没有成功,基本上,
handledirsep
和确切的通配符设置是我没有得到的。我认为,
.dita$
中的
$
也很重要。工作完美。万分感谢