Skip to content

Spring boot plugin rewrites jar contents, making the build not reproducible unless tests are run #46929

@hgschmie

Description

@hgschmie

The spring boot maven plugin rewrites the jars that a build creates when executing the spring-boot:process-test-aot goal.

This goal is dependent on the maven-wide 'skipTests' and 'maven.test.skip' properties. If either of these is set, the execution is skipped.

For modern java projects, it is common to provide reproducible builds (See https://reproducible-builds.org/docs/jvm/ for details). In a reproducible build cycle, the CI does

  • a full build of a project executing all tests (neither 'skipTests' nor 'maven.test.skip' is set). The resulting jars are installed in the local repository

  • a second build using (for maven) the artifact:compare target. For that second build, usually tests and other checks are skipped as the goal of that build is simply to validate that the resulting jars are bitwise identical.

Currently, it is impossible to use the spring-boot:process-test-aot in this reproducible build cycle. Adding the plugin to the build results in the plugin being executed in the first build, but skipped in the second as it looks at the skipTests and maven.test.skip which are set to actually skip the tests while the spring-boot target should be executed independent of whether the tests are run or not.

Not being able to control the execution of this goal independent of the actual test execution (whether through maven-surefire, maven-native or any other maven test plugin) is a bug. This goal is not a test specific goal but a test-build specific goal.

The current situation makes it impossible for to provide reproducible builds if one wants to support native builds and also support spring. Dropping native build support is not an option.

One possible solution is making the execution of the spring-boot:process-test-aot not directly dependent on the properties mentioned above but have a configuration option to skip or run the goal and have its default set from the proprties but allow users to override this in the maven pom file. This would allow for reproducible builds while maintaining full compatibility to the current functionality.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions