Bootstrapping a Project Using a POM

Using the scm:bootstrap a project can be build from a fresh copy of the source in the scm repository. This is a convenient way to distribute a project because the bootstrap pom can be given to a developer to generate the maven build environment for the project.

The pom.xml should contain a scm configuration for the bootstrap to work.

<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>
  ...
  <build>
    ...
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-plugin</artifactId>
        <version>1.9.1</version>
        <configuration>
          <goals>install</goals>
        </configuration>
      </plugin>
    </plugins>
    ...
  </build>
  ...
</project>

Assuming the scm configuration has been configured in the pom.xml, bootstrapping can be invoked by

   mvn scm:bootstrap

By default the scm plugin will get the latest version from the trunk and generate it under target/checkout and execute the configured goals in it.

Configuring Authentication

Most public repositories requires developers to authenticate first before they can pull the source from the repository. For repositories requiring authentication, the scm plugin needs to be configured in one of the following ways:

  • In the poml.xml
    <project>
      ...
      <build>
        ...
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.9.1</version>
            <configuration>
              <username>username</username>
              <password>password</password>
            </configuration>
          </plugin>
        </plugins>
        ...
      </build>
      ...
    </project>
  • In the settings.xml via a server entry, using the host name from the connection URL as the server id
    <settings>
      ...
      <servers>
        <server>
          <id>hostname</id>
          <username>username</username>
          <password>password</password>
        </server>
      </servers>
      ...
    </settings>

    Since version 1.5, the plugin also recognizes encrypted passwords.