Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.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/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
Google Java Format格式化时无法读取文件_Java_Ant_Google Java Format - Fatal编程技术网

Google Java Format格式化时无法读取文件

Google Java Format格式化时无法读取文件,java,ant,google-java-format,Java,Ant,Google Java Format,我添加了一个ant任务来在编译之前格式化源代码。 但是,当提供文件路径列表时,格式化程序会出现错误,并且在作为JavaAnt任务运行时会跳过(无法读取)文件。 单独或批量运行相同的脚本不会产生相同的错误 这是JavaAnt任务的问题吗? 在java任务中设置fork=“True”无效。返回的结果代码仍然是1 bash脚本可以在我的存储库中找到 脚本有:buildant、buildantall、format和formatall Build.xml和Build.properties位于每个项目目录下

我添加了一个ant任务来在编译之前格式化源代码。 但是,当提供文件路径列表时,格式化程序会出现错误,并且在作为JavaAnt任务运行时会跳过(无法读取)文件。 单独或批量运行相同的脚本不会产生相同的错误

这是JavaAnt任务的问题吗? 在java任务中设置fork=“True”无效。返回的结果代码仍然是1

bash脚本可以在我的存储库中找到

脚本有:buildant、buildantall、format和formatall

Build.xml和Build.properties位于每个项目目录下

您可以尝试单独运行脚本的项目是Facade2和Composite2

您至少需要JDK 8来编译所有代码。JDK 7将适用于除使用lambda表达式的Composite2之外的所有其他项目

提前谢谢

ant任务的设置如下所示:

<target name="gformat">
    <exec executable="find" dir="${basedir}"
        failonerror="true" outputproperty="sources">
        <arg line=" . -type f -name '*.java'"/>
    </exec>

    <echo message="About to format ...: ${sources}"/>

    <java classname="${gformat.main.class}">
        <arg line=" -i ${sources}"/>
        <classpath>
            <pathelement location="../${gformat.jar}"/>
            <pathelement path="${java.class.path}"/>
        </classpath>
    </java>
</target>


通过用以下内容替换exec任务,我能够修复上述错误:

<fileset dir="${basedir}" id="javasrcs">
      <include name="**/*.java" />
    </fileset>
    <pathconvert property="sources" refid="javasrcs" pathsep=" " />


现在,如何关闭此查询

查找任务的问题在于,它在每个文件名之间放置了一个行分隔符,而格式化程序希望在命令行中使用空格字符。解决方案是grep并用空格替换行分隔符,或者使用前面指定的空格分隔符使用ant任务

查找任务的问题在于,它在每个文件名之间放置了一个行分隔符,而格式化程序希望在命令行中使用空格字符。解决方案是grep并用空格替换行分隔符,或者使用前面指定的空格分隔符使用ant任务