【问题标题】:Ant identifiying the a line above the current lineAnt 识别当前行上方的 a 行
【发布时间】:2012-12-28 09:14:05
【问题描述】:

所以我可以检索文件中的某一行。现在我想检查这一行正上方的行中的值。我该如何在蚂蚁中做到这一点?

【问题讨论】:

    标签: ant build ant-contrib


    【解决方案1】:

    以下示例使用Groovy ANT task 打印每个 Java 文件的第 3 行和第 4 行。

    <project name="demo" default="run">
    
        <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy">
            <classpath>
                <pathelement location="lib/groovy-all-2.1.0-rc-1.jar"/>
            </classpath>
        </taskdef>
    
        <target name="run">
            <fileset id="javafiles" dir="src" includes="**/*.java"/>
    
            <groovy>
                ant.project.references.javafiles.each {
                    def lines = new File(it.toString()).readLines()
    
                    ant.echo lines[2]
                    ant.echo lines[3]
                }
            </groovy>
        </target>
    
    </project>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-16
      • 1970-01-01
      • 2020-04-26
      • 2011-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多