-
Notifications
You must be signed in to change notification settings - Fork 38k
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
Introduce support for changing the target component in GenerationContext #28928
Comments
Current work on this issue can be viewed in the following feature branch. Note, however, that I am investigating a different approach that would override the default target type for each invocation of The current tests show that
Whereas, ideally these would be:
|
This commit reverts the changes to ApplicationContextAotGenerator and ApplicationContextInitializationCodeGenerator and replaces that functionality with support for forking a GenerationContext for a new target class. This allows GeneratedClasses to contain all generated classes by transparently changing the current ClassNameGenerator behind the scenes. The state of the ClassNameGenerator is also retained transparently. See spring-projectsgh-28928
Commit sbrannen@a151339 reverts all changes to This new approach simplifies the programming model for clients of |
There are essentially two ways to fix this issue that I can see based on several discussions with @philwebb. We could add such a method to Or we could allow the creation of a There is an additional problem regardless of which approach we pick. We can't strictly speaking rely on |
This is effectively the route I've gone in the current implementation of #28204. The following are the only changes I had to make to core AOT infrastructure:
In light of that, let's hold off on providing support for targeting a component -- as I originally proposed -- until the AOT work for the TestContext framework is further along.
I created #28974 to address this particular issue. |
Should this still be opened? |
Overview
ApplicationContextAotGenerator
currently does not support a target component for the name of the generatedApplicationContextInitializer
. This is sufficient if you are processing a singleApplicationContext
for AOT. It's also sufficient if you do not want the generated initializers to reside in the same package as the target component.However, for the AOT support in the TestContext framework we would like to generate an
ApplicationContextInitializer
per test class (or more specifically per uniqueMergedContextConfiguration
) in the same package as the original test class.Status Quo
With the
ClassNameGenerator
configured withorg.springframework.test.context.aot.TestContextAotGenerator
as the default target class, we get the following by default, which does not create the classes in the test's package.If we pass
generationContext.withName(testClass.getName())
toApplicationContextAotGenerator
, we get the following, which is very verbose and still not in the test's package.If we pass
generationContext.withName(testClass.getSimpleName())
toApplicationContextAotGenerator
, we get the following, which is not as verbose but still not in the test's package.Whereas, if we allow the "target component class" to be specified we can achieve the following.
Deliverables
ApplicationContextAotGenerator
andApplicationContextInitializationCodeGenerator
.The text was updated successfully, but these errors were encountered: