Today, I would like to explain the improvement for maven plugin - buildNumber, that I talked in my previous message - short revision id for Git SCM.
IMPORTANT : This feature is present in the maven-buildnumber-plugin 1.1 version.
You can specify the
length for the Git revision. To enable this feature you have to specify the new tag
<shortRevisionLength>
in the
<configuration>
section. For exemple:
The associated maven output informs us about the detection of
shortRevisionLength tag and print the length of the revision that will be used in buildNumber formatting:
Some implementation details
This feature uses internally the
git rev-pasre --short (see associated
git help section) command and the revision length is set to minimum 4 characters. So you can't have the revision id shorter then 4 characters. Even if you specify the length between 0 and 4, the plugin will inform you about this situation and the minimum value (4) will be used.
UPDATED: If your maven build can't find the dependency for maven-buildnumber-plugin 1.1 , try to force the dependency update by adding option "-U" for your mvn command.
22 commentaires:
I have tried using the shortRevisionLength tag but I get the following error each time I try: [INFO] Error configuring: org.codehaus.mojo:buildnumber-maven-plugin. Reason: ERROR: Cannot override read-only parameter: shortRevisionLength in goal: buildnumber:create
I'm using 1.1-SNAPSHOT. Any thoughts on this one?
Strange. I have checked the coude source of buildnumber mojo class, the shortRevisionLength field has its own public setter method. I have also executed the goal buildnumber:create on my projects and it passed with success. Can you provide more information about your plugin config.
I had to go and manually change plugin.xml inside the jar file META-INF/maven directory to get this thing to work.
I updated the following parameter:
shortRevisionLength
int
false
true
Max length of a revision id (used only for git)
The 'editable' was set to false.
Once I changed that to true it worked like a charm. Do you think you could verify that and upload a new version into the repo?
Thanks.
Alex K.
Hello Alex,
Thanks for your insight.
Actually the field shortRevisionLength has the "readonly" annotation. I have removed it and the generated plugin.xml has a correct 'editable = true'.
The patch was sent today. Details here - http://jira.codehaus.org/browse/MBUILDNUM-86
I will notify you when this patch will be applied to the central repo.
Hi Alex,
I just received the notification that the patch was applied and pushed to the project SVN, you can try it.
And thank you again for the contribution.
Awesome, thanks for the update. All the best.
Hello Yevgeny,
I am experiencing problems building my projects that use buildnumber plugin. Bunch of dependencies refer to 1.7-SNAPSHOT version that is nowhere to be found.
all scm related artifacts are missing for this version.
Could you please look into this?
Thank you in advance for your help.
Alex K
Hi Yevgeny,
I'm experiencing problems with buildnumber plugin. 11 dependecnies are missing for version 1.7-SNAPSHOT:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) org.apache.maven.scm:maven-scm-api:jar:1.7-SNAPSHOT
2) org.apache.maven.scm:maven-scm-manager-plexus:jar:1.7-SNAPSHOT
3) org.apache.maven.scm:maven-scm-provider-bazaar:jar:1.7-SNAPSHOT
4) org.apache.maven.scm:maven-scm-provider-svnexe:jar:1.7-SNAPSHOT
5) org.apache.maven.scm:maven-scm-provider-gitexe:jar:1.7-SNAPSHOT
6) org.apache.maven.scm:maven-scm-provider-svn-commons:jar:1.7-SNAPSHOT
7) org.apache.maven.scm:maven-scm-provider-cvsexe:jar:1.7-SNAPSHOT
8) org.apache.maven.scm:maven-scm-provider-starteam:jar:1.7-SNAPSHOT
9) org.apache.maven.scm:maven-scm-provider-clearcase:jar:1.7-SNAPSHOT
10) org.apache.maven.scm:maven-scm-provider-perforce:jar:1.7-SNAPSHOT
11) org.apache.maven.scm:maven-scm-provider-hg:jar:1.7-SNAPSHOT
----------
11 required artifacts are missing.
for artifact:
org.codehaus.mojo:buildnumber-maven-plugin:maven-plugin:1.1-20120423.154815-3
from the specified remote repositories:
apache.snapshots (https://repository.apache.org/content/groups/snapshots-group/),
oss.sonatype.snapshots (https://oss.sonatype.org/content/repositories/snapshots),
central (http://repo1.maven.org/maven2),
appfuse-snapshots (http://oss.sonatype.org/content/repositories/appfuse-snapshots),
codehaus-snapshots (http://nexus.codehaus.org/snapshots/),
codehouse-s-repo (https://nexus.codehaus.org/content/groups/snapshots-group),
maven.tmatesoft.com.releases (http://maven.tmatesoft.com/content/repositories/releases),
springsource-repo (http://repo.springsource.org/release)
Hi Alex,
In your repositories list (from the error msg listing) I don't see the repo from the codehouse. Try to add this repo https://nexus.codehaus.org/content/groups/snapshots-group, the exact syntax for adding the codehouse SNAPSHOT repo you can find in this article (the last section). I hope this will work for you
Hey but if you look at the list it is 3rd from the bottom:
codehouse-s-repo (https://nexus.codehaus.org/content/groups/snapshots-group)
Exactly, I didn't see it. Sorry.
Which version of Java you are using? I experience another problem with those 11 dependencies when I switched to JDK 7.
For me the message is Could not transfer metadata org.apache.maven.scm:maven-scm-provider-perforce:1.7-SNAPSHOT/maven-metadata.xml from/to codehouse-s-repo (https://nexus.codehaus.org/content/groups/snapshots-group): Error transferring file: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
I'll investigate this issue in more details.
I use 1.6. And everything has been working just fine until yesterday. Before it would go and look up the updated snapshots once a day and the versions would be like long integers, but now the version is 1.7 and it can't find it. I believe some changes were made in plugin pom or something and now I can't use it at all. I had to comment it out because the project won't build.
You can use --offline flag to make your build running without error. Of course, it's very limited workaround, but may be we'll find the solution quickly. I'll contact the main maintainer of the SCM's plugin to ask about our problems.
Hi Alex,
I have synchronized the build-number project. The last SVN modifications have changed the version if this plugin, now it is 1.2-SNAPSHOT and NOT 1.1.
Maybe it will fix your problem.
Thank Yevgeny, I guess it's a progress since I get a different error now :). Pls see below.
akirillov@thinkpad:~/workspaces/ekahau/erci$ mvn clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Ekahau ERC Integration Module
[INFO] task-segment: [clean, package]
[INFO] ------------------------------------------------------------------------
Downloading: https://nexus.codehaus.org/content/groups/snapshots-group/org/codehaus/mojo/buildnumber-maven-plugin/1.2-SNAPSHOT/buildnumber-maven-plugin-1.2-SNAPSHOT.pom
[INFO] Unable to find resource 'org.codehaus.mojo:buildnumber-maven-plugin:pom:1.2-SNAPSHOT' in repository codehouse-s-repo (https://nexus.codehaus.org/content/groups/snapshots-group)
Downloading: http://oss.sonatype.org/content/repositories/appfuse-snapshots/org/codehaus/mojo/buildnumber-maven-plugin/1.2-SNAPSHOT/buildnumber-maven-plugin-1.2-SNAPSHOT.pom
[INFO] Unable to find resource 'org.codehaus.mojo:buildnumber-maven-plugin:pom:1.2-SNAPSHOT' in repository appfuse-snapshots (http://oss.sonatype.org/content/repositories/appfuse-snapshots)
Downloading: http://oss.sonatype.org/content/repositories/appfuse-snapshots/org/codehaus/mojo/buildnumber-maven-plugin/1.2-SNAPSHOT/buildnumber-maven-plugin-1.2-SNAPSHOT.pom
[INFO] Unable to find resource 'org.codehaus.mojo:buildnumber-maven-plugin:pom:1.2-SNAPSHOT' in repository appfuse-snapshots (http://oss.sonatype.org/content/repositories/appfuse-snapshots)
Downloading: http://repo.springsource.org/release/org/codehaus/mojo/buildnumber-maven-plugin/1.2-SNAPSHOT/buildnumber-maven-plugin-1.2-SNAPSHOT.pom
[INFO] Unable to find resource 'org.codehaus.mojo:buildnumber-maven-plugin:pom:1.2-SNAPSHOT' in repository springsource-repo (http://repo.springsource.org/release)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.codehaus.mojo:buildnumber-maven-plugin
Reason: POM 'org.codehaus.mojo:buildnumber-maven-plugin' not found in repository: Unable to download the artifact from any repository
org.codehaus.mojo:buildnumber-maven-plugin:pom:1.2-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2),
appfuse-snapshots (http://oss.sonatype.org/content/repositories/appfuse-snapshots),
codehouse-s-repo (https://nexus.codehaus.org/content/groups/snapshots-group),
springsource-repo (http://repo.springsource.org/release)
for project org.codehaus.mojo:buildnumber-maven-plugin
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed May 02 14:45:03 EDT 2012
[INFO] Final Memory: 12M/309M
[INFO] ------------------------------------------------------------------------
Ok, I already have this issue too. I can't explain what is wrong, but I have to reinitialize my local maven repo. Try to delete all artifacts from the codehouse folder.
no joy even after cleaning codehaus. maybe it's time to create a ticket in their issue tracker. something is broken.
The problem is I can't reproduce the problem in my environment. I don't know how to formalize the issue... I will try to reproduce the issue in completely new Maven installation.
Hi Alex,
I have received the responose from the main committer of the plugin. The version 1.1 is currently under the dev for release and it may be available from the central repo tomorrow . See http://markmail.org/message/kagk7ubprhlazaeb
Good news. Thank you. I appreciate your help with this.
Thank you for the improvement Mr. Yevgen. Is there a way to access the buildNumber in the tag of the buildnumber plugin?
Something like:
{1}.{0,date,yyyy.MM.dd.HH.mm.ss}
timestamp
${git.sha1}
Hi, I'm not sure...
You can ask this question on the developers forum of the plugin - http://jira.codehaus.org/browse/MBUILDNUM.
The community is very responsive and I hope you will get the answer.
Enregistrer un commentaire