Skip to content

Make initialize-spring-boot-migration work with simple multi Maven module project #270

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

Closed
8 tasks done
fabapp2 opened this issue Jul 31, 2022 · 0 comments · Fixed by #340
Closed
8 tasks done

Make initialize-spring-boot-migration work with simple multi Maven module project #270

fabapp2 opened this issue Jul 31, 2022 · 0 comments · Fixed by #340
Assignees
Labels
type: enhancement New feature or request
Milestone

Comments

@fabapp2
Copy link
Contributor

fabapp2 commented Jul 31, 2022

Currently, the recipe initialize-spring-boot-migration only works for single module projects.
As a first step to support multi maven module projects this recipe should work with a simple multi module project.

What needs to be done

Setup project

Parent/root module

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
    <modules>
        <module>module1</module>
        <module>module2</module>
    </modules>
</project>

Application module

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.example</groupId>
        <artifactId>parent</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>module1</artifactId>
    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <spring-boot.version>2.7.2</spring-boot.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>module2</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
</project>

Component module

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.example</groupId>
        <artifactId>parent</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>module2</artifactId>
    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
</project>

Expected result:

  • dependencyManagement section with Spring dependencies should be added to parent pom
  • Spring Boot Application class and test should be added to application module
  • application.properties should be added to application module
  • dependencies should be added to application module

TODOs

  • AddDependencies: adds dependencies to topmost application modules. This is oversimplified. The correct module has to be calculated depending on the usage.
  • RemoveDependenciesMatchingRegex: Removes dependencies from the modules where AddDependency was applied.
  • AddMavenPlugin: Adds the spring-boot-maven-plugin to all application modules
  • AddSpringBootApplicationPropertiesAction: Adds application.properties to all application modules
  • AddSpringBootMainClassAction: Adds main class to all application modules
  • AddSpringBootContextTestClassAction: Adds main class to all application modules
  • BuildPackaging: Changes type to jar for application modules
  • Make MultiModuleHandler and abstract class providing the setter for Action
@fabapp2 fabapp2 self-assigned this Aug 5, 2022
@fabapp2 fabapp2 added this to the v0.12.0 milestone Sep 20, 2022
@fabapp2 fabapp2 added the type: enhancement New feature or request label Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
1 participant