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


##########
solr/solrj/build.gradle:
##########
@@ -15,13 +15,82 @@
  * limitations under the License.
  */
 
+plugins {
+  id "org.openapi.generator" version "6.6.0"
+}
 
 apply plugin: 'java-library'
+apply plugin: 'com.diffplug.spotless'
+
+import com.diffplug.gradle.spotless.JavaExtension
+
 
 description = 'Solrj - Solr Java Client'
 
+configurations {
+  openApiSpecFile {
+    canBeConsumed = false
+  }
+  generatedCode
+}
+
+tasks.register("copySpec", Copy) {
+  from("../solrj-model/build/generated/openapi")
+  into(layout.buildDirectory.dir("openapispec"))
+}
+
+def generatedExt = new JavaExtension(spotless)
+project.ext.spotlessJavaSetup.execute(generatedExt)
+generatedExt.target("build/generated/src/**/*.java")
+def generatedSpotlessTask = 
generatedExt.createIndependentApplyTask("generatedSpotless")
+generatedSpotlessTask.group("build")
+generatedSpotlessTask.description("Apply formatting for generated code")
+
+openApiGenerate {
+  generatorName = "java"
+  // TODO - pretty hacky to specify inputSpec this way...ideally I'd just rely 
on a property defined in
+  // solrj-model, as below, but it doesn't appear to be working
+  //inputSpec = project(":solr:solrj-model").ext.openapispecfile
+  inputSpec = "${buildDir}/openapispec/openapi.json"
+
+  // Add 'debugModels: ""' or 'debugOperations: ""' to get the JSON input to 
mustache templating for those components
+  globalProperties.set([modelDocs: "false", apis: "", models: ""])
+  templateDir = "$projectDir/src/resources/java-template"
+  apiPackage = "org.apache.solr.client.solrj.request"
+  modelPackage = "org.apache.solr.client.solrj.model"
+  outputDir = "${buildDir}/generated/"
+  generateApiTests = false
+  generateModelTests = false
+}
+
+tasks.getByName("copySpec").dependsOn 
configurations.getByName("openApiSpecFile")
+tasks.getByName("openApiGenerate").dependsOn tasks.copySpec
+tasks.getByName("openApiGenerate").finalizedBy generatedSpotlessTask
+generatedSpotlessTask.dependsOn tasks.openApiGenerate
+
+sourceSets {
+  main {
+    java {
+      srcDir "${buildDir}/generated/src/main/java"
+    }
+  }
+}
+tasks.compileJava.dependsOn(configurations.generatedCode)
+
+
 dependencies {
 
+  openApiSpecFile(project(path: ":solr:solrj-model", configuration: 
"openapiSpec"))
+  generatedCode files("${buildDir}/generated/main/java") {
+    builtBy tasks.openApiGenerate
+  }
+
+  // TODO Most likely temporary, due to historical pushback on adding Jackson 
deps to solrj, but it does _hugely_
+  //  simplify the parsing code and there are new compelling reasons, given 
the claims around CBOR performance relative
+  //  to JSON, javabin, etc.
+  implementation 'com.fasterxml.jackson.core:jackson-databind' // Came from a 
testImplementation line below.

Review Comment:
   Great!
   
   In terms of how to handle this, do you think it'd be better to shade the 
Jackson dep (increasing solrj's size but avoiding the jackson-dep-conflict 
issue), or include Jackson as a "normal" (i.e. unshaded) dependency?



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