use of io.quarkus.deployment.pkg.builditem.CompiledJavaVersionBuildItem in project quarkus by quarkusio.
the class S2iProcessor method s2iRequirementsJvm.
@BuildStep(onlyIf = { IsNormalNotRemoteDev.class, S2iBuild.class }, onlyIfNot = NativeBuild.class)
public void s2iRequirementsJvm(S2iConfig s2iConfig, CurateOutcomeBuildItem curateOutcomeBuildItem, OutputTargetBuildItem out, PackageConfig packageConfig, JarBuildItem jarBuildItem, CompiledJavaVersionBuildItem compiledJavaVersion, BuildProducer<KubernetesEnvBuildItem> envProducer, BuildProducer<BaseImageInfoBuildItem> builderImageProducer, BuildProducer<KubernetesCommandBuildItem> commandProducer) {
final Collection<ResolvedDependency> appDeps = curateOutcomeBuildItem.getApplicationModel().getRuntimeDependencies();
String outputJarFileName = jarBuildItem.getPath().getFileName().toString();
String classpath = appDeps.stream().map(d -> d.getGroupId() + "." + d.getResolvedPaths().getSinglePath().getFileName()).map(s -> concatUnixPaths(s2iConfig.jarDirectory, "lib", s)).collect(Collectors.joining(":"));
String jarFileName = s2iConfig.jarFileName.orElse(outputJarFileName);
String jarDirectory = s2iConfig.jarDirectory;
String pathToJar = concatUnixPaths(jarDirectory, jarFileName);
String baseJvmImage = s2iConfig.baseJvmImage.orElse(S2iConfig.getDefaultJvmImage(compiledJavaVersion.getJavaVersion()));
builderImageProducer.produce(new BaseImageInfoBuildItem(baseJvmImage));
Optional<S2iBaseJavaImage> baseImage = S2iBaseJavaImage.findMatching(baseJvmImage);
baseImage.ifPresent(b -> {
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getJarEnvVar(), pathToJar, OPENSHIFT));
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getJarLibEnvVar(), concatUnixPaths(jarDirectory, "lib"), OPENSHIFT));
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getClasspathEnvVar(), classpath, OPENSHIFT));
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getJvmOptionsEnvVar(), String.join(" ", s2iConfig.getEffectiveJvmArguments()), OPENSHIFT));
});
if (!baseImage.isPresent()) {
List<String> cmd = new ArrayList<>();
cmd.add("java");
cmd.addAll(s2iConfig.getEffectiveJvmArguments());
cmd.addAll(Arrays.asList("-jar", pathToJar, "-cp", classpath));
commandProducer.produce(KubernetesCommandBuildItem.command(cmd));
}
}
Aggregations