Search in sources :

Example 6 with JavaContainerBuilder

use of com.google.cloud.tools.jib.api.JavaContainerBuilder in project jib by google.

the class MavenProjectProperties method createJibContainerBuilder.

@Override
public JibContainerBuilder createJibContainerBuilder(JavaContainerBuilder javaContainerBuilder, ContainerizingMode containerizingMode) throws IOException {
    try {
        if (isWarProject()) {
            Path war = getWarArtifact();
            Path explodedWarPath = tempDirectoryProvider.newDirectory();
            ZipUtil.unzip(war, explodedWarPath);
            return JavaContainerBuilderHelper.fromExplodedWar(javaContainerBuilder, explodedWarPath, getProjectDependencies().stream().map(Artifact::getFile).map(File::getName).collect(Collectors.toSet()));
        }
        switch(containerizingMode) {
            case EXPLODED:
                // Add resources, and classes
                Path classesOutputDirectory = Paths.get(project.getBuild().getOutputDirectory());
                // Don't use Path.endsWith(), since Path works on path elements.
                Predicate<Path> isClassFile = path -> path.getFileName().toString().endsWith(".class");
                javaContainerBuilder.addResources(classesOutputDirectory, isClassFile.negate()).addClasses(classesOutputDirectory, isClassFile);
                break;
            case PACKAGED:
                // Add a JAR
                javaContainerBuilder.addToClasspath(getJarArtifact());
                break;
            default:
                throw new IllegalStateException("unknown containerizing mode: " + containerizingMode);
        }
        // Classify and add dependencies
        Map<LayerType, List<Path>> classifiedDependencies = classifyDependencies(project.getArtifacts(), getProjectDependencies());
        javaContainerBuilder.addDependencies(Preconditions.checkNotNull(classifiedDependencies.get(LayerType.DEPENDENCIES)));
        javaContainerBuilder.addSnapshotDependencies(Preconditions.checkNotNull(classifiedDependencies.get(LayerType.SNAPSHOT_DEPENDENCIES)));
        javaContainerBuilder.addProjectDependencies(Preconditions.checkNotNull(classifiedDependencies.get(LayerType.PROJECT_DEPENDENCIES)));
        return javaContainerBuilder.toContainerBuilder();
    } catch (IOException ex) {
        throw new IOException("Obtaining project build output files failed; make sure you have " + (isPackageErrorMessage(containerizingMode) ? "packaged" : "compiled") + " your project " + "before trying to build the image. (Did you accidentally run \"mvn clean " + "jib:build\" instead of \"mvn clean " + (isPackageErrorMessage(containerizingMode) ? "package" : "compile") + " jib:build\"?)", ex);
    }
}
Also used : Path(java.nio.file.Path) JibMavenPluginExtension(com.google.cloud.tools.jib.maven.extension.JibMavenPluginExtension) JavaContainerBuilderHelper(com.google.cloud.tools.jib.plugins.common.JavaContainerBuilderHelper) ImageReference(com.google.cloud.tools.jib.api.ImageReference) SingleThreadedExecutor(com.google.cloud.tools.jib.plugins.common.logging.SingleThreadedExecutor) ProgressEvent(com.google.cloud.tools.jib.event.events.ProgressEvent) PropertyNames(com.google.cloud.tools.jib.plugins.common.PropertyNames) JavaContainerBuilder(com.google.cloud.tools.jib.api.JavaContainerBuilder) LayerType(com.google.cloud.tools.jib.api.JavaContainerBuilder.LayerType) TimerEventHandler(com.google.cloud.tools.jib.plugins.common.TimerEventHandler) MavenProject(org.apache.maven.project.MavenProject) Duration(java.time.Duration) Map(java.util.Map) Artifact(org.apache.maven.artifact.Artifact) Path(java.nio.file.Path) Verify(com.google.common.base.Verify) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) ServiceLoader(java.util.ServiceLoader) TimerEvent(com.google.cloud.tools.jib.event.events.TimerEvent) InvalidImageReferenceException(com.google.cloud.tools.jib.api.InvalidImageReferenceException) PluginExtensionLogger(com.google.cloud.tools.jib.plugins.common.PluginExtensionLogger) Collectors(java.util.stream.Collectors) ZipUtil(com.google.cloud.tools.jib.plugins.common.ZipUtil) ContainerizingMode(com.google.cloud.tools.jib.plugins.common.ContainerizingMode) ProjectProperties(com.google.cloud.tools.jib.plugins.common.ProjectProperties) List(java.util.List) ProgressDisplayGenerator(com.google.cloud.tools.jib.plugins.common.logging.ProgressDisplayGenerator) Optional(java.util.Optional) ContainerBuildPlan(com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan) ConsoleLogger(com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger) NullExtension(com.google.cloud.tools.jib.plugins.extension.NullExtension) PluginExecution(org.apache.maven.model.PluginExecution) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) HashMap(java.util.HashMap) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Build(org.apache.maven.model.Build) JibPluginExtensionException(com.google.cloud.tools.jib.plugins.extension.JibPluginExtensionException) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ExtensionConfiguration(com.google.cloud.tools.jib.plugins.common.RawConfiguration.ExtensionConfiguration) Os(org.apache.maven.shared.utils.Os) PluginDescriptor(org.apache.maven.plugin.descriptor.PluginDescriptor) TempDirectoryProvider(com.google.cloud.tools.jib.filesystem.TempDirectoryProvider) Nullable(javax.annotation.Nullable) ConsoleLoggerBuilder(com.google.cloud.tools.jib.plugins.common.logging.ConsoleLoggerBuilder) MavenSession(org.apache.maven.execution.MavenSession) Files(java.nio.file.Files) DirectoryWalker(com.google.cloud.tools.jib.filesystem.DirectoryWalker) IOException(java.io.IOException) ProgressEventHandler(com.google.cloud.tools.jib.event.progress.ProgressEventHandler) Log(org.apache.maven.plugin.logging.Log) File(java.io.File) LogEvent(com.google.cloud.tools.jib.api.LogEvent) Plugin(org.apache.maven.model.Plugin) Containerizer(com.google.cloud.tools.jib.api.Containerizer) Paths(java.nio.file.Paths) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) LayerType(com.google.cloud.tools.jib.api.JavaContainerBuilder.LayerType) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File)

Example 7 with JavaContainerBuilder

use of com.google.cloud.tools.jib.api.JavaContainerBuilder in project jib by google.

the class GradleProjectPropertiesTest method setupBuildContext.

private BuildContext setupBuildContext() throws InvalidImageReferenceException, CacheDirectoryCreationException {
    JavaContainerBuilder javaContainerBuilder = JavaContainerBuilder.from(RegistryImage.named("base")).setAppRoot(AbsoluteUnixPath.get("/my/app")).setModificationTimeProvider((ignored1, ignored2) -> EPOCH_PLUS_32);
    JibContainerBuilder jibContainerBuilder = gradleProjectProperties.createJibContainerBuilder(javaContainerBuilder, ContainerizingMode.EXPLODED);
    return JibContainerBuilderTestHelper.toBuildContext(jibContainerBuilder, Containerizer.to(RegistryImage.named("to")));
}
Also used : JavaContainerBuilder(com.google.cloud.tools.jib.api.JavaContainerBuilder) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder)

Example 8 with JavaContainerBuilder

use of com.google.cloud.tools.jib.api.JavaContainerBuilder in project jib by google.

the class JavaContainerBuilderHelper method fromExplodedWar.

/**
 * Constructs a new {@link JibContainerBuilder} for a WAR project.
 *
 * @param javaContainerBuilder Java container builder to start with
 * @param explodedWar the exploded WAR directory
 * @param projectArtifactFilename the file names of project artifacts for project dependencies
 * @return {@link JibContainerBuilder} containing the layers for the exploded WAR
 * @throws IOException if adding layer contents fails
 */
public static JibContainerBuilder fromExplodedWar(JavaContainerBuilder javaContainerBuilder, Path explodedWar, Set<String> projectArtifactFilename) throws IOException {
    Path webInfLib = explodedWar.resolve("WEB-INF/lib");
    Path webInfClasses = explodedWar.resolve("WEB-INF/classes");
    Predicate<Path> isDependency = path -> path.startsWith(webInfLib);
    Predicate<Path> isClassFile = // Don't use Path.endsWith(), since Path works on path elements.
    path -> path.startsWith(webInfClasses) && path.getFileName().toString().endsWith(".class");
    Predicate<Path> isResource = isDependency.or(isClassFile).negate();
    Predicate<Path> isSnapshot = path -> path.getFileName().toString().contains("SNAPSHOT");
    Predicate<Path> isProjectDependency = path -> projectArtifactFilename.contains(path.getFileName().toString());
    javaContainerBuilder.setResourcesDestination(RelativeUnixPath.get("")).setClassesDestination(RelativeUnixPath.get("WEB-INF/classes")).setDependenciesDestination(RelativeUnixPath.get("WEB-INF/lib"));
    if (Files.exists(explodedWar)) {
        javaContainerBuilder.addResources(explodedWar, isResource);
    }
    if (Files.exists(webInfClasses)) {
        javaContainerBuilder.addClasses(webInfClasses, isClassFile);
    }
    if (Files.exists(webInfLib)) {
        javaContainerBuilder.addDependencies(new DirectoryWalker(webInfLib).filterRoot().filter(isSnapshot.negate()).filter(isProjectDependency.negate()).walk());
        javaContainerBuilder.addSnapshotDependencies(new DirectoryWalker(webInfLib).filterRoot().filter(isSnapshot).walk());
        javaContainerBuilder.addProjectDependencies(new DirectoryWalker(webInfLib).filterRoot().filter(isProjectDependency).walk());
    }
    return javaContainerBuilder.toContainerBuilder();
}
Also used : AbsoluteUnixPath(com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath) RelativeUnixPath(com.google.cloud.tools.jib.api.buildplan.RelativeUnixPath) Path(java.nio.file.Path) AbsoluteUnixPath(com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) Files(java.nio.file.Files) Predicate(java.util.function.Predicate) FilePermissions(com.google.cloud.tools.jib.api.buildplan.FilePermissions) Set(java.util.Set) DirectoryWalker(com.google.cloud.tools.jib.filesystem.DirectoryWalker) IOException(java.io.IOException) JavaContainerBuilder(com.google.cloud.tools.jib.api.JavaContainerBuilder) FileEntriesLayer(com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer) ModificationTimeProvider(com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider) Instant(java.time.Instant) LinkedHashMap(java.util.LinkedHashMap) LayerType(com.google.cloud.tools.jib.api.JavaContainerBuilder.LayerType) List(java.util.List) Paths(java.nio.file.Paths) Map(java.util.Map) RelativeUnixPath(com.google.cloud.tools.jib.api.buildplan.RelativeUnixPath) PathMatcher(java.nio.file.PathMatcher) Optional(java.util.Optional) Path(java.nio.file.Path) FileSystems(java.nio.file.FileSystems) DirectoryWalker(com.google.cloud.tools.jib.filesystem.DirectoryWalker)

Example 9 with JavaContainerBuilder

use of com.google.cloud.tools.jib.api.JavaContainerBuilder in project jib by google.

the class GradleProjectProperties method createJibContainerBuilder.

@Override
public JibContainerBuilder createJibContainerBuilder(JavaContainerBuilder javaContainerBuilder, ContainerizingMode containerizingMode) {
    try {
        FileCollection projectDependencies = project.files(project.getConfigurations().getByName(configurationName).getResolvedConfiguration().getResolvedArtifacts().stream().filter(artifact -> artifact.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier).map(ResolvedArtifact::getFile).collect(Collectors.toList()));
        if (isWarProject()) {
            String warFilePath = getWarFilePath();
            log(LogEvent.info("WAR project identified, creating WAR image from: " + warFilePath));
            Path explodedWarPath = tempDirectoryProvider.newDirectory();
            ZipUtil.unzip(Paths.get(warFilePath), explodedWarPath);
            return JavaContainerBuilderHelper.fromExplodedWar(javaContainerBuilder, explodedWarPath, projectDependencies.getFiles().stream().map(File::getName).collect(Collectors.toSet()));
        }
        SourceSet mainSourceSet = getMainSourceSet();
        FileCollection classesOutputDirectories = mainSourceSet.getOutput().getClassesDirs().filter(File::exists);
        Path resourcesOutputDirectory = mainSourceSet.getOutput().getResourcesDir().toPath();
        FileCollection allFiles = project.getConfigurations().getByName(configurationName).filter(File::exists);
        FileCollection nonProjectDependencies = allFiles.minus(classesOutputDirectories).minus(projectDependencies).filter(file -> !file.toPath().equals(resourcesOutputDirectory));
        FileCollection snapshotDependencies = nonProjectDependencies.filter(file -> file.getName().contains("SNAPSHOT"));
        FileCollection dependencies = nonProjectDependencies.minus(snapshotDependencies);
        // Adds dependency files
        javaContainerBuilder.addDependencies(dependencies.getFiles().stream().map(File::toPath).collect(Collectors.toList())).addSnapshotDependencies(snapshotDependencies.getFiles().stream().map(File::toPath).collect(Collectors.toList())).addProjectDependencies(projectDependencies.getFiles().stream().map(File::toPath).collect(Collectors.toList()));
        switch(containerizingMode) {
            case EXPLODED:
                // Adds resource files
                if (Files.exists(resourcesOutputDirectory)) {
                    javaContainerBuilder.addResources(resourcesOutputDirectory);
                }
                // Adds class files
                for (File classesOutputDirectory : classesOutputDirectories) {
                    javaContainerBuilder.addClasses(classesOutputDirectory.toPath());
                }
                if (classesOutputDirectories.isEmpty()) {
                    log(LogEvent.warn("No classes files were found - did you compile your project?"));
                }
                break;
            case PACKAGED:
                // Add a JAR
                Jar jarTask = (Jar) project.getTasks().findByName("jar");
                Path jarPath = jarTask.getArchiveFile().get().getAsFile().toPath();
                log(LogEvent.debug("Using JAR: " + jarPath));
                javaContainerBuilder.addToClasspath(jarPath);
                break;
            default:
                throw new IllegalStateException("unknown containerizing mode: " + containerizingMode);
        }
        return javaContainerBuilder.toContainerBuilder();
    } catch (IOException ex) {
        throw new GradleException("Obtaining project build output files failed", ex);
    }
}
Also used : JavaContainerBuilderHelper(com.google.cloud.tools.jib.plugins.common.JavaContainerBuilderHelper) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) ImageReference(com.google.cloud.tools.jib.api.ImageReference) SingleThreadedExecutor(com.google.cloud.tools.jib.plugins.common.logging.SingleThreadedExecutor) ProgressEvent(com.google.cloud.tools.jib.event.events.ProgressEvent) PropertyNames(com.google.cloud.tools.jib.plugins.common.PropertyNames) JavaContainerBuilder(com.google.cloud.tools.jib.api.JavaContainerBuilder) TimerEventHandler(com.google.cloud.tools.jib.plugins.common.TimerEventHandler) Task(org.gradle.api.Task) Provider(org.gradle.api.provider.Provider) TaskProvider(org.gradle.api.tasks.TaskProvider) Locale(java.util.Locale) Duration(java.time.Duration) Path(java.nio.file.Path) Verify(com.google.common.base.Verify) Project(org.gradle.api.Project) Predicate(java.util.function.Predicate) ServiceLoader(java.util.ServiceLoader) TimerEvent(com.google.cloud.tools.jib.event.events.TimerEvent) InvalidImageReferenceException(com.google.cloud.tools.jib.api.InvalidImageReferenceException) PluginExtensionLogger(com.google.cloud.tools.jib.plugins.common.PluginExtensionLogger) Collectors(java.util.stream.Collectors) JavaVersion(org.gradle.api.JavaVersion) ZipUtil(com.google.cloud.tools.jib.plugins.common.ZipUtil) ContainerizingMode(com.google.cloud.tools.jib.plugins.common.ContainerizingMode) ProjectProperties(com.google.cloud.tools.jib.plugins.common.ProjectProperties) List(java.util.List) ProgressDisplayGenerator(com.google.cloud.tools.jib.plugins.common.logging.ProgressDisplayGenerator) Optional(java.util.Optional) ContainerBuildPlan(com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan) ConsoleLogger(com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger) NullExtension(com.google.cloud.tools.jib.plugins.extension.NullExtension) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) WarPlugin(org.gradle.api.plugins.WarPlugin) JibPluginExtensionException(com.google.cloud.tools.jib.plugins.extension.JibPluginExtensionException) Supplier(java.util.function.Supplier) FileCollection(org.gradle.api.file.FileCollection) Logger(org.gradle.api.logging.Logger) ArrayList(java.util.ArrayList) SourceSet(org.gradle.api.tasks.SourceSet) ExtensionConfiguration(com.google.cloud.tools.jib.plugins.common.RawConfiguration.ExtensionConfiguration) TempDirectoryProvider(com.google.cloud.tools.jib.filesystem.TempDirectoryProvider) Nullable(javax.annotation.Nullable) ConsoleLoggerBuilder(com.google.cloud.tools.jib.plugins.common.logging.ConsoleLoggerBuilder) Action(org.gradle.api.Action) Files(java.nio.file.Files) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) Jar(org.gradle.jvm.tasks.Jar) DirectoryWalker(com.google.cloud.tools.jib.filesystem.DirectoryWalker) IOException(java.io.IOException) ProgressEventHandler(com.google.cloud.tools.jib.event.progress.ProgressEventHandler) File(java.io.File) LogEvent(com.google.cloud.tools.jib.api.LogEvent) Os(org.apache.tools.ant.taskdefs.condition.Os) Containerizer(com.google.cloud.tools.jib.api.Containerizer) JibGradlePluginExtension(com.google.cloud.tools.jib.gradle.extension.JibGradlePluginExtension) Paths(java.nio.file.Paths) GradleException(org.gradle.api.GradleException) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Path(java.nio.file.Path) SourceSet(org.gradle.api.tasks.SourceSet) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) GradleException(org.gradle.api.GradleException) Jar(org.gradle.jvm.tasks.Jar) IOException(java.io.IOException) FileCollection(org.gradle.api.file.FileCollection) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) File(java.io.File)

Example 10 with JavaContainerBuilder

use of com.google.cloud.tools.jib.api.JavaContainerBuilder in project jib by google.

the class JavaContainerBuilderHelperTest method testFromExplodedWar.

@Test
public void testFromExplodedWar() throws URISyntaxException, IOException, InvalidImageReferenceException, CacheDirectoryCreationException {
    // Copy test files to a temporary directory that we can safely operate on
    Path resourceExplodedWar = Paths.get(Resources.getResource("plugins-common/exploded-war").toURI());
    FileOperations.copy(ImmutableList.of(resourceExplodedWar), temporaryFolder.getRoot().toPath());
    Path temporaryExplodedWar = temporaryFolder.getRoot().toPath().resolve("exploded-war");
    Files.createDirectories(temporaryExplodedWar.resolve("WEB-INF/classes/empty_dir"));
    Files.createFile(temporaryExplodedWar.resolve("WEB-INF/lib/project-dependency-1.0.0.jar"));
    Set<String> projectArtifacts = ImmutableSet.of("project-dependency-1.0.0.jar");
    JavaContainerBuilder javaContainerBuilder = JavaContainerBuilder.from(RegistryImage.named("base")).setAppRoot(AbsoluteUnixPath.get("/my/app"));
    JibContainerBuilder jibContainerBuilder = JavaContainerBuilderHelper.fromExplodedWar(javaContainerBuilder, temporaryExplodedWar, projectArtifacts);
    BuildContext buildContext = JibContainerBuilderTestHelper.toBuildContext(jibContainerBuilder, Containerizer.to(RegistryImage.named("target")).setExecutorService(MoreExecutors.newDirectExecutorService()));
    FileEntriesLayer resourcesLayerConfigurations = getLayerConfigurationByName(buildContext, LayerType.RESOURCES.getName());
    FileEntriesLayer classesLayerConfigurations = getLayerConfigurationByName(buildContext, LayerType.CLASSES.getName());
    FileEntriesLayer dependenciesLayerConfigurations = getLayerConfigurationByName(buildContext, LayerType.DEPENDENCIES.getName());
    FileEntriesLayer snapshotsLayerConfigurations = getLayerConfigurationByName(buildContext, LayerType.SNAPSHOT_DEPENDENCIES.getName());
    FileEntriesLayer projectDependenciesLayerConfigurations = getLayerConfigurationByName(buildContext, LayerType.PROJECT_DEPENDENCIES.getName());
    assertThat(projectDependenciesLayerConfigurations.getEntries()).comparingElementsUsing(SOURCE_FILE_OF).containsExactly(temporaryExplodedWar.resolve("WEB-INF/lib/project-dependency-1.0.0.jar"));
    assertThat(dependenciesLayerConfigurations.getEntries()).comparingElementsUsing(SOURCE_FILE_OF).containsExactly(temporaryExplodedWar.resolve("WEB-INF/lib/dependency-1.0.0.jar"));
    assertThat(snapshotsLayerConfigurations.getEntries()).comparingElementsUsing(SOURCE_FILE_OF).containsExactly(temporaryExplodedWar.resolve("WEB-INF/lib/dependencyX-1.0.0-SNAPSHOT.jar"));
    assertThat(resourcesLayerConfigurations.getEntries()).comparingElementsUsing(SOURCE_FILE_OF).containsExactly(temporaryExplodedWar.resolve("META-INF"), temporaryExplodedWar.resolve("META-INF/context.xml"), temporaryExplodedWar.resolve("Test.jsp"), temporaryExplodedWar.resolve("WEB-INF"), temporaryExplodedWar.resolve("WEB-INF/classes"), temporaryExplodedWar.resolve("WEB-INF/classes/empty_dir"), temporaryExplodedWar.resolve("WEB-INF/classes/package"), temporaryExplodedWar.resolve("WEB-INF/classes/package/test.properties"), temporaryExplodedWar.resolve("WEB-INF/lib"), temporaryExplodedWar.resolve("WEB-INF/web.xml"));
    assertThat(classesLayerConfigurations.getEntries()).comparingElementsUsing(SOURCE_FILE_OF).containsExactly(temporaryExplodedWar.resolve("WEB-INF/classes/HelloWorld.class"), temporaryExplodedWar.resolve("WEB-INF/classes/empty_dir"), temporaryExplodedWar.resolve("WEB-INF/classes/package"), temporaryExplodedWar.resolve("WEB-INF/classes/package/Other.class"));
    assertThat(dependenciesLayerConfigurations.getEntries()).comparingElementsUsing(EXTRACTION_PATH_OF).containsExactly("/my/app/WEB-INF/lib/dependency-1.0.0.jar");
    assertThat(snapshotsLayerConfigurations.getEntries()).comparingElementsUsing(EXTRACTION_PATH_OF).containsExactly("/my/app/WEB-INF/lib/dependencyX-1.0.0-SNAPSHOT.jar");
    assertThat(resourcesLayerConfigurations.getEntries()).comparingElementsUsing(EXTRACTION_PATH_OF).containsExactly("/my/app/META-INF", "/my/app/META-INF/context.xml", "/my/app/Test.jsp", "/my/app/WEB-INF", "/my/app/WEB-INF/classes", "/my/app/WEB-INF/classes/empty_dir", "/my/app/WEB-INF/classes/package", "/my/app/WEB-INF/classes/package/test.properties", "/my/app/WEB-INF/lib", "/my/app/WEB-INF/web.xml");
    assertThat(classesLayerConfigurations.getEntries()).comparingElementsUsing(EXTRACTION_PATH_OF).containsExactly("/my/app/WEB-INF/classes/HelloWorld.class", "/my/app/WEB-INF/classes/empty_dir", "/my/app/WEB-INF/classes/package", "/my/app/WEB-INF/classes/package/Other.class");
}
Also used : Path(java.nio.file.Path) AbsoluteUnixPath(com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath) BuildContext(com.google.cloud.tools.jib.configuration.BuildContext) JavaContainerBuilder(com.google.cloud.tools.jib.api.JavaContainerBuilder) FileEntriesLayer(com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) Test(org.junit.Test)

Aggregations

JavaContainerBuilder (com.google.cloud.tools.jib.api.JavaContainerBuilder)15 JibContainerBuilder (com.google.cloud.tools.jib.api.JibContainerBuilder)15 Path (java.nio.file.Path)11 AbsoluteUnixPath (com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath)7 IOException (java.io.IOException)7 Files (java.nio.file.Files)7 Paths (java.nio.file.Paths)7 List (java.util.List)7 Optional (java.util.Optional)7 Predicate (java.util.function.Predicate)7 DirectoryWalker (com.google.cloud.tools.jib.filesystem.DirectoryWalker)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)6 Containerizer (com.google.cloud.tools.jib.api.Containerizer)5 ImageReference (com.google.cloud.tools.jib.api.ImageReference)5 InvalidImageReferenceException (com.google.cloud.tools.jib.api.InvalidImageReferenceException)5 LogEvent (com.google.cloud.tools.jib.api.LogEvent)5 ContainerBuildPlan (com.google.cloud.tools.jib.api.buildplan.ContainerBuildPlan)4 ProgressEvent (com.google.cloud.tools.jib.event.events.ProgressEvent)4 TimerEvent (com.google.cloud.tools.jib.event.events.TimerEvent)4 ProgressEventHandler (com.google.cloud.tools.jib.event.progress.ProgressEventHandler)4