IntelliJ excludes jooqCodegen's folder

Answered

Using kotlin + gradle (gradle wrapper 8.5) + JooqCodegen (gradle plugin 3.19.6)

JOOQ generates model objects from the database schema in directory `build/generated-sources/jooq`

Unfortunately IntelliJ marks that folder as Excluded …

So I tried right-click > Mark Directory as … > Generated Sources Root with no success… (directory is now blue, but imports are still unresolved).

Of course everything compiles just fine using ./gradlew clean build

Using: IntelliJ IDEA 2023.3.6 (Ultimate Edition)
Build #IU-233.15026.9, built on March 21, 2024

2
6 comments

I've created a minimal project to reproduce: 

https://github.com/jobayle/repro-intellij-imports

Thanks!

1

Problem solved by using gradle plugin idea:

plugins {
	// ...
    idea
}

// ...

idea {
    module {
        sourceDirs.add(file("build/generated-sources/jooq"))
        generatedSourceDirs.add(file("build/generated-sources/jooq"))
    }
}
1

Another way is to manually include the sourceSet as below.  (I tried this with your project and Ultimate 2024.1.1). 
 

val generatedDir= layout.buildDirectory.dir("generated-sources/jooq")
sourceSets {
    this.main {
        kotlin.srcDir(generatedDir) // or java.srcDir(generatedDir)
    }
}


Now IDEA automatically un-excludes build/generated-sources/jooq, without having to directly configure the IDEA plugin.  

See https://github.com/jOOQ/jOOQ/issues/16088 for some discussion around this.

I suppose because ./gradlew build succeeds JOOQ-codegen-gradle is doing something with the sourceSets … it's just that IDEA is not able to pick up on it for some reason.  This is a bit perplexing: one would think that it if gradle knew, IDEA should also know after importing the model.

PS.  I modified your project slightly to not need a real DBMS environment by using ‘XMLDatabase' … https://www.jooq.org/doc/3.19/manual/code-generation/codegen-xml/ 

0

Problem solved by using gradle plugin idea:

This cannot really considered as a solution. I don't find clean put IDE's plugins in projects files…

1

Thank you to everyone reporting on this!

I have created YouTrack Issue IDEA-354580 based on the information from this thread and assigned to the R&D Team, so this issue can be addressed.

Please make sure to upvote the YouTrack Issue to raise its' priority for the developers!

0

There's a discussion about jOOQ's source set management here:

https://github.com/jOOQ/jOOQ/issues/16318#issuecomment-2162576930

0

Please sign in to leave a comment.