Created
April 27, 2013 20:26
-
-
Save parj/5474558 to your computer and use it in GitHub Desktop.
Basic gradle file to download anttasks and run the task within it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repositories { | |
mavenCentral() | |
maven { | |
url "http://oss.sonatype.org/content/groups/public/" | |
} | |
} | |
configurations { | |
fz | |
} | |
dependencies { | |
fz group: 'uk.co.firstzero', name: 'anttasks', version: '2.4' | |
} | |
// Push file to a WebDav Server | |
task push << { | |
ant.taskdef(name: 'push', classname: 'uk.co.firstzero.webdav.Push', classpath: configurations.runtime.asPath) | |
ant.push(user: 'admin', password: "admin", url: "http://localhost:8080/repository/default", overwrite: true) { | |
fileset(dir: 'src/test/resources/webdav', includes: '*.csv') | |
} | |
} | |
// Pull file from a webdav server | |
task pull << { | |
ant.taskdef(name: 'pull', classname: 'uk.co.firstzero.webdav.Pull', classpath: configurations.runtime.asPath) | |
ant.pull(user: 'admin', password: "admin", url: "http://localhost:8080/repository/default", | |
file: "output.csv", | |
outFile: "src/test/resources/webdav/output.csv", | |
overwrite: true) | |
} | |
// Converts csv to Excel | |
task csvToExcel << { | |
ant.taskdef(name: 'csvToExcel', classname: 'uk.co.firstzero.csv.AntCsvToExcel', classpath: configurations.runtime.asPath) | |
ant.csvToExcel(outputFile: "build/tmp/report.xls", separator: "^") { | |
fileset(dir: "src/test/resources/csv/CsvToExcel", includes: "*.csv") | |
} | |
} | |
// Diffs two directories containing xml files with the same name | |
task diffxml << { | |
ant.taskdef(name: 'diffxml', classname: 'uk.co.firstzero.xml.AntXMLUnit', classpath: configurations.runtime.asPath) | |
ant.diffxml(testDirectory: "src/test/resources/xml/AntXMLUnitTest/test", resultDirectory: "out") { | |
fileset(dir: "src/test/resources/xml/AntXMLUnitTest/control", includes: "*.xml") | |
} | |
} | |
// Strips out and modifies tags in xmls and renames them using a naming convention | |
task modifyPath << { | |
ant.taskdef(name: 'xPath', classname: 'uk.co.firstzero.xml.AntXPath', classpath: configurations.runtime.asPath) | |
ant.taskdef(name: 'modifyPath', classname: 'uk.co.firstzero.xml.ModifyPath', classpath: configurations.runtime.asPath) | |
//Rename Pattern is the file rename pattern, takes as input as xpaths separated by # | |
ant.xPath(outputDirectory: "out", renamePattern: "//publish_date[position() = 1]#_#//price[position() = 1]" ) { | |
fileset(dir: "src/test/resources/xml/AntXPathTest", includes: "*.xml") | |
modifyPath(path: "//title", delete:"True") | |
modifyPath(path: "//author", value:"ToDo") | |
} | |
} | |
// Reads blob data from the database | |
task readBlob << { | |
ant.taskdef(name: "readBlob", classname: "uk.co.firstzero.sql.AntReadBlob", classpath: configurations.runtime.asPath) | |
String databaseLocation = projectDir.toString() + "/src/test/resources/sql/test" | |
println ("Database = " + databaseLocation) | |
//SQL should contain a string name and then blob - example | |
//SELECT name, blob_data from test_db where condition_1=1234 | |
ant.readBlob(className: "org.h2.Driver", jdbcUrl: "jdbc:h2:" + databaseLocation + ";IFEXISTS=TRUE", | |
user: "sa", password: "", extension: ".jpg", | |
sql: "SELECT name, blob from TEST", | |
outputDirectory: "build/tmp", | |
unzip: "True") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment