Open electrum opened 3 years ago
Hi @electrum,
and thus must declare a dependency on
docker-java-api
docker-java-api
is a transitive dependency:
https://mvnrepository.com/artifact/org.testcontainers/testcontainers/1.16.0
Which means that you get it automatically when you add testcontainers as a dependency if you are using a build system (Gradle/Maven/SBT/etc).
Hi @bsideup, thanks for the response and all your work on this great project.
You get the transitive dependency automatically, but if you use one of the Testcontainers methods such as GenericContainer.withCreateContainerCmdModifier()
that requires using docker-java-api
classes, the best practice is to add a direct dependency.
Using a transitive dependency directly in your code without declaring it is flagged by the Maven Dependency Plugin and likely by other build systems as well. Some build systems will actually prevent non-direct dependencies from being available to the compiler. Example:
[INFO] --- maven-dependency-plugin:3.1.2:analyze-only (default) @ my-module ---
[WARN] Used undeclared dependencies found:
[WARN] com.github.docker-java:docker-java-api:jar:3.2.11:compile
docker-java-api
is part of the (advanced) public API of Testcontainers and thus it seems appropriate and helpful to have it be part of the BOM.In my use case, I wanted to override
GenericContainer.containerIsStarted()
, which means I have a compile time dependency onInspectContainerResponse
(as it is a parameter) and thus must declare a dependency ondocker-java-api
.The problem is that I need to supply a version for the dependency, but what version do I use use? The answer is that it must be the same version as used by Testcontainers, but there's no way to do it automatically, so I have to manually copy/paste the version and keep it updated whenever I update Testcontainers. If it was in the BOM, I could simply add the dependency without a version and it would always be correct.