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

Improved support for multi-module maven projects #210

Merged
merged 3 commits into from
Feb 26, 2018

Conversation

lutovich
Copy link
Contributor

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.

<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin-tests-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
Copy link
Contributor

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.

Copy link
Member

@nedtwigg nedtwigg left a 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.

@lutovich
Copy link
Contributor Author

Thanks for reviewing! I'll fix relativePath and try to simplify test POMs a bit. Will merge after #209.

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.
@lutovich lutovich merged commit b72edf3 into diffplug:master Feb 26, 2018
@lutovich lutovich deleted the maven-multi-module branch February 26, 2018 22:48
@lutovich
Copy link
Contributor Author

Hi @nedtwigg, both #209 and this PR are now merged. Do you think 1.0.0.BETA3 can now be released?

@nedtwigg
Copy link
Member

1.0.0.BETA3 has been published.

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.

3 participants