-
Notifications
You must be signed in to change notification settings - Fork 85
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
Ci friendly #77
Ci friendly #77
Conversation
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please undo the reformatting...cause that covers the real changes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be better now.
Lol ! I am the author of https://github.com/fmarot/cifriendly-maven-plugin and was eagerly awaiting your solution to flatten only the version number as being part of flatten-maven-plugin would have made it the de-facto standard for Maven. While we're at it and @khmarbaise may be looking :) if I may, I think that Maven really need a standard and simple solution to "just replace the version number when it is a variable" without relying on a plugin, especially the flatten plugin that does much more than that. And goof support in the IDE (when having multiple projects) is also needed so it would help (I thnik) if this feature was in the core Maven. Sorry to have a bit hijacked the thread... |
02f238f
to
803a1fe
Compare
Yes. It would be nice to have this as part of the "official" Flatten plugin as it is more likely for people to use it. So I this functionality makes it into the plugin in one way or the other. Btw, my local build runs the new integration test fine, but the Travis CI apparently does not. I cannot see it or test it, but maybe it has the classloading issue that I got rid of locally by not extending the existing classes. I don't currently have much time for contributing but might take a look at the profile handling in the future. |
Not sure how valid below is but if I put something like this into a module in a multi-module pom: <properties>
<jackson.version>2.9.6</jackson.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${jackson.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> I get these type of errors:
|
This is caused by the block |
803a1fe
to
1df4b08
Compare
The unnecessary block was removed. |
Based on the Travis CI build log I would guess that the build problem is caused by the fact that the Travis CI build does not use the invoker.properties file unlike my local build. |
Eagerly waiting on this new feature! Thanks for putting some work behind it! |
The JDK8 build seems to work now (https://travis-ci.org/mojohaus/flatten-maven-plugin/builds/437944243) when the revision is given in the maven-invoker-plugin configuration instead of invoker.properties. Maybe it is a security feature in Travis CI or a bug/feature in maven-invoker-plugin. |
1234193
to
c605580
Compare
Does the ci job just need to be re-kicked? Looks like the build issue with older jdks were addressed in #75. |
I will rebase this pull request once #75 has been merged to master branch and then we will get a new build. |
…arent with dependencies
…on config This way of invoking works in Travis CI.
c605580
to
2a20cdf
Compare
Thanks for your work on this and all the added tests. |
The CI friendly is a reference to https://maven.apache.org/maven-ci-friendly.html. CI does stand for continuous integration. The name could be something else, but I don't really have any better suggestions for it. |
Is this PR ready to merge? |
@hohwille are there any intentions to merge or decline this? |
All I want for Christmas... is for this to merge!!! 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I got things right, you want to replace only the three variables that you predefined and hardcoded into this new flatten mode. It would also be insightful to understand more about the undesired side-effects of flatten-maven-plugin that you want to avoid with this new mode (if I got you right you were talking about system properties like maybe java.home or something that otherwise get accidentally replaced if used in POM - is that the case? Should instead then that be considered as a bug and be fixed?).
My biggest concern is that the name of the new mode and especially the 3 hardcoded variables with their names and meanings do not seem to be following a convincing design.
This might just be my personal point of view. I have no idea how many people were involved in this and came up with the "Maven CI Friendly Versions" documentation published on the maven site maybe after long discussions and smart thoughts I might not get.
I see that you want to have this feature deadly and I might seem as a stupid guy not reacting for ages and now complaining with picky reviews.
@khmarbaise / @mojohaus/owners do you agree with my point of view or am I just picky. I do not want to be a spoilspot here...
@@ -219,7 +219,7 @@ | |||
</properties> | |||
<goals> | |||
<goal>clean</goal> | |||
<goal>${project.groupId}:${project.artifactId}:${project.version}:flatten</goal> | |||
<goal>${project.groupId}:${project.artifactId}:${project.version}:flatten -Drevision=1.2.3.4</goal> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having a fixed revision for all tests seems kind of unflexible but that can be resolved later...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary if we want to run the integration tests in Travis. For some reason it doesn't use the ones given in invoker.properties even though in local builds they are used.
I am not sure if the problem is with Travis or the Invoker plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, got it. You explained that earlier. Sorry, that I did not got it directly... Considered done. If someone finds a nicer solution can still be improved after merge...
@@ -0,0 +1,13 @@ | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indendation is 2 in other existing files.
@@ -0,0 +1 @@ | |||
invoker.mavenOpts = -Drevision=1.2.3.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, this is the nice solution. Can we strip the revision system property from the plugins toplevel pom then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referring to the other answer, this is what I tried first and forgot to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is working outside travis (event with out having it in pom) please leave it here. Otherwise please cleanup.
fatjar, | ||
|
||
/** Only resolves variables revision, sha and changelist. Keeps everything else. */ | ||
resolveCiFriendliesOnly; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed in the issue the name is not very good. Already resolveCiVaraiblesOnly
would be a little better. Still thinking of something better. After all who defined this (https://maven.apache.org/maven-ci-friendly.html). To tell it straigth away:
- the linked documentation states about
sha1
you writesha
here. sha
/sha1
is a particular hash algorithm. It is also already getting obsolete and is attacked. If you are naming a variable you should not use the name of the algorithm esp. if you set it as system property. How aboutchecksum
orhash
?- Who came up with the name
changelist
? If that is for-SNAPSHOT
or an empty string this is also entirely odd. A Changelist is something like this: https://en.wikipedia.org/wiki/Version_control#Common_vocabulary also it can easily be mistaken for a changelog (there is maven changes plugin and maven changelog plugin).
This is my actual concern...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no knowledge about the origins of the "Maven CI Friendly Versions" documentation, so I cannot answer about it. The purpose is to just resolve the variables that are stated there, but I think mostly the use case would be for "revision".
"sha" should be "sha1".
I am fine with any naming for the variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure there is no misunderstanding (I am awaiting this PR): the guys at the head of Maven (@khmarbaise & al) themselves came up with 3 harcoded variable names that are possible to be accepted as variable part of the version. This is what is usually called "CI Friendly Maven". This may not be the best choice, there may have been different alternative implementations, but to this day this is the current status of Core Maven. Knowing the forward compatible history of Maven, I doubt they will change. So there is really no need to try to find alternatives here. Even non core plugin should just reuse what Maven user are (or will be) familiar with, the way of naming things (CIFriendly, sha1, changelist & revision) should be the same.
My 2 cents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmarot could you shed in some light here? Do you agree to some of my points or do you have some arguments for your PoV?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lasselindqvist as you are so superb fast and active in updating the PR:
would it be possible that you link to the original documentation from the javadoc then like this:
See Maven CI Friendly for further details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, each subject one after another:
- resolveCiFriendliesOnly vs resolveCiVariablesOnly : I prefer the former to keep it linked with the Maven Core vocabulary of "CI Friendly". But it is not very important
- sha1 VS sha in the comment : @lasselindqvist already corrected it
- rename sha1 to a more generic word: this is a no go as Maven Core uses explicitly "sha1" as one of the 3 allowed keywords.
- changelist : same as above. the Flatten plugin has no choice but to comply with the wording of Maven Core. Otherwise users would not understand.
(just trying to help here ;) thanks for your work both of you)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmarot thanks for the quick feedback. I was not aware if this is just something a single guy came up with - but if maven core already adopted this I do not want to fight anything here. I just want to care about design and quality and avoide foolish decisions ;)
@khmarbaise can you confirm this.
IMHO we could then merge this and maybe I might even be able to push out a new release before xmas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfriedenhagen confirmed on dev list:
https://groups.google.com/forum/#!topic/mojohaus-dev/1SQSAERVg1c
|
||
|
||
/** | ||
* {@inheritDoc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check your IDE settings (Eclipse templates). {@inheritDoc}
JavaDoc tag is obsolete since java 1.6 and replaced by @Override
annotation.
{ | ||
result.append( input, endIdx + 1, input.length() ); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woho. Can't this ~120 lines of code be reduced to a view lines using regex, findFirst and replace? In the end you are only looking for 3 fixded given expressions. Also you could directly indexOf or replace for that 3 variables if they are hardcoded anyhow... Just looks overcomplicated to me. I might also be missing something. Just a suggestion, nothing that could not be accepted as is. A regular JUnit for this would be helpful and more explanatory as well...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CiInterpolatorImpl just basically replicates StringSearchInterpolator from plexus-interpolation with small changes so that it only replaces those three variables. It is ugly, but works with the same behavior as the resolving of other variables in the plugin. Using regex might detect and resolve circular and nested variables differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfectly fine then. Get the point. Maybe a link to the "copied" implementation (StringSearchInterpolator) in the javadoc ({@link package.name.StringSearchInterpolator}
) with such hint would be lovely.
Change 'sha' to 'sha1' in resolveCiFriendliesOnly comment
invoker.mavenOpts = -Drevision=1.2.3.4 since Travis CI builds does not use them anyway so it is misleading
Replace tabs with 2 spaces as all the other XML files use 2 tabs as the indentation.
Add a reference to https://maven.apache.org/maven-ci-friendly.html in resolveCiFriendliesOnly documentation.
Link to StringSearchInterpolator and explain the difference to the original in the class Javadoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lasselindqvist thanks for the quick reactions and improvements to my review feedback.
As the CI friendly variables are already defined by maven and out in the wild for 2 years this seems fine to me now. Thanks to all contributing and clarifying.
Here is your package. Please vote: Also please note that you broke the javadoc and I had to rebuild manually with doclint disabled. I was not so picky for the review to not block this any further. However, it would be lovely if you could provide a PR with these additional cleanups. In case you would do that, do not rush - its Christmas time so first enjoy being with your family. Can be done next year as well... |
Here is one possible implementation of CI friendly variable resolver.
This has some things I don't personally like. For example CiInterpolatorImpl just basically replicates StringSearchInterpolator because first I tried to extend it and overwrite just some of the methods but that lead to weird classloading issues that I didn't have the energy to solve.
Also resolving variables inside profile dependencies doesn't work as it should but that is because of the multiple other problems in profile resolving in the flatten plugin.
Now I have found out that there might be some better solutions to flattening CI variables in poms. Like https://github.com/fmarot/cifriendly-maven-plugin which seems to be a much simpler approach to solving just this one problem. I haven't tried that plugin though.
Anyway, I just wanted to leave this so that other people can access this particular solution if it is what they need in their projects.