-
Notifications
You must be signed in to change notification settings - Fork 367
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
Maven settings with profiles fails to active other profiles from parent activeByDefault #4269
Comments
These versions resolve with Maven. If I'm misuing the test APIs, I can create a sample project. openrewrite#4269
These versions resolve with Maven. If I'm misuing the test APIs, I can create a sample project. openrewrite#4269
What do you think @timtebeek ? Does this look like a bug to you? If it's not high on your priority list, we can work on it. We just want to make sure you agree it's a bug before doing that. |
Hi! I've pushed a small change to your reproducer to make that pass locally; I think the order of the pom files matters for the tests. Might there be anything else needed to replicate the issue you're seeing locally? |
I will continue to work on this, but the intent is to mimic behavior when a Maven settings file has a section like this:
When I try to perform an actual rewrite on a real project, ResolvePom#activeProfiles will be Alternatively, I can push a project-based adhoc reproducer. I mean mimic what I'm really trying to do.. |
Perhaps seeing the implementation of this method will help you more faithfully reproduce what you're after with a unit test.
|
I have been trying some variations of that:). I did push changes that I hope does better with this commit. Let me know if there's a better way to craft the test or you need me to submit an adhoc project. |
I went ahead and created an adhoc test here. Apologies for hijacking your repo. I do have a reason:) |
Please ignore the 'Another adhoc' + 3 following commits above. That is a different issue I'm having. Sorry about that. |
@timtebeek Sorry to pester, but I am:) Did you take a peek? I have an idea on a fix, but don't want to start that if you don't see this as an issue. Of course, we'd love it if you could fix or let us know where this lands on the priority list. |
Hi @crankydillo ; Apologies for the delayed response; it's at times hard to get to everything. I've pushed yet another change to your PR to (I think) set the active profile correctly. That again makes the test pass. With that test passing I feel I still don't fully understand the issue you're having, and how settings.xml factors in. I can see the various pom.xml files you have, and the profiles in those, and how you set a different active profile "foobar". I'd expect that to still keep Any help towards solving a problem is of course appreciated, and perhaps helps explain the issue too, but for now it's a bit unclear to me still. Please note that you're always welcome in our Slack as well, if you'd prefer a more synchronous response. |
No need to apologize @timtebeek and thanks for reminder about slack:). Very appreciative of you looking at this!
I dropped a comment on your change. One of the things that has become clear over the past few days is I don't fully understand If you use the 'does not work' scenario,
Yes, this is our expectation as well. However, it does not appear to be the case. Might be better to work with the adhoc test I have above.
I may go ahead and work on a fix, but the root of the issue is that a profile that has |
That helps clarify the issue, thanks! I'd somehow missed the readme you added to your reproducer Sounds indeed like we're not activating the active-by-default profiles in the parent if a settings.xml also has profiles it activates. That seems like a bug indeed, even if it's not as easy to replicate with a unit test. Any help towards a fix appreciated! |
This is just PoC code. I'm out of time as my vacation is starting:) openrewrite#4269
Honestly, I'd probably just copy the code for now. If it weren't for having to have listProfiles due to lombok-generated `MavenSettings#getProfile`, which has a different signature than we need, I'd probably go with this. But having `getProfiles` and `listProfiles` in the same class is really messy. Even so, I'll push it and let the rewrite folks decide. openrewrite#4269
API contract should be preserved. openrewrite#4269
These versions resolve with Maven. If I'm misuing the test APIs, I can create a sample project. openrewrite#4269
These versions resolve with Maven. If I'm misuing the test APIs, I can create a sample project. openrewrite#4269
This is just PoC code. I'm out of time as my vacation is starting:) openrewrite#4269
we can look at other profiles state in order to determine what to do with `activeByDefault` profiles. I'm not happy that I've copied the code in multiple locations. The method of isolating code to a static method doesn't work so well and my attempts at doing some interface/inheritance modeling is not working so well with lombok, which I've never really worked with. Lastly, I've added some tests related to profile deactivation. If there's code that handles that, I haven't found it. The code I've added here does not. openrewrite#4269
One method is deprecated. openrewrite#4269
Honestly, I'd probably just copy the code for now. If it weren't for having to have listProfiles due to lombok-generated `MavenSettings#getProfile`, which has a different signature than we need, I'd probably go with this. But having `getProfiles` and `listProfiles` in the same class is really messy. Even so, I'll push it and let the rewrite folks decide. openrewrite#4269
API contract should be preserved. openrewrite#4269
These versions resolve with Maven. If I'm misuing the test APIs, I can create a sample project. openrewrite#4269
This is just PoC code. I'm out of time as my vacation is starting:) openrewrite#4269
we can look at other profiles state in order to determine what to do with `activeByDefault` profiles. I'm not happy that I've copied the code in multiple locations. The method of isolating code to a static method doesn't work so well and my attempts at doing some interface/inheritance modeling is not working so well with lombok, which I've never really worked with. Lastly, I've added some tests related to profile deactivation. If there's code that handles that, I haven't found it. The code I've added here does not. openrewrite#4269
One method is deprecated. openrewrite#4269
Honestly, I'd probably just copy the code for now. If it weren't for having to have listProfiles due to lombok-generated `MavenSettings#getProfile`, which has a different signature than we need, I'd probably go with this. But having `getProfiles` and `listProfiles` in the same class is really messy. Even so, I'll push it and let the rewrite folks decide. openrewrite#4269
API contract should be preserved. openrewrite#4269
Thanks again! |
We have a
settings.xml
file that has anactiveProfile
specified. We have many parent pom files that have profiles with<activeByDefault>true</active>
. We primarily use this to group sets of managed dependencies. All of this builds and works fine with Maven; however, it does not with openrewrite.My read of Maven's doc on activeByDefault is the activeByDefault=true profiles should be active in poms that do not have a profile with the same id as the active one specified in our
settings.xml
.What version of OpenRewrite are you using?
How are you running OpenRewrite?
Maven plugin + https://github.com/openrewrite/rewrite/blob/main/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactId.java
What is the smallest, simplest way to reproduce the problem?
TEST PR. If I've misunderstood some of your testing libs, I can give a sample project that will show the problem.
What did you expect to see?
Test to pass (maven dependency versions resolved)
What did you see instead?
Failure to resolve Maven dependency versions
Are you interested in contributing a fix to OpenRewrite?
Took a peek, but may bit a bit too extensive for how much time I have...
The text was updated successfully, but these errors were encountered: