Skip to content

Conversation

@MariusVolkhart
Copy link
Contributor

I've been working on a prototype to enable multiple JRE variants to be built. My use case is wanted to make JREs for different OS, but this could also be used for different Java versions. It ends up looking something like:

val v = "jdk-19.0.2+7"
jlinkJre {
	modules.set(
		setOf(
			"java.base",
			"java.compiler",
			"java.desktop",
			"java.management",
			"java.naming",
			"java.rmi",
			"java.scripting",
			"java.sql",
			"jdk.jfr",
			"jdk.unsupported",

			// Debugging support
			"jdk.jdwp.agent",
			"jdk.management.agent",
		)
	)

	variants {
		register("s390x_linux") {
			version.set(v)
			endian.set(Endian.BIG)
			operatingSystem.set(LINUX)
		}

		register("x64_linux") {
			version.set(v)
			operatingSystem.set(LINUX)
		}

		register("x64_mac") {
			version.set(v)
			operatingSystem.set(MAC)
		}

		register("x64_windows") {
			version.set(v)
			operatingSystem.set(WINDOWS)
		}
	}
}

This requires the temurin-binaries-repository plugin (or similar logic) to be applied.

I haven't written tests yet, but have tried it out in and it generally works as expected. I'd like to know if this is:

  1. A concept you're interested in accepting
  2. Is this approach good/acceptable? Is there a better way? Other ideas? etc. I'm happy to go back & forth on this a bit.

If generally "yes, keep working on it", I'll start on tests while implementation details get ironed out.

@ryandens
Copy link
Owner

ryandens commented Mar 6, 2023

I'm playing around with a similar concept, and this is generally the reason why I started working on this plugin! I'm trying to figure out the best way to integrate this so it conforms with both of the models for the jib's "platforms" and the application plugin's distribution container. For the application plugin, one way I got it to work well was by leaving the "main" distribution untouched and depending on an external JRE, and creating alternate distributions for each platform. But, I'm still not sure how I feel about that. This variant concept seems to map quite closely to jib's concept of platforms: https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#how-do-i-specify-a-platform-in-the-manifest-list-or-oci-index-of-a-base-image

All in all:

  1. Definitely want to solve this problem!
  2. Unsure about the current approach, I expect it to take some iteration. Feel free to keep at it, but of course no guarantees I'll be able to accept it. The vision I have for this plugin is being able to configure it in the way you describe, while also effectively mapping it to application plugin distributions and container images. Integrating this into jib's platform support so that the plugin injects the appropriate JRE into the container image for that platform with minimal configuration would be great. JIb's platform support is incubating, so anything we build on this will have to be flexible to change

Each variant gets a distribution. The variant distributions inherit inputs from the main distribution.
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.

2 participants