Similar to the solution we took with JIBX bindings. If anyone is interested
i am including a complete example from our build.gradle.
dependencies {
addConfiguration('bind')
clientModule(['bind'], "org.jibx:jibx-bind:1.1.5") {
dependencies("org.jibx:jibx-extras:1.1.5")
dependencies("org.jibx:jibx-run:1.1.5")
dependencies("org.apache.bcel:bcel:5.1")
dependencies("com.thoughtworks.qdox:qdox:1.6.1")
dependencies("stax:stax-api:1.0")
dependencies("org.codehaus.woodstox:wstx-asl:2.8")
dependencies("xmlpull:xmlpull:1.1.4")
dependencies("xpp3:xpp3:1.1.3.4.O")
}
}
compile.doLast {
ant {
taskdef(name: 'bind',
classname: 'org.jibx.binding.ant.CompileTask',
classpath: dependencies.antpath('bind'))
bind(binding: "${rootDir}/binding.xml",
verbose: 'false') {
classpath {
pathelement(path: "${rootDir}/build/classes")
}
}
}
}
There is a better way to handle the dependency part as Tom pointed out, but
this was one of the first pieces of build logic i wrote in gradle :)
On Sun, Mar 22, 2009 at 6:34 PM, Tom Eyckmans <[email protected]> wrote:
> Hi,
> If there are Ant tasks available you can use them in an ant { } block in
> your build.gradle file, I think this is the easist and prefer it over
> calling command lines manually. Also because it makes porting easier. You
> can use the asPath on a dependency configuration to access the jar files for
> your ant taskdef, so for example:
>
> dependencies {
> addConfiguration('jibxAnt')
>
> addMavenRepo()
>
> jibxAnt // add jibx dependency here
> }
>
> createTask('jibx') {
> ant{
> taskdef(name:'jibx', classname: ... , classpath: jibxAnt.asPath ) //
> I didn't check the name
>
> // call jibx task(s)
> }
> }
>
> 2009/3/17 <[email protected]>
>
> Hi all,
>>
>> I need to run some JibX binding compile while building my project. I was
>> wondering which was the best practice with gradle to do so.
>>
>> Either using Groovy's AntBuilder
>> Or calling from Gradle script a custom "java -jar jibx-bind.jar (...)"
>>
>> What are the pros/cons for each method ?
>>
>> And for both methods, how can access the jar file? Is all .gradle/cache
>> folder included in the classpath, or should I use a variable. If so, is
>> there a Gradle variable pointing to the cache dir?
>>
>> Thanks in advance
>>
>
>