use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibOwnershipExtensionTest method testExtendContainerBuildPlan_noGlobGiven.
@Test
public void testExtendContainerBuildPlan_noGlobGiven() {
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().build();
Configuration.Rule rule = mockRule("", "doesn't matter");
when(config.getRules()).thenReturn(Arrays.asList(rule));
try {
new JibOwnershipExtension().extendContainerBuildPlan(buildPlan, null, Optional.of(config), null, logger);
fail();
} catch (JibPluginExtensionException ex) {
assertEquals(JibOwnershipExtension.class, ex.getExtensionClass());
assertEquals("glob pattern not given in ownership configuration", ex.getMessage());
}
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib-extensions by GoogleContainerTools.
the class JibSpringBootExtensionTest method testExtendContainerBuildPlan_noFiltering.
@Test
public void testExtendContainerBuildPlan_noFiltering() throws JibPluginExtensionException {
// set up <excludeDevtools>false (no filtering required)
Xpp3Dom configuration = new Xpp3Dom("configuration");
Xpp3Dom excludeDevtools = new Xpp3Dom("excludeDevtools");
excludeDevtools.setValue("false");
configuration.addChild(excludeDevtools);
when(project.getPlugin("org.springframework.boot:spring-boot-maven-plugin")).thenReturn(bootPlugin);
when(bootPlugin.getConfiguration()).thenReturn(configuration);
FileEntriesLayer layer1 = buildLayer("dependencies", Paths.get("spring-boot-devtools-1.2.3.jar"), Paths.get("archive").resolve("bar.zip"));
FileEntriesLayer layer2 = buildLayer("NOT dependencies", Paths.get("spring-boot-devtools-1.2.3.jar"));
ContainerBuildPlan buildPlan = ContainerBuildPlan.builder().addLayer(layer1).addLayer(layer2).build();
ContainerBuildPlan newPlan = new JibSpringBootExtension().extendContainerBuildPlan(buildPlan, null, Optional.empty(), mavenData, logger);
assertSame(buildPlan, newPlan);
verify(logger).log(LogLevel.INFO, "Keeping spring-boot-devtools (if any)");
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
the class PluginConfigurationProcessorTest method testEntrypoint_defaultNonWarPackaging.
@Test
public void testEntrypoint_defaultNonWarPackaging() throws IOException, InvalidImageReferenceException, MainClassInferenceException, InvalidAppRootException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, NumberFormatException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(projectProperties.isWarProject()).thenReturn(false);
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-cp", "/app/resources:/app/classes:/app/libs/*", "java.lang.Object").inOrder();
ArgumentMatcher<LogEvent> isLogWarn = logEvent -> logEvent.getLevel() == LogEvent.Level.WARN;
verify(logger, never()).accept(argThat(isLogWarn));
}
use of com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan in project jib by google.
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 google.
the class PluginConfigurationProcessorTest method testClasspathArgumentFile.
@Test
public void testClasspathArgumentFile() throws NumberFormatException, InvalidImageReferenceException, MainClassInferenceException, InvalidAppRootException, IOException, InvalidWorkingDirectoryException, InvalidPlatformException, InvalidContainerVolumeException, IncompatibleBaseImageJavaVersionException, InvalidContainerizingModeException, InvalidFilesModificationTimeException, InvalidCreationTimeException, ExtraDirectoryNotFoundException {
when(rawConfiguration.getExtraClasspath()).thenReturn(Collections.singletonList("/foo"));
when(projectProperties.getMajorJavaVersion()).thenReturn(9);
ContainerBuildPlan buildPlan = processCommonConfiguration();
assertThat(buildPlan.getEntrypoint()).containsExactly("java", "-cp", "@/app/jib-classpath-file", "java.lang.Object").inOrder();
List<FileEntry> jvmArgFiles = getLayerEntries(buildPlan, "jvm arg files");
assertThat(jvmArgFiles).comparingElementsUsing(SOURCE_FILE_OF).containsExactly(appCacheDirectory.resolve("jib-classpath-file"), appCacheDirectory.resolve("jib-main-class-file"));
assertThat(jvmArgFiles).comparingElementsUsing(EXTRACTION_PATH_OF).containsExactly("/app/jib-classpath-file", "/app/jib-main-class-file");
String classpath = new String(Files.readAllBytes(appCacheDirectory.resolve("jib-classpath-file")), StandardCharsets.UTF_8);
assertThat(classpath).isEqualTo("/foo:/app/resources:/app/classes:/app/libs/foo-1.jar:/app/libs/bar-2.jar");
String mainClass = new String(Files.readAllBytes(appCacheDirectory.resolve("jib-main-class-file")), StandardCharsets.UTF_8);
assertThat(mainClass).isEqualTo("java.lang.Object");
}
Aggregations