-
Notifications
You must be signed in to change notification settings - Fork 461
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
Improved support for multi-module maven projects #210
Conversation
<groupId>com.diffplug.spotless</groupId> | ||
<artifactId>spotless-maven-plugin-tests-parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>..</relativePath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default anyway. No need to specify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, merge whenever you'd like.
Thanks for reviewing! I'll fix |
Some steps in the maven plugin require paths to configuration files. For example eclipse formatter and scalafmt. In multi-module maven projects it is desirable to specify paths only once and not duplicate configs in multiple modules. Each sub-project should not assume anything about the general project structure and should not refer to files in parent modules using relative paths. It is recommended to create a separate module with configuration files and depend on it in the plugin. This approach is taken by the Checkstyle and PMD plugins: http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html https://maven.apache.org/plugins/maven-pmd-plugin/examples/multi-module-config.html Such approach means configuration files no longer live within the project and might be inside a JAR. Thus specified value of `<file>` require special resolution. Both Checkstyle and PMD use builtin plexus `ResourceManager` which is able to locate files from regular file system, URL or JAR. Located file is then copied to the output directory (usually `./target/`) and used as a regular file. This commit makes spotless plugin also use `ResourceManager` in order to support multi-module configuration with config files in a dedicated module. Every step that contains `<file>` is updated to perform the resolution. It is also possible to specify configuration file URLs, though this feature is not tested.
It's default value is `..` so no need to be explicit about it.
0d21acb
to
79e5322
Compare
|
Some steps in the maven plugin require paths to configuration files. For example eclipse formatter and scalafmt. In multi-module maven projects it is desirable to specify paths only once and not duplicate configs in multiple modules. Each sub-project should not assume anything about the general project structure and should not refer to files in parent modules using relative paths. It is recommended to create a separate module with configuration files and depend on it in the plugin. This approach is taken by the Checkstyle and PMD plugins:
http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html
https://maven.apache.org/plugins/maven-pmd-plugin/examples/multi-module-config.html
Such approach means configuration files no longer live within the project and might be inside a JAR. Thus specified value of
<file>
require special resolution.Both Checkstyle and PMD use builtin plexus
ResourceManager
which is able to locate files from regular file system, URL or JAR. Located file is then copied to the output directory (usually./target/
) and used as a regular file.This commit makes spotless plugin also use
ResourceManager
in order to support multi-module configuration with config files in a dedicated module. Every step that contains<file>
is updated to perform the resolution. It is also possible to specify configuration file URLs, though this feature is not tested.