I'm running a gradle build that generates Java classes from an external
resource (via wsimport, actually). I want to store them in my main source
directory, src/main/java. Other than simply hardwiring that directory name
into my build file, is there some other way to refer to that directory?

For example, my wsimport task looks like this:

task wsimport(dependsOn: processResources) {
doLast {
 sourceSets.main.classesDir.mkdirs()
ant {
taskdef(name: 'wsimport',
 classname: 'com.sun.tools.ws.ant.WsImport',
classpath: configurations.jaxws.asPath)
 wsimport(keep:true,
destdir: sourceSets.main.classesDir,
sourcedestdir: 'src/main/java',        <-- Hard wired directory name here
 wsdl: "http://www.webservicex.net/CurrencyConvertor.asmx?wsdl";)
 }
}
}

I also only want this task to run if I haven't run it before, so I also have
the following line:

wsimport.onlyIf { !(new File("src/main/java/net/webservicex")) }

This is all working, but it feels brittle because of the explicit source
directory name. Is there a better, more general way to do this?

Thanks,

Ken
-- 
Kenneth A. Kousen
President
Kousen IT, Inc.

Email: [email protected]
Site: http://www.kousenit.com
Blog: http://kousenit.wordpress.com
Twitter: @kenkousen
Making Java Groovy<http://affiliate.manning.com/idevaffiliate.php?id=1084_254>

Reply via email to