use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by GoogleContainerTools.
the class PluginConfigurationProcessorTest method testEntrypoint_warningOnExpandClasspathDependencies.
@Test
public void testEntrypoint_warningOnExpandClasspathDependencies() throws InvalidImageReferenceException, IOException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getEntrypoint()).thenReturn(Optional.of(Arrays.asList("custom", "entrypoint")));
when(rawConfiguration.getExpandClasspathDependencies()).thenReturn(true);
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("custom", "entrypoint").inOrder();
verify(projectProperties).log(LogEvent.warn("mainClass, extraClasspath, jvmFlags, and expandClasspathDependencies are ignored " + "when entrypoint is specified"));
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by GoogleContainerTools.
the class PluginConfigurationProcessorTest method testEntrypoint_defaultWarPackaging.
@Test
public void testEntrypoint_defaultWarPackaging() throws IOException, InvalidImageReferenceException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(projectProperties.isWarProject()).thenReturn(true);
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-jar", "/usr/local/jetty/start.jar").inOrder();
verifyNoInteractions(logger);
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by GoogleContainerTools.
the class PluginConfigurationProcessorTest method testEntrypoint_warningOnMainclass.
@Test
public void testEntrypoint_warningOnMainclass() throws InvalidImageReferenceException, IOException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getEntrypoint()).thenReturn(Optional.of(Arrays.asList("custom", "entrypoint")));
when(rawConfiguration.getMainClass()).thenReturn(Optional.of("java.util.Object"));
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("custom", "entrypoint").inOrder();
verify(projectProperties).log(LogEvent.warn("mainClass, extraClasspath, jvmFlags, and expandClasspathDependencies are ignored " + "when entrypoint is specified"));
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by GoogleContainerTools.
the class MavenProjectProperties method runPluginExtensions.
@Override
public JibContainerBuilder runPluginExtensions(List<? extends ExtensionConfiguration> extensionConfigs, JibContainerBuilder jibContainerBuilder) throws JibPluginExtensionException {
if (extensionConfigs.isEmpty()) {
log(LogEvent.debug("No Jib plugin extensions configured to load"));
return jibContainerBuilder;
}
// Add the injected extensions at first to prefer them over the ones from JDK service
// loader.
// Extensions might support both approaches (injection and JDK service loader) at the same
// time for compatibility reasons.
List<JibMavenPluginExtension<?>> loadedExtensions = new ArrayList<>(injectedExtensions);
loadedExtensions.addAll(extensionLoader.get());
JibMavenPluginExtension<?> extension = null;
ContainerBuildPlan buildPlan = jibContainerBuilder.toContainerBuildPlan();
try {
for (ExtensionConfiguration config : extensionConfigs) {
extension = findConfiguredExtension(loadedExtensions, config);
log(LogEvent.lifecycle("Running extension: " + config.getExtensionClass()));
buildPlan = runPluginExtension(extension.getExtraConfigType(), extension, config, buildPlan);
// to validate image reference
ImageReference.parse(buildPlan.getBaseImage());
}
return jibContainerBuilder.applyContainerBuildPlan(buildPlan);
} catch (InvalidImageReferenceException ex) {
throw new JibPluginExtensionException(Verify.verifyNotNull(extension).getClass(), "invalid base image reference: " + buildPlan.getBaseImage(), ex);
}
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibQuarkusExtensionTest method testExtendContainerBuildPlan_entrypoint.
@Test
public void testExtendContainerBuildPlan_entrypoint() throws JibPluginExtensionException {
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().build();
ContainerBuildPlan newPlan = new JibQuarkusExtension().extendContainerBuildPlan(buildPlan, null, Optional.empty(), mavenData, logger);
assertEquals(Arrays.asList("java", "-verbose:gc", "-Dmy.property=value", "-jar", "/new/appRoot/app.jar"), newPlan.getEntrypoint());
}
Aggregations