by
P4Maven is a Maven SCM Plugin Provider that implements Maven's generic SCM API for the Perforce SCM system using the Perforce Java API.
Maven SCM supports Maven 2.x plugins and other tools by providing them with a common API for doing SCM operations. The Maven SCM Plugin offers vendor-independent access to common SCM commands by offering a set of command mappings for the configured SCM system. Each command is implemented as a goal.
P4Maven implements the goals of the Maven SCM Plugin 1.4 and Maven 2.x. Please see the following link for details:
Note: P4Maven is known to work with P4Java 2010.1+ (Perforce Java API), JDK 1.5.0+, Maven SCM Plugin 1.4 and Maven 2.x
The main semantic issue faced by the provider is CVS/SVN's concept of a working copy versus Perforce's concept of a client workspace specification.
CVS/SVN allow the user to check out any repository location to any local directory at will and tracks this by keeping metadata in a CVS/.svn directory. Perforce uses a client workspace concept whereby it keeps track of the mapping of repository locations to local filesystem locations within the Perforce server. This creates restrictions on where users can check out projects.
The following system properties can be set by the user:
P4Maven POM Snippet:
... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>1.4</version> <dependencies> <!-- P4Maven --> <dependency> <groupId>com.perforce</groupId> <artifactId>p4maven</artifactId> <version>[2011,2012)</version> </dependency> </dependencies> <configuration> <connectionType>connection</connectionType> <username>someuser</username> <password>somepassword</password> <includes>**</includes> </configuration> </plugin> <!-- SCM Settings --> <scm> <connection>scm:p4:localhost:1666://depot/someproject</connection> <developerConnection>scm:p4:localhost:1666://depot/someproject</developerConnection> <url>http://somerepository.com/view.cvs</url> </scm> ...
P4Maven Commandline Snippet:
mvn -Dmaven.scm.perforce.clientspec.name=someclient scm:checkout
P4Maven also comes with a set of Mojos that implement additional Perforce commands as Maven goals.
P4Maven Mojo specific system properties can be set by the user:
P4Maven Mojo POM Snippet:
... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>1.4</version> <dependencies> <!-- P4Maven --> <dependency> <groupId>com.perforce</groupId> <artifactId>p4maven</artifactId> <version>[2011,2012)</version> </dependency> </dependencies> <configuration> <connectionType>connection</connectionType> <username>someuser</username> <password>somepassword</password> <includes>**</includes> </configuration> </plugin> <!-- P4Maven Mojo --> <plugin> <groupId>com.perforce</groupId> <artifactId>p4maven-mojo</artifactId> <version>[2011,2012)</version> <configuration> <connectionType>connection</connectionType> <username>someuser</username> <password>somepassword</password> <includes>**</includes> </configuration> </plugin> </plugins> </build> <!-- SCM Settings --> <scm> <connection>scm:p4:localhost:1666://depot/someproject</connection> <developerConnection>scm:p4:localhost:1666://depot/someproject</developerConnection> <url>http://somerepository.com/view.cvs</url> </scm> ...
P4Maven Mojo Commandline Snippet:
Synosis: mvn groupID:artifactID:version:goalmvn com.perforce:p4maven-mojo:2011.1.1-SNAPSHOT:shelve -Dmaven.scm.perforce.clientspec.name=someclient -Dmaven.scm.p4.changelist=17815