-
Notifications
You must be signed in to change notification settings - Fork 265
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
Add goal that works with Maven CI Friendly Versions and set property (revision) based on git tag #1071
Comments
Would you approve a PR with this functionality? |
maybe you should use an extension for this rather than a plugin. https://maven.apache.org/examples/maven-3-lifecycle-extensions.html |
Ended up creating our own plugin. Could use Maven SCM API and it did feel right to add the JGit dependency. We haven't published it yet, so we could potentially provide it as an extension but probably need some guidance then. Also, we are in need of this now really and I'm not sure how long it would take for a PR and a release to happen. |
Your code with JGit looks simple, Maven SCM Api add support for others tools - I will try with it.
As next goal will be easier than extension.
Release can happen in a few days after merge. I watch a repository and when we have new feature or bug fix I will simply release. |
@slawekjaranowski I tried with Maven SCM API, but it seemed like it was to simple for this use-case. Could be that I missed out on something. I reckon it might will be configurable later on how the git repo should be traversed from the starting commit (branch only etc), so for flexibility I'd prefer JGit. You wrote "I will try with it". Was that as in you or a suggestion for me?
Not following here either. We would rather see this feature incorporated in the Versions Maven plugin as it involves versioning of POMs but with another angle, i.e. instead of changing the actual POM.xml once uses CI/CD and tags. I'm a bit stressed for time now (3 weeks since I wrote here) and we need this feature asap. As for our code we will donate it without any copyright claims or what not. However, the plugin contains a modified (VersionInformation) of code that is copyrighted by Karl Heinz Marbaise under MIT License for mojohaus. Is there a solution to this (licenses are MIT for build-helper and Apache 2.0 for Versions)? |
Suggestion for you 😄
I think about new goal.
It is open source project maintained by volunteers in their free time, so I can not give you any promise about timelines.
We use maven-invoker-plugin for IT test, there are possibility to use pre - setup and post - verify script
We can copy as is with preserving license header .... or change @khmarbaise what do you think |
|
@slawekjaranowski Would it be possible to elaborate a little moe on how to use the maven invoker plugin for testing with git repos? I'm looking at e.g. it-823-ranges-update-report-001 and it-set-scm-tag-004 but it's not clear to me how I use maven invoker plugin to either use a pre-set git repository or to create on of the fly. This in order to have test data. I'm thinking that I need to use JGit to setup and then regular JUnit. I honestly think that testing Maven plugin is a mess. Shall I use the |
With invoker, create a file:
if git will not available on system test will be skipped next you create:
and finally create a you can execute only one test by:
|
Thank you. I'll start work on this this week (currently, upgrading our internal pipelines). During that upgrade, I realized that you sometimes need to bypass the version being set based on git (e.g. when testing). In Python the tools use environment variables such as
Are there existing environment variables used by Versions Maven Plugin and if so, how are they named? Otherwise my suggestion is:
|
The maven wrapper specified in the project uses version 3.8.6 of Maven, but:
It seems a the Maven Wrapper haven't been updated in sometime and I know that there have been some significant changes to it (provided a PR myself if I recall right). I'm having issues running mvnw when behind our company proxy - both directly and via our internal JFrog Artifactory (using a locally installed Maven works fine). I think it would be good to update the Maven Wrapper in Versions to rule out and issue that has been resolved. Off topic: |
What for such env will be used ... if it is a parameter for Mojo you simply should use a filed with annotation |
eh ... don't use a wrapper it can be generate more problems like proxy etc ...
What command do you execute ? 3.9.0 is required only for release as I remember. |
Ok. That explains it. Before I saw your command in #1071 (comment) I ran |
Normally yes. But, but there are occasions for a SCM plugin goal that needs to be compatible with CI systems when you can't set/use the Maven Plugin parameter. Without those two environment variables (used by Python build systems hatch and poetry) it would have been really difficult to write tests for our build system among other things. The option to by pass the plugin setting the property can be be particularly useful in CI/CD pipelines or in build environments where the SCM metadata might not be fully available or accessible. Typically, during testing, you might want to temporarily override the automatic versioning behavior without modifying the configuration files or the SCM tags. |
I believe that the creation of a new git repository in I've been able to find any information, but is there a best practice for mojohaus plugins on how to use the invoker to create a temporary directory in setup.groovy, pass the information to verify.groovy (unless verify.groovy remains in the same cwd as setup.groovy) and then assuring that the temporary directory is cleaned up after the test? From what I have read and verified the invoker will clone the integration test project to I could really use a pointer then as I would like to do the following:
|
Maven supports Maven CI Friendly Versions since version 3.5.
It allows the user to set a placeholder
<version>${revision}</version>
that can be replaced from command line using:
e.g.
mvn -Drevision=1.0.0-SNAPSHOT clean package
Our use-case is that you want this revision property (can be configurable) to be set by a Maven plugin using tag information from the scm (typically, git).
The revision property should be set as follows:
note: will be set to variants of nr of commits
That is the basics. I was contemplating writing a plugin for it, but we'll rather so it incorporated in into this plugin.
Build number will be handled correctly by Maven as can be seen here:
The text was updated successfully, but these errors were encountered: