Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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
修改.java文件的Ant脚本在";“一般”;Eclipse项目,但不在Maven Eclipse项目中_Eclipse_Maven_Ant - Fatal编程技术网

修改.java文件的Ant脚本在";“一般”;Eclipse项目,但不在Maven Eclipse项目中

修改.java文件的Ant脚本在";“一般”;Eclipse项目,但不在Maven Eclipse项目中,eclipse,maven,ant,Eclipse,Maven,Ant,我有一个相对简单的Ant脚本commentOutXmlAnnotations.xml,它编辑所有子目录中Java文件的内容,通过正则表达式注释掉某些行: <?xml version="1.0"?> <project name="CommentOutXmlAnnotations" basedir="." default="commentOutXmlAnnotations" > <!-- This Ant script comm

我有一个相对简单的Ant脚本
commentOutXmlAnnotations.xml
,它编辑所有子目录中Java文件的内容,通过正则表达式注释掉某些行:

<?xml version="1.0"?>
<project
    name="CommentOutXmlAnnotations"  
    basedir="."  
    default="commentOutXmlAnnotations" >

    <!-- This Ant script comments out the following lines from the Java files in this directory
         and all subdirectories:
        -import javax.xml.bind.annotation.*;
        -@Xml*

        To run this in Eclipse, right-click on this file and click "Run As->Ant Build".             
     -->

    <target
        name="commentOutXmlAnnotations"        
        description="Run" >
            <replaceregexp
                byline="false"
                flags="g" >

                <regexp pattern="(@Xml[A-Za-z0-9]+(\([^)]+\))?|import javax\.xml\.bind\.annotation\.[A-Za-z0-9.]+;)[ \t]*(\r?\n)" />

                <substitution expression="/*\1*/\3" />

                <fileset dir="." >
                    <include name="*/*.java" />
               </fileset>
            </replaceregexp>        
    </target> 
</project>
但是子目录中.java文件的内容不会改变。我认为这与Maven项目目录设置有关

在Eclipse Maven项目中,如何将project/ant脚本配置为在其所在的同一目录中执行?

所以,这是一个愚蠢的错误

上面的脚本只搜索一个目录深度,因此看起来该脚本没有任何影响,因为所有java文件的包名都比一个目录长

要在多个深度搜索所有子目录,
fileset
元素应为:

<fileset dir="." >
    <include name="**/*.java" />
</fileset>

<fileset dir="." >
    <include name="**/*.java" />
</fileset>