-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[MNG-7038] Introducing project.topdir #840
Conversation
Sidenote: I found in the init script there is something called |
IIUC then the property value of the newly introduced
Probably this newly introduced property should rather be set from Java code based on the following logic:
|
@kwin You are right. That is probably a lot better, also because this code in init will travel outside of the project and even the homedirectory of the user to find the however... |
This also means the (internal) |
This is internal for a good reason and should only be used for finding the |
I fully agree to have a new |
One question comes to my mind. Are all those properties system properties ? It would make sense to have some of them being computed relative to a given project (in the Also I would keep |
I think I ran into a chicken-egg type of problem.
I would like to have some suggestions on how to handle this is. |
This would have to be computed inside the
For the per-project
|
I think before anything can be decided, I'd expect a full documentation of all possible cases where such a directory can be calculated. I think that a project property should not mutate during the build since it is bound to the current module being executed. |
Agreed on all points. For the project specific properties, it could be either:
|
@gnodet Thanks for the code pointer. This really helps in my understanding the code.
I disagree with this because if you want the settings.xml in a @michael-o Yes, good point. I agree with the property being immutable from an as early moment in the build as possible. My current thoughts about the meaning of the topdir:
The important difference with the So the |
Note that with build poms, the relative path can be kept empty and it will be inferred from the reactor. But it should be available after the first phase of the model building IIRC.
It really depends on the structure of the project. Some projects may not have their ancestor as the topmost directory. We need to cover those use cases too. Also, it needs to work during a project-aggregation (or we need some properties for that). I think we need to think in terms of use-cases, not properties. What's your first use-case for the topdir thing ? |
Cases to think about I just thought of:
One of the child mentioned edge cases has settings IN the child module (i.e. |
@gnodet My first class of usecases is a consistent location for project level settings ( https://issues.apache.org/jira/browse/MNG-5659 ) which will solve a lot of practical problems for many of the projects where I work. |
A practical example is in this project https://github.com/nielsbasjes/yauaa I wanted to have a single set of project specific checkstyle config. I ended up with packaging these files in a jar and making that a dependency of the checkstyle plugin. |
We need to split between build settings, and project resources I think. By build settings, I mean things that are loaded once for a given maven session. Per-project |
Well, I don't think the topdir as defined above would work. What you need here, is a project resource, so can have a stable absolute path on the file system for the root of the project. It has nothing to do with parent/child relationship imho. The parent/child relationship defines inheritance in the project models, but is completely unrelated to their respective file system location. And what we need here is definitely a file system based property. This top level directory is used by maven. When you invoke maven from a child, all the POMs from the reactor are loaded. This is done through the I think this property works well when the projects are standalone. Problems arise when projects are aggregated, or when |
I'm wondering if it would make sense to add a new element in the build POM model (which would be removed in the consumer pom) to specify that a given pom is the top level pom. The heuristic to obtain the I do think that this need to be thought with projects aggregation in mind. This could be either an attribute |
I've been following this thread and I just thought I'd throw in my two cents. This is what my use case looks like: Over the years I have built a number of multi-modular projects that have spring-boot as a parent. I have a number of artefacts in the root (folder) that I want to access from my sub-modules (pmd, spotbug, spotless, dependency-check, etc).
Initially I was using a build-module but since it was used as a dependency and was not always available I gave up using that approach. The solution I've been using for the last few years is the
I guess most Maven projects probably use, for the sake of simplicity and probably the most intuitive, a direct hierarchical structure which is also reflected on the file system. So do I, with a few exceptions where I used a parent module that was next to the child modules. When using the I understand that people can have quite complex project structures and maybe also in a mono-repo and that Maven should be able to support it. To me it sounds reasonable to assume a For me, regardless of which submodule I'm building from, I want to be able to find my shared artefacts up in the hierarchy (file structure). This is what many tools does and most people are used to it and it is quite accepted. I do think that mixing it with pom parent relation makes it a lot more complicated. One solution could be to use different strategies for resolving the project root (topdir) and one strategy, the default one, could be to traverse the directory tree searching for a marker, e.g. |
Fwiw, the |
thanks for the update. I didn't know the build-helper-maven plugin worked like that, although I probably suspected it. Good to know what the reason is, if it ever goes outside my project tree |
MNG-7038: Introduce public property to point to a root directory of (multi-module) project.
This pull request simply introduces the new variable
project.topdir
which has been documented and points to the top directory of a (multi module) project.Please double check if you agree with both this variable name and the way I have implemented it.
Following this checklist to help us incorporate your
contribution quickly and easily:
[MNG-XXX] SUMMARY
, where you replaceMNG-XXX
and
SUMMARY
with the appropriate JIRA issue. Best practice is to use the JIRA issuetitle 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.
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.