Replies: 1 comment
-
|
Closing this as done after successfully parsing and running SBM against a 50+ modules JEE application. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Until now Spring Boot Migrator was only working with single module applications.
Support for Maven multi-module projects was missing.
In this discussion, I'll try to note my thoughts and learning while working on #270.
Feel free to jump in and bring in your ideas and remarks, it's appreciated!
Maven multi-module projects and generic Actions
In a multi-module Maven project, the hardest problem is to decide which modules should be affected by an applied
Action.For specialized
Actions there's often only one algorithm to select affected modules (BuildFileand source sets).But for more generic
Actions likeAddDependency,RemoveDependenciesthe affected modules heavily depend on the context of the migration.Example
E.g. The pom.xml where dependencies should be added differs from recipe to recipe.
When initializing a new Spring Boot project the
spring-boot-starterandspring-boot-starter-testdependencies must be added to the same modules as the starter class(es) annotated with@SpringBootStarter.But when migrating a Maven multi-module project with a JPA-module containing JPA related classes and being referenced by other modules the dependency for
spring-boot-starter-data-jpamust be added to this module.Learning
Actions configuration, e.g. the dependency to addPossible Solutions
One Action implementation per use case
A new Action for Every variation:
AddDependenciesToApplicationModules, `AddDependencyTo👍
👎
AddDependencyHere,AddDependencyThere, ...One Action implementation with replaceable strategies
Actions can be configured by exchanging strategies to handle multi-module projects👍
ActionnamesAddDependencyadds dependencies👎
Actionconfiguration dataMultiModuleHandlernot reusableActionDeserializerEvery Action has support for an optional, replaceable strategy
This is the same as above but with a default strategy.
Conclusion
We will create "One Action implementation per use case" for Actions that need to deal with multi-module projects.
With the approach of a replaceable strategy the
Actionhierarchy becomes more complex, the YAML setup becomes much more complex and a recipe configuration in Java also becomes much more complex.But the benefits are minimal. The
HandlerorStrategiescan hardly be reused but will contain theapplylogic of an Action and could thus be theActionitself with easier setup.ApplicationModule(s)
In a multi-module project each module is represented by an
ApplicationModule.The
ProjectContextprovidesgetApplicationModules()to retrieveApplicaitonModuleswhich encapsulates allApplicationModules.Add new Dependency
When adding a new dependency to a
pom.xml, the classpath updates only for dependant modules and for child modules.ApplicationModules.getDependantModules(ApplicationModule)Returns all modules that declare the given module as dependency.
getDeclaredModules()Returns all modules declared in
<modules>getModuleResourcesReturns all resources contained in any of the
ApplicationModulesSourceSets.containsChecks if a given
Pathmatches the absolute path of any of a resource in any of theSourceSetsBeta Was this translation helpful? Give feedback.
All reactions