-
Notifications
You must be signed in to change notification settings - Fork 33
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
[MPH-168] effective-pom should support multi-module project #76
base: master
Are you sure you want to change the base?
Conversation
I have tried some things with the
I get the following output:
Therefore, I currently have the output path hardcoded set to the target directory of the relevant module. We could go for the option of making the We could also choose to allow to specify a directory as Please, let me know what your preferred solution is. |
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.
Thanks for this effort!
I'd appreciate if the new property individual
would not automatically set output
.
Could you make it in such a way that individual
would output to standard out, unless output
was set? If individual=true
and output
are set, I would interpret output
as relative to the base directory of the module for which each individual effective pom was generated.
src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
Outdated
Show resolved
Hide resolved
When the user only specifies the individual flag, it will create individual effective POMs and print it to standard out. When the output parameter is specified, it is used to write the ouput to files, relative to the (sub)project the effective POM is for. The output parameter is parsed as a File so contains the full path. We replace the basedir of that path to get the actual location where the effective POM should be written to. That would fail in case of a relative path going up the tree. Therefore, if the basedir cannot be found, we take the name of the output path and use only that.
{ | ||
String rawOutputPath = output.getPath(); | ||
String rawBasedirPath = project.getBasedir().getPath(); | ||
String result = rawOutputPath.contains( rawBasedirPath ) |
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 brute-force searching of strings is not the correct way to process paths. Even in the best of worlds, there are all sorts of cases this won't work with (e.g. if the paths are not normalized, and contains ../
, etc. In addition you're using contains()
, which even with this approach isn't correct (it looks even in the middle of the string).
Instead of searching raw strings, you should be using path manipulation methods for semantic Path
objects. For example, there's a method made to do exactly what you want: Path.relativize()
. And if you don't have a Path
, you can create one from a string. You can also can convert from the old File
model to the new Java NIO Path
model and back.
If you're not used to working with semantic path objects, you might start at Oracle's The Path Class tutorial, which includes Path Operations explanations..
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MPH-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MPH-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean verify
).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement. The ICLA has been signed and is sent to Apache secretary.
This PR closes https://issues.apache.org/jira/browse/MPH-168.
I have chosen to solve this issue using a new parameter
individual
. I chose this name because you are generating an effective POM for each project/module individually. It is already possible to generate an effective POM across for each project/module, but it will put it in a single result/file. Please, advice on this naming if you like it or what it should be changed to.I have not yet built the support of specifying
output
in combination withindividual
. For now, it will always output the effective POM to${projectDirectory}/target/effective.pom.xml
. In the issue it mentions setting theoutput
to${project.build.directory}/effective-pom.xml
, but I'm not sure how to transform the variable part in it per project.IMO the code does not look very clean, I think some of it could be refactored, but I'm not sure in what way.