Skip to content

Allow relative auto-configuration ordering to be configured using @AutoConfiguration #29907

@wilkinsona

Description

@wilkinsona

With the new @AutoConfiguration annotation, it would be nice to be able to configure relative ordering without having to use @AutoConfigureBefore and @AutoConfigureAfter. This could be achieved with attributes similar to the following:

	/**
	 * The auto-configure classes that should have not yet been applied.
	 * @return the classes
	 */
	Class<?>[] before() default {};

	/**
	 * The names of the auto-configure classes that should have not yet been applied.
	 * @return the class names
	 */
	String[] beforeNames() default {};

	/**
	 * The auto-configure classes that should have already been applied.
	 * @return the classes
	 */
	Class<?>[] after() default {};

	/**
	 * The names of the auto-configure classes that should have already been applied.
	 * @return the class names
	 */
	String[] afterNames() default {};

As a signal that relative ordering is preferred, support for absolute ordering will continue to only be supported with @AutoConfigureOrder.

@philwebb wondered if we may be able to achieve the above using meta-annotations and @AliasFor. To do that, we may need to make some changes so that @AutoConfigureBefore and @AutoConfigureAfter can be used as meta-annotations. Some experiments suggest that getAutoConfigurationMetadata in AutoConfigurationSorterTests doesn't. Some main code may need to change too, including the auto-configuration annotation processor.

Metadata

Metadata

Assignees

Labels

status: noteworthyA noteworthy issue to call out in the release notestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions