Usage

The SCM Plugin maps a lot of commands to a variety of scm implementations. But there are only 2 frequently used commands:

  • checkin - commit the changes to the remote repository ( scm server ).
  • update - updates the local working copy with the one from the remote repository ( scm server ).

Configuring SCM

Each scm has a different command line invocation to commit the modified sources. Using maven this process is simplified by providing a uniform way to do this by letting maven handle the command line translation to perform the scm task.

To configure the scm support for maven you need the scm configuration in your pom.xml.

<project>
  ...
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>SCM Sample Project</name>
  <url>http://somecompany.com</url>
  <scm>
    <connection>scm:svn:http://somerepository.com/svn_repo/trunk</connection>
    <developerConnection>scm:svn:https://somerepository.com/svn_repo/trunk</developerConnection>
    <url>http://somerepository.com/view.cvs</url>
  </scm>
  ...
</project>

Maven will use the information embedded in the scm configuration to determine the command mapping for the scm command. The scm configuration url is composed of different information that defines the mapping:

   scm:svn:http://somerepository.com/svn_repo/trunk
   <service name>:<scm implementation>:<repository url>

Check the maven scm list for the list of supported SCMs.

Committing and updating changes through Maven

Assuming that SCM has been configured in the pom.xml and the project directory is managed by a SCM, invoking the checkin goal in the scm will start the commit process for all configured sources in your pom.xml.

The files should be added beforehand by an external scm client.

  mvn -Dmessage="<commit_log_here>" scm:checkin

for update

  mvn scm:update

Specifying the scm connection to use

There two possible scm connections that can be used in the pom.xml, connection and developerConnection.

  • connection configuration
    <project>
      ...
      <build>
        [...]
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.9.4</version>
            <configuration>
              <connectionType>connection</connectionType>
            </configuration>
          </plugin>
          ...
        </plugins
        ...
      </build>
      ...
    </project>
  • developerConnection configuration
    <project>
      ...
      <build>
        ...
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.9.4</version>
            <configuration>
              <connectionType>developerConnection</connectionType>
            </configuration>
          </plugin>
          ...
        </plugins
        ...
      </build>
      ...
    </project>

Related Links