Skip to content

Skip Docker containers when tests are skipped - #4532

Open
ppkarwasz wants to merge 1 commit into
2.xfrom
fix/2.x/skip-docker-without-tests
Open

ppkarwasz wants to merge 1 commit into
2.xfrom
fix/2.x/skip-docker-without-tests

Conversation

@ppkarwasz

Copy link
Copy Markdown
Member

The docker profiles of log4j-layout-template-json-test, log4j-mongodb and log4j-mongodb4 start their containers in CI even when tests are skipped. For example, the reproducibility check runs with -DskipTests=true but still starts Elasticsearch, Logstash and MongoDB. Besides wasting time, this makes the check depend on Docker: in this run on release/2.25.6, docker-maven-plugin 0.46.0 crashed on the Docker 29 daemon of the ubuntu-26.04 runner image, and the reproducibility check never reached the remaining modules.

This PR sets docker.skip=true whenever skipTests or maven.test.skip is set to true. Maven can only activate a profile on a single property, so log4j-parent gets one profile per property.

Testing

CI=true ./mvnw -pl log4j-mongodb docker:start@start-mongo docker:stop@stop-mongo with Docker 29.8.0:

Flags docker.skip Result
none unset Mongo container started and removed
-DskipTests true start and stop do nothing
-Dmaven.test.skip true start and stop do nothing
-DskipTests=false unset profiles not activated

No changelog entry: the change only affects the build.

🤖 Generated with Claude Code

The `docker` profiles of `log4j-layout-template-json-test`, `log4j-mongodb`
and `log4j-mongodb4` start their containers in CI even if tests are skipped,
e.g. in the reproducibility check, which runs with `-DskipTests=true`.

Set `docker.skip` whenever `skipTests` or `maven.test.skip` is set, using
one profile per property, since Maven activates profiles on a single
property only.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread log4j-parent/pom.xml
<id>skip-docker-on-maven-test-skip</id>
<activation>
<property>
<name>maven.test.skip</name>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failsafe also skips with -DskipITs, but the containers still start then. Should that get a third profile too?

@ramanathan1504 ramanathan1504 added the build Affects the build system or other automation label Nov 26, 2026
@ramanathan1504 ramanathan1504 added this to the 2.27.0 milestone Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Affects the build system or other automation port-to-2.25.x port-to-2.26.x port-to-main

Projects

Development

Successfully merging this pull request may close these issues.

2 participants