Skip to content
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

Refactor @Modulith to Compose @SpringBootApplication #282

Closed
Crain-32 opened this issue Aug 25, 2023 · 1 comment
Closed

Refactor @Modulith to Compose @SpringBootApplication #282

Crain-32 opened this issue Aug 25, 2023 · 1 comment
Assignees
Labels
in: core Core module meta model type: improvement Minor improvements
Milestone

Comments

@Crain-32
Copy link

Crain-32 commented Aug 25, 2023

Discussed a bit during Spring One, but I'll provide the following justifications as to "why" below.

Lets compare the Inherited Annotations between @Modulith and @SpringBootApplication

@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Modulithic
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { //
		@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
		@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface Modulith { // Assume Aliases }
// Spring Boot
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { //
		@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
		@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication { // Assume Aliases }

You can see that the @ComponentScan and @Configuration are the same. The main difference being @SpringBootApplication's @Inherited (Which I'll admit I don't fully understand) and @Modulith's @Modulithic.

I propose (Likely for 1.1.X due to timing) that we Refactor @Modulith to be the following.

@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Modulithic
@SpringBootApplication
public @interface ModulithicSpringApplication { // Assume Aliases }

Since the Spring-Modulith Project is supposed to be an opinionated Spring Boot Application, I think the composition of the two Annotations is the best option. It provides a convenient annotation that can easily be used in the baseline of a project, while keeping @Modulthic Separate for instances/users who want to use it in specific ways.

@odrotbohm odrotbohm self-assigned this Oct 16, 2023
@odrotbohm odrotbohm added in: core Core module meta model type: improvement Minor improvements labels Oct 16, 2023
@odrotbohm odrotbohm added this to the 1.1 RC1 milestone Oct 16, 2023
@odrotbohm
Copy link
Member

That's in place now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Core module meta model type: improvement Minor improvements
Projects
None yet
Development

No branches or pull requests

2 participants