I am migrating a project to Maven and as we were used to always reference our builds by the latest change number in our Perforce SCM repository, I would like to be able to extract this information
I am trying to configure Maven scm plugin via following resources:
- http://maven.apache.org/scm/maven-scm-plugin/usage.html for generic usage
- http://www.perforce.com/perforce/doc.current/manuals/p4maven/index.html
First I don't understand how to make it work, so if anybody has a fully working example, I will be happy to, on my side I have tried by adding in my pom:
<scm>
<connection>
scm:perforce:localhost:1666://depot/
<my_project>
/
<version>
</connection>
<developerConnection>
scm:perforce:localhost:1666:/depot/
<my_project>
/
<version>
</developerConnection>
<url>http://somerepository.com/view.cvs</url>
</scm>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.6</version>
<dependencies>
<!-- P4Maven -->
<dependency>
<groupId>com.perforce</groupId>
<artifactId>p4maven</artifactId>
<version>[2011,2012)</version>
</dependency>
</dependencies>
<configuration>
<connectionType>//depot/proto/kernel/kernel/04.00/maven2</connectionType>
<username>my local username</username>
<password>xxxxxx</password>
<includes>**</includes>
</configuration>
</plugin>
</plugins>
this is leading me to:
[INFO] --- maven-scm-plugin:1.6:checkout (default-cli) @ kernel ---
mars 27, 2012 9:54:08 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
Avertissement: Error injecting: org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider
java.lang.NoClassDefFoundError: org/apache/maven/scm/command/info/InfoScmResult
Surely forgot something, I will try to read again the instructions and see what I miss, but if anybody knows ...
Anyway, my question is rather: is it worth trying it ? I don't see in the available actions from scm plugin anything that will help me getting the last change information and integrate it into a reference build number. Shall I develop my own plugin for this ?
Thanks in advance.
I was struggling with exactly the same problem recently - I just wanted to get a Perforce revision number to use it in maven artifacts (for example as a part of a name). I checked buildnumber-maven-plugin, but it does not support Perforce at all. I also tried maven-release-plugin, but it seems to me as it does too much and I even didn't find out if it will do what I need.
Anyway I ended up with a solution which I don't like, but it works. I get this revision number directly with p4 executable via ant and antrun plugin (you must use the latest 1.7 version to export ant property to maven). You also need to have p4 executable available.
After this plugin configuration is used you have ${revision.number} available in maven.
It's been a few years since the question was asked, but in the interval p4maven has been rewritten, and the updated documentation is startlingly hard to find.
Here's the new README.md. I followed it through and everything works. At this point, 1.0.6 is the latest version in maven central.
I discovered the source from a link on the Maven build number plugin page.
I got some advice from one of the P4Maven developers that might help.
First, check your configuration. The "..." in the "" tag should be one of the tag names in the "" tag (i.e. "connection" or "developerConnection")
There two options to use Maven with Perforce SCM.
Use the default (built-in) Maven Perforce SCM provider (p4 commandline based)
[environment variables] P4CLIENT= P4USER= P4PASSWD=
or
[JVM args] -Dusername= -Dpassword=
[pom.xml] ...
...
...
[pom.xml]
...
...
scm4:localhost:1666://depot/someproject scm4:localhost:1666://depot/someproject scm4://depot/someproject
...
Note that for P4Maven we're overriding the default provider inside the "maven-scm-plugin" plugin.
Note that we're using "scmp4" (if using P4Maven) instead of "scmperforce" (built-in default) as the provider name, since "perforce" is taken by the existing default implementation.
I landed here while searching for solution of a similar issue "NO Configuration could be determinded" which i faced with Code Collaborator client with P4. I ended up in uninstalling P4 client and reinstalling to get it working.