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

Conversion multi module #1

Merged
merged 14 commits into from
Dec 10, 2022
Merged

Conversion multi module #1

merged 14 commits into from
Dec 10, 2022

Conversation

bwgjoseph
Copy link
Owner

Converts the existing project setup into a multimodule maven project

after moved to parent project, running `./mvnw clean verify`, project will be built correctly
but if changed to use `./mvnw spotless:apply`, it will throw the following error

```
No plugin found for prefix 'spotless' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\Joseph\.m2\repository), central (https://repo.maven.apache.org/maven2)]
```

Running `./mvnw -pl starter-mvc-core spotless:apply`would be fine though

To fix root cause, the fix, it seem, is to ensure submodules point to the parent pom.xml

See diffplug/spotless#1135
Reference https://kurular4.medium.com/why-you-should-use-parent-pom-for-your-multi-module-java-projects-b575017fab2e
fix an issue where requireJavaVersion is not enforced, which is caused by having multiple <rules>, it only requires a single <rules>
When running mvn site on a top level project, Maven will build all sites for every module defined in the modules section of the pom individually. Note that each site is generated in each individual project's target location. As a result, relative links between different modules will NOT work. They will however work when you deploy or stage the site. See https://maven.apache.org/plugins/maven-site-plugin/examples/multimodule.html

Note that https://maven.apache.org/plugins/maven-site-plugin/examples/multimodule.html#aggregate-reports is not configured yet
when running command from parent pom, it will scan through parent and all sub-modules to update the pom.xml, if want to scan specify pom.xml then run with -pl <module> command

See https://stackoverflow.com/questions/4146638/maven-variable-for-reactor-root/48879554#48879554 for using ${session.executionRootDirectory} as the root directory of where .mvnw is ran
See https://cwiki.apache.org/confluence/display/MAVEN/Maven+Properties+Guide for a standard maven variables
when run `./mvnw verify`, the sub-modules will run the git info and generate in its build directory
Possible to suppress via annotation, see https://github.com/gaul/modernizer-maven-plugin#ignoring-elements

when run `./mvnw verify`, the sub-modules will run the modernizer
adds spotbugs reporting to submit when running ./mvnw site
however, spotbugs report is not reporting on parent site project but is reporting at the sub-module
thinking if jacoco should exist in its own sub-module but still leave it at parent pom first
Placing in pluginManagement kind of allowing to centalize the configuration but not taking effect on any modules until any of the module declare this in the plugin section on their pom.xml

See https://www.baeldung.com/maven-plugin-management
@bwgjoseph bwgjoseph merged commit ca363b1 into main Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant