Maven provides a mechanism to interact with SCM systems in a vendor-independent way. Typically, a Maven project is checked in an SCM. Using the Maven SCM plugin, you can perform a number of SCM-related activities.
The Maven project that we want to use the plugin with should be in an SCM. Maven supports a number of SCM providers. We will use Git to illustrate this.
<scm> <connection>scm:git:https://bitbucket.org/maruhgar/apache-maven-cookbook</connection> <developerConnection>scm:git:https://[email protected]/maruhgar/apache-maven-cookbook</developerConnection> <url>https://bitbucket.org/maruhgar/apache-maven-cookbook</url> </scm>
mvn scm:status
When the status
goal of the Maven SCM plugin is run, it uses the information in the scm
tag of the pom
file to get the SCM details. It uses this information and invokes the corresponding scm
command to get the status information. In the preceding example, it is the git status
.
There are three entries in the scm
tag:
connection
: This is the connection information to access the repository. This is typically in the following form:<service name>:<scm implementation>:<repository url>
service name
: This would be an SCMscm implementation
: This would be one of the supported SCMsrepository url
: This would be a URL for the repositorydeveloperConnection
: This is similar to any connection, except that this may need authentication or have additional privileges. Typically, the connection
access would be read-only, while the developerConnection
access would be read-write.url
: This is the repository URL.You will also notice that the appropriate shell command is used based on the operating system, which is cmd.exe
in the case of Windows and sh
in the case of Linux.
The Maven SCM plugin provides a number of other commands for various SCM operations, such as add
, remove
, checkin
, checkout
, update
, diff
, branch
, and tag
.
Bootstrap is an interesting option to checkout and build a project with:
bootstrap-project
file).scm
section:<scm> <connection>scm:git:https://github.com/maruhgar/mvn-examples</connection> <url>https://github.com/maruhgar/mvn-examples</url> </scm>
build
section:<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>1.9.2</version> <configuration> <goals>install</goals> <goalsDirectory>test-properties</goalsDirectory> </configuration> </plugin> </plugins> </build>
mvn scm:bootstrap
Our Maven project has checked another Maven project, using the information in the scm
section, and run the specified goal on this. We specify a goalsDirectory
element because the SCM contains a number of projects and we want to execute the goals for a specific project, in this case test-properties
.
3.138.204.186