11package software .xdev ;
22
3+ import java .nio .file .Path ;
34import java .nio .file .Paths ;
5+ import java .util .List ;
46
7+ import org .apache .commons .compress .archivers .tar .TarArchiveEntry ;
58import org .slf4j .LoggerFactory ;
69
710import software .xdev .testcontainers .imagebuilder .AdvancedImageFromDockerFile ;
811import software .xdev .testcontainers .imagebuilder .compat .DockerfileCOPYParentsEmulator ;
12+ import software .xdev .testcontainers .imagebuilder .transfer .fcm .FileLinesContentModifier ;
913
1014
1115public final class Application
@@ -25,13 +29,46 @@ public static void main(final String[] args)
2529 ".md" ,
2630 ".cmd" ,
2731 "/renovate.json5" ,
28- // We need to keep the pom.xml as maven can't resolve the modules otherwise
29- "testcontainers-advanced-imagebuilder/src/**" ,
30- "testcontainers-advanced-imagebuilder-demo/src/**"
32+ "testcontainers-advanced-imagebuilder/**" ,
33+ "testcontainers-advanced-imagebuilder-demo/**"
3134 )
3235 .withDockerFilePath (Paths .get ("../testcontainers-advanced-imagebuilder-demo/Dockerfile" ))
3336 .withBaseDir (Paths .get ("../" ))
34- .withDockerFileLinesModifier (new DockerfileCOPYParentsEmulator ());
37+ .withDockerFileLinesModifier (new DockerfileCOPYParentsEmulator ())
38+ // Only copy the required maven modules and remove the not required ones
39+ .withTransferArchiveTARCompressorCustomizer (c -> c .withContentModifier (
40+ new FileLinesContentModifier ()
41+ {
42+ @ Override
43+ public boolean shouldApply (
44+ final Path sourcePath ,
45+ final String targetPath ,
46+ final TarArchiveEntry tarArchiveEntry )
47+ {
48+ return "pom.xml" .equals (targetPath );
49+ }
50+
51+ @ Override
52+ public List <String > modify (
53+ final List <String > lines ,
54+ final Path sourcePath ,
55+ final String targetPath ,
56+ final TarArchiveEntry tarArchiveEntry )
57+ {
58+ return lines .stream ()
59+ // Only keep the dummy-app submodule as this is only needed for building
60+ .filter (s -> !(s .contains ("<module>testcontainers-advanced-imagebuilder" )
61+ && !s .contains ("<module>testcontainers-advanced-imagebuilder-dummy-app" )))
62+ .toList ();
63+ }
64+
65+ @ Override
66+ public boolean isIdentical (final List <String > original , final List <String > created )
67+ {
68+ return original .size () == created .size ();
69+ }
70+ }
71+ ));
3572
3673 final String imageName = builder .get ();
3774
0 commit comments