// START SNIPPET declare-inputs-and-outputs
task transform {
    srcFile = file('mountains.xml')
    destDir = new File(buildDir, 'generated')
    inputs.file srcFile
    outputs.dir destDir
// END SNIPPET declare-inputs-and-outputs
    doLast {
        println "Transforming source file."
        destDir.mkdirs()
        def mountains = new XmlParser().parse(srcFile)
        mountains.mountain.each { mountain ->
            def name = mountain.name[0].text()
            def height = mountain.height[0].text()
            def destFile = new File(destDir, "${name}.txt")
            destFile.text = "$name -> ${height}\n"
        }
    }
// START SNIPPET declare-inputs-and-outputs
}
// END SNIPPET declare-inputs-and-outputs
