JOOQ and gradle class generation

My question is the best way to customize my build using gradle and jooq with the following limitations:

I have:

  • The simplest gradle build file, but one that can use eclipse, jooq, postgres and HSQL
  • Some Java core classes, including a couple of Enums, in a gradle-driven eclipse project
  • Several database schemas, each in its own file (schema1.sql, schema2.sql, etc.), in the same project
  • The most excellent JOOQ library and the pretty cool HSQLDB SQLFile utility
  • A combination of ANT scripts and java programs that perform the following steps in a fairly manual form and which I would like to automate.

I want the following functions to be controlled by gradle:

  • Main classes are compiled
  • Each database schema loaded into postgres database (I know how to do this in gradle)
  • A JOOQ library for generating classes from each schema (I know how to do this in gradle) using type matching to map some database columns to the corresponding Enums class (I don't know yet how to do this in gradle, because I don't know how to provide JOOQ access task to main classes)

There seem to be a few options in front of me, but I'm not sure which one would be the best:

  • Option 1. Divide the project into two projects: "core" and "db", the first of which is used by the latter to display mappings of columns and listings and projects located downstream, depending on how
  • Option two: save one project, but divide it into three stages: “compile the kernel”, “generate classes”, “compile generated classes”, where each step has access to the generated artifacts of the previous one. But I do not know how to do this.

I think that I can probably decide how to do this, given enough time, but I really wonder if this is a solvable problem, and there is an obvious or canonical way to do this. For recording, I prefer the second option, because this pattern is repeated with other projects, and Option One doubles the number of projects that I have to deal with. (Maybe it's not so bad ...)

Sorry if this is a vague question - the gradle documentation is actually pretty good in terms of “how to do X,” but I really don't feel like getting a good overview of how all the bits hang together.

I most understand any help.

EDIT

I have a related question, which is a specification of how to make option 2. This question and answer is here Gradle: assembling multiple source sets in one jar

While this question and answer describes how to make option two, they do not answer the broader question: “This is the best way to do this,” so I leave this question open.

+3
source share

Source: https://habr.com/ru/post/979026/


All Articles