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

[MNG-6802] Fix bug in FileProfileActivator #347

Merged
merged 33 commits into from
May 15, 2021

Conversation

dehasi
Copy link
Contributor

@dehasi dehasi commented May 21, 2020

FileProfileActivator changes FileProfileActivator.exists
which lets flattened resolveCiFriendliesOnly depending
fail activating profile.

Problem

The root of the problem that FileProfileActivator
interpolates path value and rawModel is updated here
and becomes not raw anymore.

It affects i.e. flatten-maven-plugin

Solution

FileProfileActivator has to have an absolute path to check
if a file exists but shouldn't update Profile.

On the other side DefaultModelBuilder
needs to have interpolated profiles to build an effective model.
To interpolate profiles, DefaultModelBuilder also needs absolute paths.

The interpolation logic is needed in two places.
That's why I extracted the common logic to ProfileActivationFilePathInterpolator.

I use it in both places. In FileProfileActivator I only check if the file exists.
In DefaultModelBuilder I interpolate profiles.

I added DefaultModelBuilderFactoryTest#test_pom_changes()
to check that getRawModel() is still raw and getEffectiveModel() is interpolated.

Also, I added FileProfileActivatorTest to show that the activator doesn't update profiles anymore.

Discussion

Please, let me know if I can do something else to make this PR accepted.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    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.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MNG-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MNG-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the Core IT successfully.

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.

Ravil Galeyev added 2 commits May 20, 2020 22:57
FileProfileActivator changes FileProfileActivator.exists
which lets flattened resolveCiFriendliesOnly depending
fail activating profile.
@slannez
Copy link

slannez commented May 22, 2020

@dehasi Hi, is there anything we can do to help? This bug is also preventing us from using flatten plugin on our projects.

@glimmerveen
Copy link

Coincidentally I ran into the same issue, and did not notice your issue/PR when working on a solution as well.
Interestingly I took a different route at addressing this behaviour, you can have a look at my PR here: #348 .

@dehasi
Copy link
Contributor Author

dehasi commented May 22, 2020

@glimmerveen I like your solution! It's short and solves the problem.
But:) I still think that FileProfileActivator shouldn't update method parameters.
Anyway, hope at least one of PRs will be accepted the issue will be resolved.

@slannez I also submitted a fix #152 to flatten itself. Probably it also can help you.

@glimmerveen
Copy link

My solution looks more like a workaround I guess; and I am not sure if it has any unforeseen consequences :).

I agree, let's hope the underlying problem is quickly solved with either solution!

* Make ProfileActivationFilePathInterpolator a class
* call super.tearDown() last
@dehasi dehasi requested a review from elharo May 26, 2020 06:32
Ravil Galeyev added 3 commits May 26, 2020 15:45
* Get rid of reusing local variables
* Rename file-> activationFile
* Move if ( missing ) to try block
* Update javadocs
* Replace string format with concatenation
* Replace FileReader to FileInputStream
@dehasi dehasi requested a review from elharo May 26, 2020 15:50
@slachiewicz
Copy link
Member

@elharo commons-lang see #308 and https://issues.apache.org/jira/browse/MNG-6829

@elharo
Copy link
Contributor

elharo commented May 26, 2020

see my comment at the end of that issue: plexus-utils and maven-shared-utils are not as well maintained or reliable as commons-lang. I'd pick commons-lang over either of those, given a choice.

@rfscholte
Copy link
Contributor

IIRC the original reason for our own utils is to prevent class collissions. There have been Maven releases where plugins picked up the incompatible version from Maven core. Unsure if this is still an issue, but for that reason I would stay with plexus-utils.

@dehasi
Copy link
Contributor Author

dehasi commented May 27, 2020

Dear @elharo @rfscholte @slachiewicz

Correct me if I'm wrong, It looks like my PR raised an important topic,
but you have not agreed about it yet.

But the discussion is slightly out of the scope of the problem, which I'm trying to solve.

Could we focus on the issue with the FileProfileActivator itself?
Can I do anything else to help you fix the bug?

For now, I reverted lang3 to plexus-utils,
not because I support one of the sides but because it was there from the beginning.
So, let's try to make fewer changes.

Once, when you agree, I'll be happy to help you refactor the code.
Seriously, I'm ready to make the tool, that I use on my daily basis, better.
My username in Apache Jira is rgaleyev, so you can just assign a ticket to me.

@glimmerveen
Copy link

Are there any updates on the proposed changes? Can these be merged or are there still issues to be resolved?

@rfscholte
Copy link
Contributor

I've assigned MNG-6802 to me, not sure when I'll pick it up as everybody is waiting for a response. Be aware there's a conflict right now.

Ravil Galeyev added 2 commits June 23, 2020 14:09
# Conflicts:
#	maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
@dehasi
Copy link
Contributor Author

dehasi commented Jun 24, 2020

@rfscholte I resolved conflicts.

@basvandenbrink
Copy link

I would also love to see this fix or fix #348 merged. Quite some people are facing the issues that it aims to solve, because this is the root cause of this issue: e-gineering/gitflow-helper-maven-plugin#105.

@elharo, I see that you were assigned as reviewer. Do you have some time to take a look?

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflicts need to be resolved before this can be reviewed.

@mthmulders
Copy link
Contributor

However those are weird failure messages I don't understand so let's be careful about checking this in. They don't look like a typical temporary maven central failure. Maybe Github actions uses some sort of local mirror that's misbehaving?

@mthmulders created a thread on the dev mailing list about this about 20 hours ago.

That mailing list thread resulted in a potential fix in the integration test suite. That fix has been merged, and the last four runs of the GitHub actions have run successfully. That is of course no guarantee that it'll never fail again, but you could at least give it another go.

@elharo
Copy link
Contributor

elharo commented May 5, 2021

@dehasi
Copy link
Contributor Author

dehasi commented May 8, 2021

@elharo It looks the build was successful. Can we proceed with the review? I answered your comments.

@dehasi dehasi requested a review from elharo May 13, 2021 20:11
Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elharo
Copy link
Contributor

elharo commented May 13, 2021

There are a lot of test failures I don't immediately understand. I don't usually work on the core, so you might need to find someone else to help analyze these.

@dehasi
Copy link
Contributor Author

dehasi commented May 13, 2021

@elharo I've pulled the last changes from the master. Does it make sense to try to restart the build before I ask for help?

@MartinKanters
Copy link
Contributor

@elharo I've pulled the last changes from the master. Does it make sense to try to restart the build before I ask for help?

Yes, that would make sense. The ITs that failed are one of the newest, so it makes sense that they fail if the latest changes from maven (core) are not merged in this branch. @elharo could you please test the Jenkins build again with the most recent version of @dehasi 's changes? The Github Actions workflow went fine, so I'm assuming Jenkins should run fine as well. (they target the same ITs)

@elharo
Copy link
Contributor

elharo commented May 14, 2021

jenkins failed again. Trying one more time:

https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven/job/MNG-6802/6/

@MartinKanters
Copy link
Contributor

jenkins failed again. Trying one more time:

https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven/job/MNG-6802/6/

I believe you are running Jenkins against an older version of his work, the one were master wasn't merged in yet (which @dehasi did yesterday). I pushed his most recent changes branch to asf and the Jenkins build succeeded.

@elharo elharo merged commit 3fabb63 into apache:master May 15, 2021
@basvandenbrink
Copy link

Great to see it has been merged! Question: will this fix be included in the next 3.x.x release?

@MartinKanters
Copy link
Contributor

@basvandenbrink The next release will be Maven 4.0.0-alpha-1, which is coming "soon" (can't give any real ETA since we are all doing this in spare time).

@michael-o
Copy link
Member

@elharo Why didn't you modify the commit message before merging? It is unreable and therefore pointless. Intermediate work should not land when merged.

@basvandenbrink
Copy link

@MartinKanters Thanks for your answer. I think it would be great to also have a stable 3.x.x version including the fix. However, I could also understand that you want to spend your limited amount of time on the v4 work.

@michael-o
Copy link
Member

@MartinKanters Thanks for your answer. I think it would be great to also have a stable 3.x.x version including the fix. However, I could also understand that you want to spend your limited amount of time on the v4 work.

Could a backport have any side effects? If not, feel free to provide a PR. @rfscholte Would you object a backport?

@rfscholte
Copy link
Contributor

I am kind of surprised that a bug in FileProfileActivator is discovered after so many years. That makes we wonder if people have found workarounds, which now would break their builds.
Let's keep it for Maven 4, which already contains changes in the same cetagory.

@mpepping
Copy link

mpepping commented Jan 4, 2022

Would a PR for a backport be considered? It would be good to have this fixed in Maven 3 as well.

@michael-o
Copy link
Member

@mpepping Likely for at least 3.9.0x. Can you provide a PR rebased on top of 3.8.x?

rlenferink pushed a commit to rlenferink/maven that referenced this pull request Jan 4, 2022
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.