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

Skip sub-projects of deselected projects #328

Open
don-vip opened this issue Mar 15, 2021 · 8 comments
Open

Skip sub-projects of deselected projects #328

don-vip opened this issue Mar 15, 2021 · 8 comments

Comments

@don-vip
Copy link

don-vip commented Mar 15, 2021

From documentation:

Since 3.10.1, "deselected" projects (mvn -pl !...) that contain changes will not be built, but their up- and downstream projects will be built (if not also deselected).

The behaviour concerning sub-modules is not specified. In this example:

A

  • B < I want to ignore all projects under B
    • C
    • D < a file is changed here
    • E, F, G... Many many more sub-projects

When I run mvn -pl '!:B' -Dgib.disable=true, Maven reactor excludes all modules under B.

But when I run mvn -pl '!:B', gib sees that D is changed and builds it.

Is it a bug or intended behaviour? If that's intended it would be great to have a configuration option to change this behaviour.

@famod
Copy link
Member

famod commented Mar 15, 2021

Thanks for reporting this!

In your example, are C, D etc. referencing B as their parent or not? This makes a difference because Maven considers C a downstream module of B when there is such a parent relationship.

@famod
Copy link
Member

famod commented Mar 15, 2021

I tested this briefly and when there is such a parent relation, mvn -pl '!:X' does not exclude the sub-modules of X.

PS: I haven't tested the non-parent variant yet.

@don-vip
Copy link
Author

don-vip commented Mar 15, 2021

I tested this briefly and when there is such a parent relation, mvn -pl '!:X' does not exclude the sub-modules of X.

I am so sorry, you're right. During my manual tests I forgot to add the required profiles of the sub-modules... I don't know if there is a "Maven way" to achieve what I want (build everything except B and its sub-modules, without having to list all of them)

@famod
Copy link
Member

famod commented Mar 15, 2021

No worries!

Maven 4 will actually make -pl recursive, so that -pl B will build B and all its sub-modules and -pl !B will neither build B nor its sub-modules.
The old behavior can be brought back with -N -pl ....

The problem with a custom implementation is that all upstream/downstream calculation in GIB is currently based on Maven core DependencyGraph (well, except a part of the BOM support).
I'll leave this open for now and think about this a bit more...

@famod
Copy link
Member

famod commented Mar 15, 2021

@don-vip In case there is also a module X under A (sibling of B), that depends on B or any of its sub-modules: Would you expect GIB to build X in case B or any of its sub-modules is changed but B is excluded (and its sub-modules)?

@don-vip
Copy link
Author

don-vip commented Mar 16, 2021

Good question. It doesn't make sense in my project. If it was the case I think I would exclude X as well. So I don't know what would be the best choice for GIB behaviour here.

@famod
Copy link
Member

famod commented Mar 16, 2021

Well, not building X in that case is the complicated part because GIB would need to evaluate all of its upstream modules to figure out whether is should be excluded or not. A graph analysis so to say, which can be rather slow for big repos if not done cleverly.
Just excluding B and its sub-modules should be the way easier part.

I think I'll have a look at how Maven 4 alpha behaves but I suppose the new recursive behavior of -pl !... will not exclude dependencies...

@famod
Copy link
Member

famod commented Apr 5, 2021

Status: I didn't have the time to look into this in detail for 3.14.0 (which I will release today) but I think we'll need a new GIB property for this, e.g. -Dgib.excludeDownstreamModules=B or similar, probably with wildcard support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants