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



##########
File path: core/build.gradle.kts
##########
@@ -187,6 +192,40 @@ ide {
     generatedSource(javaCCTest, "test")
 }
 
+fun JavaCompile.configureAnnotationSet(sourceSet: SourceSet) {
+    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(sourceSets.main.get())
+    // only if we aren't running compileJava, since doing twice fails.
+    onlyIf { tasks.findByPath("compileJava")?.enabled != true }

Review comment:
       `tasks.findByPath("compileJava")?.enabled` is verifying if the task 
exists, however, what we need to check is whether task is a part of the task 
graph (e.g. if it was requested by the user).
   
   The condition should be like 
`project.gradle.taskGraph.hasTask("compileJava")` or something like 
project.gradle.taskGraph { if (compileJava is in the graph) { disable proc-only 
task}`.




-- 
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