On 12/01/2011, at 6:05 AM, Bullard, Douglas wrote:
> I’m a Gradle newbie, trying to convert my TestNG output into something
> prettier. In Ant I use a nice xsl transform that does the job nicely. I’m
> trying to convert this to Gradle, but get a really nasty stylesheet exception
> when I try to pass in needed parameters.
>
> Here’s how it looks in Ant:
>
> <xslt in="@{testNgOutputDir}/testng-results.xml”
> style="${lib.test.formatTestNg}/testng-results.xsl”
> out="@{outputDir}/index.html”>
> <param name="testNgXslt.outputDir" expression="@{outputDir}/“/>
> <param name="testNgXslt.sortTestCaseLinks" expression="true”/>
> <param name="testNgXslt.testDetailsFilter"
> expression="FAIL,SKIP,PASS”/>
> <classpath refid="classpath.testng.format”/>
> </xslt>
>
>
> I’m trying to get something like:
> task formatTestResults << {
> ant.xslt(in:
> '/Users/douglasbullard/Documents/JavaStuff/Google_Code/IvyTools/branches/gradle/build/reports/tests/testng-results.xml',
> style:
> '/Users/douglasbullard/Documents/JavaStuff/testng-xslt-1.1.1/src/main/resources/testng-results.xsl',
> out:
> '/Users/douglasbullard/Documents/JavaStuff/Google_Code/IvyTools/branches/gradle/build/reports/tests/index.html',
> classpath:
> '/Users/douglasbullard/Documents/JavaStuff/testng-xslt-1.1.1/lib/saxon-8.7.jar'
>
> )
> }
>
> As I mentioned, this doesn’t seem to be accepting any of the things I’ve
> tried for passing the pararms (outputDir, sortTestCaseLinks, and
> testDetailsFilter) - what’s the right way to pass this from Gradle to Ant?
You pass nested Ant elements as method calls nested in a closure:
ant.xslt(in: '..', style: '..', out: '..) {
param(name: '..', expression: '..')
}
Have a look at the description of how to map from Ant to Gradle in the user
guide: http://gradle.org/0.9.1/docs/userguide/ant.html#N112F1
> Or, is there another way to do this in pure Gradle?
Not really. However, you can simply drive the Transformer directly from your
build script:
task transform << {
def transformer = TransformerFactory.newInstance().newTransformer(...)
transformer.setParamter('..', '..')
transformer.transform(...)
}
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz