use of com.google.cloud.tools.jib.plugins.extension.ExtensionLogger in project jib-extensions by GoogleContainerTools.
the class JibQuarkusExtension method extendContainerBuildPlan.
@Override
public ContainerBuildPlan extendContainerBuildPlan(ContainerBuildPlan buildPlan, Map<String, String> properties, Optional<Void> config, MavenData mavenData, ExtensionLogger logger) throws JibPluginExtensionException {
try {
logger.log(LogLevel.LIFECYCLE, "Running Quarkus Jib extension");
readJibConfigurations(mavenData.getMavenProject());
Build build = mavenData.getMavenProject().getBuild();
Path outputDirectory = Paths.get(build.getDirectory());
Path jar = outputDirectory.resolve(build.getFinalName() + "-runner.jar");
if (!Files.isRegularFile(jar)) {
throw new JibPluginExtensionException(getClass(), jar + " doesn't exist; did you run the Qaurkus Maven plugin " + "('compile' and 'quarkus:build' Maven goals)?");
}
ContainerBuildPlan.Builder planBuilder = buildPlan.toBuilder();
planBuilder.setLayers(Collections.emptyList());
// dependency layers
addDependencyLayers(mavenData.getMavenSession(), planBuilder, outputDirectory.resolve("lib"));
// Quarkus runner JAR layer
AbsoluteUnixPath appRootJar = appRoot.resolve("app.jar");
FileEntriesLayer jarLayer = FileEntriesLayer.builder().setName("quarkus jar").addEntry(jar, appRootJar).build();
planBuilder.addLayer(jarLayer);
// Preserve extra directories layers.
String extraFilesLayerName = JavaContainerBuilder.LayerType.EXTRA_FILES.getName();
buildPlan.getLayers().stream().filter(layer -> layer.getName().startsWith(extraFilesLayerName)).forEach(planBuilder::addLayer);
// set entrypoint
List<String> entrypoint = new ArrayList<>();
entrypoint.add("java");
entrypoint.addAll(jvmFlags);
entrypoint.add("-jar");
entrypoint.add(appRootJar.toString());
planBuilder.setEntrypoint(entrypoint);
return planBuilder.build();
} catch (IOException ex) {
throw new JibPluginExtensionException(getClass(), Verify.verifyNotNull(ex.getMessage()), ex);
}
}
Aggregations