grade generateJooq appears to be deleting application java

474 views
Skip to the first unread message

Rob Sargent

unread,
27 Jan 2022, 23:41:4027/01/2022
to jooq...@googlegroups.com
Near as I can tell in my jooq/gradle/java17 setup on a mac11.6.2 a call to generatJooq is dropping all the java files, including the application files, then generating the database classes.  This is rather troubling.  First spotted on version 3.14, I’ve moved all my dependencies forward including vaadin 22 (which is giving me a separate set of troubles)

Here’s my jooq/gradle block.
jooq {
  version = '3.15.+'
  edition = nu.studer.gradle.jooq.JooqEdition.OSS  // the default (can be omitted)
  dependencies {
    jooqGenerator 'org.postgresql:postgresql:42.2.14'
  }
  configurations {
    if (referenceDBname.contains("DBNAME_NOT_SET")) { 
      println("HEADS UP: you will need to configure the reference database: " + referenceDBname)
    }
    else {
      println("Generating jOOQ code from " + referenceDBname)
    }
    main {  // name of the jOOQ configuration
          generateSchemaSourceOnCompilation = ! referenceDBname == 'DBNAME_NOT_SET'  // default (can be omitted)
          generationTool 
          {
        logging = org.jooq.meta.jaxb.Logging.INFO
        jdbc {
          driver = 'org.postgresql.Driver'
 url = String.format("jdbc:postgresql://%s:%s/%s", referenceDBhost, referenceDBport, referenceDBname)
          user = 'postgres'
 if (project.hasProperty("referenceDBpswd")) {
            password = referenceDBpswd
 }
 else {
   println "No dbpwd"
 }
        }
        generator {
 database {
   // forcedTypes {
   //   forcedType {
   //     userType = 'java.util.LocalDateTime'
   //     converter = 'com.skatr.tsn.util.DateTimeConverter'
   //     includeExpression = '.*timestamp.*'
   //   }
   // }
   name = 'org.jooq.meta.postgres.PostgresDatabase'
   schemaVersionProvider = 'select max(version::int) FROM public.flyway_schema_history'
   includeRoutines = true
   schemata {
     schema {
inputSchema = 'public'
     }
     schema {
inputSchema = 'suas'
     }
   }
 }
          generate {
            deprecated               = false
            fluentSetters            = true
            generatedAnnotation      = true
            generatedAnnotationType  = 'DETECT_FROM_JDK'
            globalRoutineReferences  = true
            immutablePojos           = false
            pojos                    = true
            records                  = true
            relations                = true
            routines                 = true
          }
          target {
   packageName = 'com.skatr.db.gen'
   directory = 'src/main/java'
 }
          strategy.name = 'org.jooq.codegen.DefaultGeneratorStrategy'
        }
      }
    }
  }
}

tasks.named('generateJooq').configure {
  // make jOOQ task participate in incremental builds (which is also a prerequisite for participating in build caching)
  allInputsDeclared = true
  // make jOOQ task participate in build caching
  outputs.cacheIf { true }
}

Lukas Eder

unread,
28 Jan 2022, 02:30:0428/01/2022
to jOOQ User Group
Hi Rob,

jOOQ's GenerationTool deletes all non-jOOQ content in src/main/java/com/skatr/db/gen (i.e. directory/packageName). It doesn't touch anything else.

You could tell the generator to not do the above by specifying

target {
  // ..
  clean = false
}

See:

But I'm assuming that things are cleaned by some other process, including the gradle plugin or gradle itself?

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/E82216FC-1902-422E-84AE-EAF10F4EE0D4%40gmail.com.

Rob Sargent

unread,
28 Jan 2022, 08:36:0728/01/2022
to jooq...@googlegroups.com
Lucas,
Thanks for the explanation of the process and the ‘clean’ tip. I’ll keep looking. Grade is surprisingly unforthcoming or at best obtuse with regard to what actually is done,when, on what files. 

On Jan 28, 2022, at 12:30 AM, Lukas Eder <lukas...@gmail.com> wrote:



Lukas Eder

unread,
28 Jan 2022, 08:38:2428/01/2022
to jOOQ User Group
I was told many times that these things are better done by Gradle than by jOOQ's code generator 😅 Now you have it...

Please let us know, here, what the issue was. I'm sure, someone in the future will find your answer useful. Also sounds like a good candidate for https://stackoverflow.com/questions/tagged/jooq

Rob Sargent

unread,
28 Jan 2022, 08:46:3428/01/2022
to jooq...@googlegroups.com
I shall report back with any findings. A slight chance flyway is involved. This a personal project rather than work so progress is, um, unpredictable.

On Jan 28, 2022, at 6:38 AM, Lukas Eder <lukas...@gmail.com> wrote:


Reply all
Reply to author
Forward
0 new messages