Skip to content

Conversation

@miguelgrinberg
Copy link
Contributor

@miguelgrinberg miguelgrinberg commented Dec 2, 2025

This should more or less support the use of Java in CI and local usage, including the request converter CLI.

I have added a JavaExporter class based on the usage.js example. To ensure that this class only appears as a valid exporter in CI, I have added an optional method that exporters can implement called available(). If this is present, the method is called and if it returns false then the exporter is not loaded. The implementation that I'm using only reports Java as available when the JAVA_ES_REQUEST_CONVERTER_JAR environment variable is set. This variable is passed to the Java caller.

Some things will need to be adjusted once the Java converter is ready, but overall I think all the wrapper pieces around the jar file are in place in this PR.

@l-trotta There is a lot of changes in this PR. A lot of it is more related to making Java appear the same as the other languages in spite of its implementation differences. The Java specific logic is in the src/exporters/java.ts file (a TypeScript wrapper around your jar file that is based on the usage.js example you created) and on test/integration/run-java.sh (the bash script that compiles and executes an exported complete script against the test server). We can walk over the changes together if that will make it easier to review.

<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>9.2.0</version>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<version>9.2.0</version>
<version>9.2.2</version>

Copy link
Contributor Author

@miguelgrinberg miguelgrinberg Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@l-trotta Here what I do for all the other languages is use a cloned copy of the source code. Because the CI runs on the main version of the spec, so it is more correct to run it on the unreleased clients that will eventually be 9.3 then on the released 9.2.

In the run-java.sh script I'm cloning the java client, but I haven't looked into how to include it here as a locally installed dependency. I hope it is possible?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, ignore the change then. to get it locally the dependency must have been previously published to the local .m2 repo running mvn install in the project folder, then I think maven will try and get it by default if it's available, no modifications needed to the pom.

Comment on lines +53 to +93
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.6.1</version>
</plugin>
<plugin>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are all of these used somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is a template pom.xml file that I generated a while ago, I believe using maven. We can prune all the stuff that isn't needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants