I suspected it was something like that. It turned out I need to add
parentheses to the mkdirs command or Groovy thinks it's a property.

Thanks again,

Ken

On Sun, Feb 20, 2011 at 5:36 PM, Rene Groeschke <[email protected]> wrote:

> Hi Kenneth,
>
> Am 20.02.11 23:06, schrieb Kenneth Kousen:
> > I'm generating a web service client via a gradle build. In order to
> compile
> > my client, I need to first generate the stubs using the wsimport task.
> The
> > problem I'm having is that by running the wsimport task before the
> compile
> > task, the build fails if the destination directory doesn't already exist.
> >
> > My build file is below. I have a "sourceSets" task to map my project
> > structure to a standard Eclipse structure. When running the wsimport
> task,
> > the compiled code is supposed to go into the standard build directory,
> which
> > here is designated as sourceSets.main.classesDir.  My problem is that I
> > apparently need to create the build/main/classes directory ahead of time,
> or
> > the wsimport task fails.
> I think gradle creates the classes directory during the compileJava task
> in your example, which is (as you mentioned) to late for you. the ant ws
> import task seems to need an existing directory to
> put its generated output into. The easiest solution may be to create the
> directory just before executing the wsimport action:
>
> task wsimport(dependsOn: processResources)  {
>    doLast{
>         //ensure that the output directory is already created
>        sourceSets.main.classesDir.mkdirs << create the output directory if
> it doesn't yet exists
>         ant {
>            taskdef(name:'wsimport',
>                classname:'com.sun.tools.ws.ant.WsImport',
>                classpath:configurations.jaxws.asPath)
>            wsimport(keep:true,
>                destdir: sourceSets.main.classesDir,
>                sourcedestdir:'src',
>            wsdl:'http://www.webservicex.net/GlobalWeather.asmx?wsdl')
>        }
>    }
> }
>
> regards,
> René
>
>
> > Am I doing something wrong here? I'm accustomed to the build artifacts
> being
> > generated automatically.
> >
> > (Btw, this sample accesses the Global Weather web service at the URL
> listed,
> > just as a simple example.)
> >
> > apply plugin:'groovy'
> > apply plugin:'eclipse'
> >
> > repositories {
> >     mavenCentral()
> >     mavenRepo urls:["http://download.java.net/maven/1";,
> >         "http://download.java.net/maven/2";]
> > }
> >
> > configurations {
> >     jaxws
> > }
> >
> > sourceSets {
> >     main {
> >         java { srcDirs = [] }
> >         groovy { srcDir 'src' }
> >     }
> >     test {
> >         java { srcDirs = [] }
> >         groovy { srcDir 'test' }
> >         resources { srcDir 'resources' }
> >     }
> > }
> >
> > task wsimport(dependsOn: processResources)  {
> >     doLast{
> >         ant {
> >             taskdef(name:'wsimport',
> >                 classname:'com.sun.tools.ws.ant.WsImport',
> >                 classpath:configurations.jaxws.asPath)
> >             wsimport(keep:true,
> >                 destdir: sourceSets.main.classesDir,
> >                 sourcedestdir:'src',
> >             wsdl:'http://www.webservicex.net/GlobalWeather.asmx?wsdl')
> >         }
> >     }
> > }
> > wsimport.onlyIf { !(new File('src/net/webservicex')).exists() }
> > compileJava.dependsOn(wsimport)
> >
> > def groovyVersion = '1.7.8'
> > def spockVersion = '0.5-groovy-1.7'
> >
> > dependencies {
> >     groovy "org.codehaus.groovy:groovy-all:$groovyVersion"
> >     jaxws 'com.sun.xml.ws:jaxws-tools:2.1.4'
> >
> >     testCompile "org.spockframework:spock-core:$spockVersion"
> > }
> >
> > Thanks for any assistance. This is going to go into my SOAP web services
> > chapter of my book "Making Java Groovy", currently available in MEAP form
> > from http://manning.com/kousen . I've been checking through the code and
> > realized I had a problem here when I started from scratch, rather than
> > running from my existing project.
> >
> > Ken Kousen
>
>
> --
> ------------------------------------
> Rene Groeschke
>
> [email protected]
> http://www.breskeby.com
> http://twitter.com/breskeby
> ------------------------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


-- 
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