Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Gradle how to get right output directotry

 
Ranch Hand
Posts: 361
  • 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: 23441
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • 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: 361
  • 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
 
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic