|
1 | 1 | package software.xdev.tci.demo.tci.webapp.containers; |
2 | 2 |
|
| 3 | +import java.io.IOException; |
| 4 | +import java.nio.file.Path; |
3 | 5 | import java.nio.file.Paths; |
| 6 | +import java.util.List; |
4 | 7 | import java.util.concurrent.TimeUnit; |
5 | 8 | import java.util.concurrent.TimeoutException; |
6 | 9 |
|
| 10 | +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; |
7 | 11 | import org.slf4j.Logger; |
8 | 12 | import org.slf4j.LoggerFactory; |
9 | 13 |
|
10 | 14 | import software.xdev.testcontainers.imagebuilder.AdvancedImageFromDockerFile; |
11 | 15 | import software.xdev.testcontainers.imagebuilder.compat.DockerfileCOPYParentsEmulator; |
| 16 | +import software.xdev.testcontainers.imagebuilder.transfer.fcm.FileLinesContentModifier; |
12 | 17 |
|
13 | 18 |
|
14 | 19 | @SuppressWarnings("PMD.MoreThanOneLogger") |
@@ -60,7 +65,40 @@ public static synchronized String getBuiltImageName() |
60 | 65 | .withBaseDir(Paths.get("../../")) |
61 | 66 | // File is in root directory - we can't access it |
62 | 67 | .withBaseDirRelativeIgnoreFile(null) |
63 | | - .withDockerFileLinesModifier(new DockerfileCOPYParentsEmulator()); |
| 68 | + .withDockerFileLinesModifier(new DockerfileCOPYParentsEmulator()) |
| 69 | + .withTransferArchiveTARCompressorCustomizer(c -> c |
| 70 | + // Rewrite parent pom to exclude integration tests |
| 71 | + // This way changes in test pom's cause no redownload of dependencies |
| 72 | + .withContentModifier(new FileLinesContentModifier() |
| 73 | + { |
| 74 | + @Override |
| 75 | + public boolean shouldApply( |
| 76 | + final Path sourcePath, |
| 77 | + final String targetPath, |
| 78 | + final TarArchiveEntry tarArchiveEntry) |
| 79 | + { |
| 80 | + return "pom.xml".equals(targetPath); |
| 81 | + } |
| 82 | + |
| 83 | + @Override |
| 84 | + public List<String> modify( |
| 85 | + final List<String> lines, |
| 86 | + final Path sourcePath, |
| 87 | + final String targetPath, |
| 88 | + final TarArchiveEntry tarArchiveEntry) throws IOException |
| 89 | + { |
| 90 | + return lines.stream() |
| 91 | + // Remove integration tests module |
| 92 | + .filter(s -> !s.contains("<module>integration-tests")) |
| 93 | + .toList(); |
| 94 | + } |
| 95 | + |
| 96 | + @Override |
| 97 | + public boolean isIdentical(final List<String> original, final List<String> created) |
| 98 | + { |
| 99 | + return original.size() == created.size(); |
| 100 | + } |
| 101 | + })); |
64 | 102 |
|
65 | 103 | try |
66 | 104 | { |
|
0 commit comments