Hi Christian, I'm not too acquainted with how Gradle works, so perhaps this is not the best answer, but in Maven, you would have to create a separate project/module only for that strategy class, in order to create a dependency graph like so:
1. Code generation module... depends on 2. Strategy module... depends on 3. jOOQ libraries I would imagine that it is the same with Gradle. I hope this helps, Lukas 2016-06-16 23:43 GMT+01:00 <[email protected]>: > Hi Lukas, > > I'm running into a problem when I try to define my own GeneratorStrategy. > The classloader doesn't find my strategy class and I can't figure out how > this can be solved. > I use jOOQ 3.7.3 to generate the code. > For creating the classes I've a gradle script which looks like this: > > > ... > > def dbProps = new Properties() > dbProps.load(new FileInputStream(System.getProperty("user.home") + > "/local.properties")) > > ext { > > database = [ > host: dbProps.get("dbHost"), > port: dbProps.get("dbPort"), > schema: dbProps.get("dbSchema"), > user: dbProps.get("dbUser"), > password: dbProps.get("dbPwd") > ] > > jooqGen = [ metaSrcDir: "$buildDir/generated" ] > > jdbcUrl = > "jdbc:mysql://${database.host}:${database.port}/${database.schema}" > > } > > defaultTasks 'jooqMetaGenerate' > > configurations { > compile.extendsFrom generatedCompile > } > > sourceSets { > generated > > main { > compileClasspath += generated.output > output.classesDir = "$buildDir/classes" > output.resourcesDir = "$buildDir/resources" > > java { > srcDirs += [jooqGen.metaSrcDir] > } > > resources > } > > } > > dependencies { > generatedCompile 'org.jooq:jooq:3.7.3', 'org.jooq:jooq-meta:3.7.3', > 'org.jooq:jooq-codegen:3.7.3' > ... > } > > ... > > task("jooqMetaGenerate") << { > Configuration configuration = new Configuration() > .withJdbc(new Jdbc() > .withUrl(jdbcUrl) > .withUser(database.user) > .withPassword(database.password)) > .withGenerator(new Generator() > .withStrategy(new Strategy() > .withName('my.own.package.util.MyGeneratorStrategy')) > .withGenerate(new Generate() > .withValidationAnnotations(true) > .withPojos(true).withPojosEqualsAndHashCode(true). > withPojosToString(true).withImmutablePojos(true)) > .withDatabase(new Database() > .withSchemata(new Schema() > .withInputSchema(database.schema) > .withOutputSchema(database.schema)) > .withName("org.jooq.util.mysql.MySQLDatabase")) > .withTarget(new Target() > .withPackageName("my.own.package") > .withDirectory(jooqGen.metaSrcDir))); > > GenerationTool.generate(configuration) > } > > > flywayMigrate.dependsOn clean > compileGeneratedJava.dependsOn jooqMetaGenerate > compileJava.dependsOn compileGeneratedJava > > > The "jooqMetaGenerate" task gives me the class not found exception: > > Caused by: java.lang.ClassNotFoundException: > my.own.package.util.MyGeneratorStrategy > > at org.jooq.util.GenerationTool.loadClass(GenerationTool.java:500) > > at org.jooq.util.GenerationTool.run(GenerationTool.java:236) > > at org.jooq.util.GenerationTool.generate(GenerationTool.java:180) > > > Any idea how I can make the classloader look for the strategy class? > > > Thanks in advance... > > > Cheers, > > Christian > > -- > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
