• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Gradle how to get right output directotry

 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a projekt like this:


Persistence
 + src
  + main
    + Java


Services
 + src
  + main
    + Java

There is a build gradle file in the service part, and when i generete, the target dir is src/generated-sources/jaxb, under Services, but i want it to output in Persistence, what is the correct syntax for this ?

I have tried:
      def jaxbTargetDir = file("Persistance/src/generated-sources/jaxb")
      def jaxbTargetDir = file("*/Persistance")
-     def jaxbTargetDir = file("**/Persistance")
      def jaxbTargetDir = file("persistance/src/main/java/com/jysk/customermasterdata/persistence/model")



task jaxb {
       System.setProperty('javax.xml.accessExternalSchema', 'all')
       def jaxbTargetDir = file("src/generated-sources/jaxb")
       doLast {
           jaxbTargetDir.mkdirs()
           ant.taskdef(
                   name: 'xjc',
                   classname: 'com.sun.tools.xjc.XJCTask',
                   classpath: configurations.jaxb.asPath
           )
           ant.jaxbTargetDir = jaxbTargetDir
           ant.xjc(
                   destdir: '${jaxbTargetDir}',
                   package: 'com.jysk.customermasterdata.services.salesforce',
                   schema: 'src/main/resources/workflowOutboundMessage.wsdl',
                   language: 'WSDL'
           )
       }
   }

   compileJava.dependsOn jaxb

 
Saloon Keeper
Posts: 24325
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a general rule, I don't recommend that you output generated files of any type to reside under your source directory tree. There are a number of reasons for this and, alas, I learned them the hard way.

I can't speak specifically for gradle, since I'm an infrequent user, but in Maven, the preferable destination for a source code generator mojo would be somewhere under the target directory where working (and final) files are built.

In Maven, the "clean" goal deletes target and all files and directories undeneath it. Further, you wouldn't normally put the target directory under source control, since it and everything in it should be regeneratable when doing a full build.
 
Frank Jacobsen
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks for the input, can see what you mean, and you are absolutely right :-)

//Frank
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic