Skip to content

maven-plugin aot test mojo: process aot when tests are built but not run #46890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

stevenschlansker
Copy link

Currently, it is not possible to build the tests AOT processing without running them. Maven Surefire provides two different configuration switches:

  • skipTests builds, but does not run, tests
  • maven.test.skip neither builds nor runs tests

Right now the spring boot aot processing will skip aot in both cases. However, there's reasons to build but not run tests: in particular, this breaks reproducible builds because the main run (with tests built and run) has the aot classes built, but then the reproducer run (build tests but skip running them) does not, leading to different test jars.

In the case where tests are built but not run, we should still do AOT processing, since that is part of producing the full test jar.

We'd very much appreciate a backport to 3.5.x if possible

Currently, it is not possible to build the tests (with aot processing)
without running them. Maven provides two different configuration switches:

* skipTests builds, but does not run, tests
* maven.test.skip neither builds nor runs tests

Right now the spring boot aot processing will skip aot in both cases.
However, there's reasons to build but not run tests: in particular, this
breaks reproducible builds because the main run (with tests) has the aot
classes built, but then the reproducer run (skip running tests) does not,
leading to different jars.

In the case where tests are built but not run, we should still do AOT processing.

Signed-off-by: Steven Schlansker <[email protected]>
@hgschmie
Copy link

I'd argue that this would be better served by adding a new configuration option that uses the value of the maven.test.skip property as its default.

That way, the code would still behave as before but a developer can control whether processing is skipped or not by overriding the default behavior.

<skipAotTestProcessing>${maven.test.skip}</skipAotTestProcessing>

@snicoll
Copy link
Member

snicoll commented Aug 19, 2025

Currently, it is not possible to build the tests AOT processing without running them.

I am not sure that I got that, given that the "running them" part is done by a different plugin. Please refer to the Native Maven Plugin documentation.

I added this in a demo project and AOT did run, but the tests did not:

<profile>
	<id>nativeSkipTests</id>
	<build>
		<plugins>
			<plugin>
				<groupId>org.graalvm.buildtools</groupId>
				<artifactId>native-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>native-test</id>
						<configuration>
							<skipNativeTests>true</skipNativeTests>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</profile>

The documentation I refered to offers a command line switch as well.

Can you clarify what this PR is supposed to do?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Aug 19, 2025
@stevenschlansker
Copy link
Author

Thanks for the example - I think it's not the same as my use case. In your example, "normal" surefire still runs, and then native tests are skipped. In this case, we are trying to skip normal surefire as well as native tests, with -DskipTests. Or did I miss something?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 20, 2025
@snicoll
Copy link
Member

snicoll commented Aug 20, 2025

Did I miss something?

Have you reviewed my previous comment that states our plugin does not execute the native tests? Does that PR of yours actually work? Have you tried it?

Regardless, it makes no sense for us to bind to a surefire plugin-specify property, especially when our plugin doesn't do anything with test execution. The maven.test.skip property is more general and honored by at least Surefire, Failsafe and the Compiler Plugins. It then makes sense to support it since our process-test-aot is compiling generated test code.

All in all, I don't think you've reviewed this thoroughly, and I can't see how the changes you've suggested is helping the scenario you've described.

@snicoll snicoll closed this Aug 20, 2025
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Aug 20, 2025
@snicoll snicoll reopened this Aug 21, 2025
@snicoll snicoll added status: waiting-for-triage An issue we've not yet triaged and removed status: declined A suggestion or change that we don't feel we should currently apply labels Aug 21, 2025
@snicoll
Copy link
Member

snicoll commented Aug 21, 2025

On second thought, let's continue the conversation on #46929 - This PR is nowhere near the changes we'd apply anyways.

@snicoll snicoll closed this Aug 21, 2025
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants