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
-
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
Action
s there's often only one algorithm to select affected modules (BuildFile
and source sets).But for more generic
Action
s likeAddDependency
,RemoveDependencies
the 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-starter
andspring-boot-starter-test
dependencies 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-jpa
must be added to this module.Learning
Action
s 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
Action
s can be configured by exchanging strategies to handle multi-module projects👍
Action
namesAddDependency
adds dependencies👎
Action
configuration dataMultiModuleHandler
not reusableActionDeserializer
Every 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
Action
hierarchy 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
Handler
orStrategies
can hardly be reused but will contain theapply
logic of an Action and could thus be theAction
itself with easier setup.ApplicationModule(s)
In a multi-module project each module is represented by an
ApplicationModule
.The
ProjectContext
providesgetApplicationModules()
to retrieveApplicaitonModules
which encapsulates allApplicationModule
s.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>
getModuleResources
Returns all resources contained in any of the
ApplicationModule
sSourceSet
s.contains
Checks if a given
Path
matches the absolute path of any of a resource in any of theSourceSet
sBeta Was this translation helpful? Give feedback.
All reactions