I am trying to generate the QueryDSL Q classes for my Mongo objects using gradle in a Spring boot project. IDE, I use Intellij.
The code I'm using is adapted from this section Creating the JPA2 metamodel from the gradle script assembly :
sourceSets { generated { java { srcDirs = ['src/generated/java'] } } } configurations { querydslapt } task generateQueryDSL(type: JavaCompile, group: 'build', description: 'Generates the QueryDSL query types') { source = sourceSets.main.java classpath = configurations.compile + configurations.querydslapt options.compilerArgs = [ "-proc:only", "-processor", "org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor" ] destinationDir = sourceSets.generated.java.srcDirs.iterator().next() } compileJava { dependsOn generateQueryDSL source generateQueryDSL.destinationDir } compileGeneratedJava { dependsOn generateQueryDSL options.warnings = false classpath += sourceSets.main.runtimeClasspath } clean { delete sourceSets.generated.java.srcDirs } idea { module { downloadJavadoc = true downloadSources = true generatedSourceDirs += file('src/generated/java') } }
The problem is that at the end of Intellij I have 3 modules. The main, test and generated. The tested and generated modules depend on the main module. I would also like the main module to depend on the generated module, since I use the generated Q classes in my code.
All my attempts to solve this problem result in a cyclical Gradle dependency error.
Can someone give me some advice that I could try to solve this problem.
Thanks!
source share