在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jgitver/jgitver-maven-plugin开源软件地址(OpenSource Url):https://github.com/jgitver/jgitver-maven-plugin开源编程语言(OpenSource Language):Groovy 59.9%开源软件介绍(OpenSource Introduction):jgitver-maven-pluginThis plugin allows to define the pom version of your project using the information from your git history.
It calculates the version, a little bit like
Here is an illustration of the capabilities of the plugin UsageActivation by maven core extensionSince version via curl from the root directory of your project, run: sh -c "$(curl -fsSL https://raw.githubusercontent.com/jgitver/jgitver-maven-plugin/master/src/doc/scripts/install.sh)" via wget from the root directory of your project, run: sh -c "$(wget https://raw.githubusercontent.com/jgitver/jgitver-maven-plugin/master/src/doc/scripts/install.sh -O -)" manually
ConfigurationIn order to control jgitver-maven-plugin behavior, you can provide a configuration
file under Here is an example configuration file: <configuration xmlns="http://jgitver.github.io/maven/configuration/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jgitver.github.io/maven/configuration/1.1.0 https://jgitver.github.io/maven/configuration/jgitver-configuration-v1_1_0.xsd">
<mavenLike>true/false</mavenLike> <!-- deprecated, use 'strategy' instead -->
<strategy>MAVEN|CONFIGURABLE|PATTERN</strategy>
<policy>MAX|LATEST|NEAREST</policy> <!-- LookupPolicy to select the base tag/commit for the version computation -->
<autoIncrementPatch>true/false</autoIncrementPatch>
<useCommitDistance>true/false</useCommitDistance>
<useDirty>true/false</useDirty>
<useGitCommitId>true/false</useGitCommitId>
<useSnapshot>true/false</useSnapshot> <!-- use -SNAPSHOT in CONFIGURABLE strategy -->
<gitCommitIdLength>integer</gitCommitIdLength> <!-- between [8,40] -->
<maxSearchDepth>integer</maxSearchDepth> <!-- upper or equal to 1, ommited otherwise, default to infinite -->
<nonQualifierBranches>master</nonQualifierBranches> <!-- comma separated, example "master,integration" -->
<regexVersionTag>r([0-9]+)</regexVersionTag> <!-- a java regular expression with a capture group matching only
tags of the form r0, r1, ..., r34-->
<exclusions> <!-- Optional list of directory path -->
<exclusion>relative directory path</exclusion> <!-- relative path from project root directory -->
</exclusions>
<useDefaultBranchingPolicy>true/false</useDefaultBranchingPolicy> <!-- uses jgitver#BranchingPolicy#DEFAULT_FALLBACK as fallback branch policy-->
<branchPolicies>
<branchPolicy>
<pattern>pattern</pattern> <!-- regex pattern -->
<!-- list of transformations to apply, if empty, defaults to REPLACE_UNEXPECTED_CHARS_UNDERSCORE, LOWERCASE_EN -->
<transformations>
<transformation>NAME</transformation> <!-- transformation name, one of jgitver#fr.brouillard.oss.jgitver.BranchingPolicy#BranchNameTransformations -->
...
</transformations>
</branchPolicy>
...
</branchPolicies>
</configuration> Please consult jgitver documentation to fully understand what the parameters do. Old xml schemas are kept for reference. Command line arguments
Working on a detached HEADWhen working on a detached HEAD, no branch information exists anymore from git.
Available output propertiesThe plugin exposes git calculated properties available during the maven build.
Those are available under the following properties name: "jgitver.meta" where You can then use them as standard maven properties in your build: <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>used version: ${jgitver.used_version}</echo>
<echo>version calculated: ${jgitver.calculated_version}</echo>
<echo>dirty: ${jgitver.dirty}</echo>
<echo>head_committer_name: ${jgitver.head_committer_name}</echo>
<echo>head_commiter_email: ${jgitver.head_commiter_email}</echo>
<echo>head_commit_datetime: ${jgitver.head_commit_datetime}</echo>
<echo>git_sha1_full: ${jgitver.git_sha1_full}</echo>
<echo>git_sha1_8: ${jgitver.git_sha1_8}</echo>
<echo>branch_name: ${jgitver.branch_name}</echo>
<echo>head_tags: ${jgitver.head_tags}</echo>
<echo>head_annotated_tags: ${jgitver.head_annotated_tags}</echo>
<echo>head_lightweight_tags: ${jgitver.head_lightweight_tags}</echo>
<echo>base_tag: ${jgitver.base_tag}</echo>
<echo>all_tags: ${jgitver.all_tags}</echo>
<echo>all_annotated_tags: ${jgitver.all_annotated_tags}</echo>
<echo>all_lightweight_tags: ${jgitver.all_lightweight_tags}</echo>
<echo>all_version_tags: ${jgitver.all_version_tags}</echo>
<echo>all_version_annotated_tags: ${jgitver.all_version_annotated_tags}</echo>
<echo>all_version_lightweight_tags: ${jgitver.all_version_lightweight_tags}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin> resulted in my case
You can also output the properties into a file so that they can be picked
up by the next steps in your build pipeline. This is accomplished by setting
the
The produced file follows the Java Properties standard. ExampleIf you want to give it a try you can use the following script that will setup a demo project under
Then play around with it doing:
RequirementsMaven requirementsjgitver-maven-plugin requires at least maven-3.3.2 to work correctly. Think to modify your IDE settings regarding maven version ; if required do not use the embedded maven version of your IDE but an external one that fulfill the maven minimal requirements. Supported IDEs
Build & releasesee also the Contributing guide. Github Markdown renderingBefore pushing try to always verify that the modifications pushed in MD files will be correctly rendered by Github. Normal build
or using docker
build and filter some IT tests
If needed, one can also add in above docker command a volume sharing
with the maven local repository by adding something like Release
IssuesI want to temporary disable the plugin executionSince
maven reports my project version to be 0 (or the one set in the pom.xml)If your version is not calculated correctly by maven/jgitver, there are good chances that the plugin is not active. build fail because all project plugins & dependencies resolve to the same versionif during a build all the plugins & dependencies are resolved to the exacts same version then chances are high that you have the local maven repository as a subdirectory of your jgitver handled project. To overcome this problem you have 2 possibilities:
see also #90 && #91 for discussions on this topic. the invoker tests of my maven plugin project do not work anymoreIf you develop a maven plugin project, you normally run maven-invoker-plugin to test your plugin. To avoid such behavior, you need to tell <configuration>
<exclusions>
<exclusion>target/local-repo</exclusion>
<exclusion>target/it/**</exclusion>
</exclusions>
</configuration> You can have a look at the configuration of jgitver-maven-plugin itself. Licensejgitver-maven-plugin is delivered under the Apache Licence, Version 2 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论