use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class BuildFilesTest method testToBuildFileSpec_templateMultiLineBehavior.
@Test
public void testToBuildFileSpec_templateMultiLineBehavior() throws URISyntaxException, InvalidImageReferenceException, IOException {
Path buildfile = Paths.get(Resources.getResource("buildfiles/projects/templating/multiLine.yaml").toURI());
Mockito.when(buildCli.getTemplateParameters()).thenReturn(ImmutableMap.of("replace" + System.lineSeparator() + "this", "creationTime: 1234"));
JibContainerBuilder jibContainerBuilder = BuildFiles.toJibContainerBuilder(buildfile.getParent(), buildfile, buildCli, commonCliOptions, consoleLogger);
ContainerBuildPlan resolved = jibContainerBuilder.toContainerBuildPlan();
Assert.assertEquals(Instant.ofEpochMilli(1234), resolved.getCreationTime());
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class BuildFilesTest method testToBuildFileSpec_alternativeRootContext.
@Test
public void testToBuildFileSpec_alternativeRootContext() throws URISyntaxException, InvalidImageReferenceException, IOException {
Path buildfile = Paths.get(Resources.getResource("buildfiles/projects/allProperties/altYamls/alt-jib.yaml").toURI());
Path projectRoot = buildfile.getParent().getParent();
JibContainerBuilder jibContainerBuilder = BuildFiles.toJibContainerBuilder(projectRoot, buildfile, buildCli, commonCliOptions, consoleLogger);
ContainerBuildPlan resolved = jibContainerBuilder.toContainerBuildPlan();
Assert.assertEquals(FileEntriesLayer.builder().addEntry(projectRoot.resolve("project/script.sh"), AbsoluteUnixPath.get("/home/script.sh")).build().getEntries(), ((FileEntriesLayer) resolved.getLayers().get(0)).getEntries());
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testEntrypoint_warningOnMainclassForWar.
@Test
public void testEntrypoint_warningOnMainclassForWar() throws IOException, InvalidCreationTimeException, InvalidImageReferenceException, IncompatibleBaseImageJavaVersionException, InvalidPlatformException, InvalidContainerVolumeException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidFilesModificationTimeException, InvalidContainerizingModeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getMainClass()).thenReturn(Optional.of("java.util.Object"));
when(projectProperties.isWarProject()).thenReturn(true);
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-jar", "/usr/local/jetty/start.jar").inOrder();
verify(projectProperties).log(LogEvent.warn("mainClass, extraClasspath, jvmFlags, and expandClasspathDependencies " + "are ignored for WAR projects"));
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testEntrypoint_warningOnExpandClasspathDependenciesForWar.
@Test
public void testEntrypoint_warningOnExpandClasspathDependenciesForWar() throws IOException, InvalidCreationTimeException, InvalidImageReferenceException, IncompatibleBaseImageJavaVersionException, InvalidPlatformException, InvalidContainerVolumeException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidFilesModificationTimeException, InvalidContainerizingModeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getExpandClasspathDependencies()).thenReturn(true);
when(projectProperties.isWarProject()).thenReturn(true);
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-jar", "/usr/local/jetty/start.jar").inOrder();
verify(projectProperties).log(LogEvent.warn("mainClass, extraClasspath, jvmFlags, and expandClasspathDependencies " + "are ignored for WAR projects"));
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testEntrypoint_warningOnJvmFlags.
@Test
public void testEntrypoint_warningOnJvmFlags() 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.getJvmFlags()).thenReturn(Collections.singletonList("jvmFlag"));
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"));
}
Aggregations