Usage

The maven-scm-publish-plugin submits modified content to SCM, sites being the most classical case. There are two ways you can set this up for site in your POM.

Use the Custom Lifecycle

Unfortunately, a Maven plugin can't define a top-level lifecycle like 'site'. However, it can come close. The plugin includes the scmpublish goal. This goal does nothing except fork a custom scmpublish lifecycle, consisting of the following phases:

  • scmpublish-prepare
  • scmpublish-pre-site
  • scmpublish-site
  • scmpublish-post-site
  • scmpublish-publish

(Again unfortunately, Maven does not allow a custom lifecycle to share phases with some other lifecycle.)

With a little configuration in your POM,

  mvn scm-publish:scmpublish

will do all the work.

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-scm-publish-plugin</artifactId>
          <version>@pom.version@</version>
          <extensions>true</extensions>
          <configuration>
            <!-- svn location for publication -->                  
            <pubScmUrl>scm:svn:https://svn.apache.org/repos/asf/maven/sandbox/bimargulies/site-test-003</pubScmUrl>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

Notice: this is actually not working, the 003-lifecycle IT has been disabled.

Using the Site Lifecycle

The alternative is to attach the necessary activities to the site lifecycle and deactivate maven-site-plugin's site deploy goal. This requires more XML in the POM, but it may be easier to use if you already customize the site lifecycle for other reasons.

  <distributionManagement>
    <site>
      <id>site</id>
      <url>scm:svn:https://svn.apache.org/repos/asf/maven/sandbox/bimargulies/site-test</url>
    </site>
  </distributionManagement>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <configuration>
            <skipDeploy>true</skipDeploy>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <executions>
          <execution>
            <id>stage-for-scm-publish</id>
            <phase>post-site</phase>
            <goals>
              <goal>stage</goal>
            </goals>
            <configuration>
              <skipDeploy>false</skipDeploy><!-- MSITE-652: configuration won't be necessary with m-site-p 3.2 -->
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-publish-plugin</artifactId>
        <version>@pom.version@</version>
        <executions>
          <execution>
            <id>scm-publish</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>publish-scm</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>