vlsi commented on a change in pull request #2531:
URL: https://github.com/apache/calcite/pull/2531#discussion_r718198212



##########
File path: core/build.gradle.kts
##########
@@ -187,6 +194,65 @@ ide {
     generatedSource(javaCCTest, "test")
 }
 
+fun configureAnnotationSet(task: JavaCompile, sourceSet: SourceSet) {
+    with(task) {
+        source = sourceSet.java
+        classpath = sourceSet.compileClasspath
+        destinationDirectory.set(options.generatedSourceOutputDirectory)
+        options.compilerArgs.add("-proc:only")
+        
org.gradle.api.plugins.internal.JvmPluginsHelper.configureAnnotationProcessorPath(sourceSet,
 sourceSet.java, options, project)
+    }
+}
+
+val annotationProcessorMain by tasks.registering(JavaCompile::class) {
+    dependsOn(javaCCMain)
+    configureAnnotationSet(this, sourceSets.main.get())
+    // only if we aren't running compileJava, since doing twice fails.
+    onlyIf { tasks.findByPath("compileJava")?.enabled != true }
+}
+
+val annotationProcessorTest by tasks.registering(JavaCompile::class) {
+    val kotlinTestCompile = 
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>()
+        .getByName("compileTestKotlin")
+
+    dependsOn(javaCCTest, kotlinTestCompile)
+
+    configureAnnotationSet(this, sourceSets.test.get())
+    classpath += files(kotlinTestCompile.destinationDirectory.get())
+
+    // only if we aren't running compileJavaTest, since doing twice fails.
+    onlyIf { tasks.findByPath("compileTestJava")?.enabled != true }
+}
+
+ide {
+    // generate annotation processed files on project import/sync.
+    // adds to idea path but skip don't add to SourceSet since that triggers 
checkstyle

Review comment:
       Is adding to "idea path" really needed? In my experiments with your 
branch, IDEA was picking up the sources automatically




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to