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

Fix Profile Interpolation bug #114

Closed
wants to merge 5 commits into from

Conversation

ciis0
Copy link

@ciis0 ciis0 commented Nov 12, 2019

#102 rebased

Closes #102
Fixes #103

@ciis0 ciis0 changed the title Flatten maven plugin 1.1.x Fix Profile Interpolation bug Nov 21, 2019
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@ciis0 Thanks for this PR 👍
I would like to first discuss whether we should "fix" the existing resolveCiFriendliesOnly as it seems to be quite buggy or create a new mode as suggested by this PR.
Do not get me wrong. I like that you care about existing behaviours that you do not want to break.
Also I would like to integrate your work and pull out a new release with this fix.
However, I do not yet understand the full context and want to take the right decision.

@@ -15,7 +15,7 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<configuration>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<flattenMode>version</flattenMode>
Copy link
Member

Choose a reason for hiding this comment

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

Please do not missuse existing ITs to test a new feature. You would need to create a new integration test instead.

Copy link
Member

Choose a reason for hiding this comment

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

IMHO we should either "fix" the existing mode, or if we keep it create a new IT for version mode.

Copy link
Author

Choose a reason for hiding this comment

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

As per #114 (comment) resolveCiFriendlies should be fixed. :)

Comment on lines +82 to +85
/**
* Fix for {@link #resolveCiFriendliesOnly}
*/
version;
Copy link
Member

Choose a reason for hiding this comment

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

So if this is a "fix" for resolveCiFriendliesOnly why do we have to introduce a new mode then?
My impression is also that this plugin can not be understood by an avergage user anymore. So what does version mode do? Where is it documentated? I already had concerns like this with the naming of resolveCiFriendliesOnly and the documentation is already lacking there but I did not want to be a blocker for urgently requested features. I think that your PR is in general providing a very helpful improvement as I also experienced some problems/bugs with this resolveCiFriendliesOnly. However the way we address this should IMHO need some improvement.
@lasselindqvist do you have some cents on this?

Copy link
Author

Choose a reason for hiding this comment

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

I just kept it during rebase, no other reasons from my side. ^^

Comment on lines +52 to +53
/** Take the element untouched from the original POM. Fix for {@link #keep} */
keepRaw
Copy link
Member

Choose a reason for hiding this comment

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

interesting. So actually keep does not actually do what it should? Can you give an example?
And you invented a new handling to avoid breaking existing build configs?
That would make a lot of sense. So does keep somehow already resolve variables or what is it that it does too much?

Copy link
Author

Choose a reason for hiding this comment

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

The problem that arose for me was that the configuration in (active) profiles was interpolated, specifically ${basedir}.

And I did not invent anything, just rebased it. ^^

Copy link
Author

Choose a reason for hiding this comment

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

Without wanting to be rude, but the overall direction of the original PR-code is rather being a work-around that being a real fix :D

I guess the work remaining now is to fix the underlying issues so the workarounds (version, keepRaw) are not necessary anymore.

@ciis0
Copy link
Author

ciis0 commented Dec 18, 2019

I basically invented nothing here, just rebased it :D

I just kept the original new version mode from the original code, I didn't make any assumptions here ^^

In the context I encounter the bug in resolveCiFriendlies (flattening ´${revision}` in a multi-module project) for the project it wouldn't be important to have an extra mode for this and fixing the original one would also be okay.

I'd say this kind of behaviour is not worth keeping backwards-compatible, it simply does the wrong thing in a way that and.
To make everyone happy one could introduce a property that still interpolates profiles and the likes. :D
Name suggestion based on https://xkcd.com/1172/ would be overheatCpuOnSpacebar.

@ciis0
Copy link
Author

ciis0 commented Dec 18, 2019

Although the underlying code is not mine, I am motivated to fix the issues that arose; the bug is really annoying in some of our projects :D

@lasselindqvist
Copy link
Collaborator

lasselindqvist commented Dec 21, 2019

See also comments in: #103

I don't think this is in a mergeable state, as it contains a mix of commits for different things, but the integration test idea is definitely usable here and opening a PR with two commits: the first introducing the test, and the second introducing the fix should be merged.

The added test has

<profiles>
	<profile>
		<id>cifriendly-profile-bug</id>
		<activation>
			<activeByDefault>true</activeByDefault>
		</activation>
		<repositories>
			<repository>
				<id>myrepo</id>
				<name>myrepo</name>
				<url>https://${repoHost}/${repoPath}</url>
			</repository>
		</repositories>
	</profile>
</profiles>

but I think we want to have something like

<profiles>
	<profile>
		<id>cifriendly-profile-bug</id>
		<activation>
			<activeByDefault>true</activeByDefault>
		</activation>
		<repositories>
			<repository>
				<id>myrepo</id>
				<name>myrepo-${revision}</name>
				<url>https://${repoHost}/${repoPath}</url>
			</repository>
		</repositories>
	</profile>
</profiles>

so that we see that the revision is resolved in the profile, but other variables are not.

@lasselindqvist
Copy link
Collaborator

lasselindqvist commented Dec 21, 2019

Checked this behavior and the problem is that the profile arrives to FlattenMojo.createResolvedPom already resolved to
<url>https://foo/bar</url>
so there is nothing CiInterpolator can do about anymore. Need to stop this resolution before that.

Seems like this issue exists regardless of the resolveCiFriendliesOnly flatten mode, which might make it harder to solve.

@ciis0
Copy link
Author

ciis0 commented Jan 2, 2020

Seems like this issue exists regardless of the resolveCiFriendliesOnly flatten mode, which might make it harder to solve.

Yup, that's the keepRaw thingy if I am not mistaken.

ciis0 added a commit to ciis0/flatten-maven-plugin that referenced this pull request Jan 17, 2020
@ciis0
Copy link
Author

ciis0 commented Jan 17, 2020

#126 supersedes this PR.

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.

resolveCiFriendliesOnly interpolates more than just version and pom elements
4 participants