dsmiley commented on code in PR #1793:
URL: https://github.com/apache/solr/pull/1793#discussion_r1594858131


##########
solr/solrj/build.gradle:
##########
@@ -85,3 +94,73 @@ dependencies {
   testImplementation 'org.apache.commons:commons-lang3'
   testImplementation 'io.dropwizard.metrics:metrics-core'
 }
+
+/**
+ * Java Code Generation for Solr API
+ */
+
+evaluationDependsOn(":solr:api")
+
+configurations {
+  openApiSpecFile {
+    canBeConsumed = false
+  }
+}
+
+ext {
+  generatedCodeDir = "${buildDir}/generated/"
+  javaTemplateDir = "${projectDir}/src/resources/java-template"
+}
+
+dependencies {
+  openApiSpecFile(project(path: ":solr:api", configuration: "openapiSpec"))
+}
+
+/**
+ * Code Generation task
+ */
+openApiGenerate {
+  generatorName = "java"
+  inputSpec = project(":solr:api").openApiSpecFile
+
+  // Add 'debugModels: ""' or 'debugOperations: ""' to get the JSON input to 
mustache templating for those components
+  globalProperties.set([apis: "", models: "false"])
+  templateDir = project.javaTemplateDir
+  apiPackage = "org.apache.solr.client.solrj.request"
+  outputDir = project.generatedCodeDir
+  generateApiTests = false
+  generateModelTests = false
+  generateApiDocumentation = false
+  generateModelDocumentation = false
+  additionalProperties = ["modelPackage": "org.apache.solr.client.api.model"]
+}
+
+tasks.openApiGenerate.dependsOn configurations.openApiSpecFile
+
+def generatedFiles = files("${project.generatedCodeDir}/src/main/java") {
+  builtBy tasks.openApiGenerate
+}
+
+/**
+ * Setup Spotless (Code formatting) for the generated java files
+ */
+def generatedExt = new JavaExtension(spotless)
+project.spotlessJavaSetup.execute(generatedExt)
+generatedExt.target(generatedFiles)
+def generatedSpotlessTask = 
generatedExt.createIndependentApplyTask("generatedSpotless")
+generatedSpotlessTask.group("build")
+generatedSpotlessTask.description("Apply formatting for generated code")
+
+tasks.openApiGenerate.finalizedBy generatedSpotlessTask
+

Review Comment:
   Yeah agreed overall.  I'm just concerned with build complexity and want to 
make recommendations to improve / simplify it, to include using a declarative 
style when possible.  Assuming the `createIndependentApplyTask` piece is 
critical, nothing much to do here :-/. 



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to