12

Apache Maven SCM Publish Plugin – Various Tips

 3 years ago
source link: https://maven.apache.org/plugins/maven-scm-publish-plugin/various-tips.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Various tips for using this plugin

URL format

You must use a scm url format:

  1. scm:<scm_provider><delimiter><provider_specific_part>

Example for svn: scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/plugins/maven-scm-publish-plugin/

And configure is as it:

  1. <distributionManagement>
  2. <site>
  3. <id>site_id</id>
  4. <url>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/plugins/maven-scm-publish-plugin/</url>
  5. </site>
  6. </distributionManagement>

NOTE: with svn, if the remote url doesn't exist, it will be created.

Git branch

To use Git branch (for example: GitHub gh-pages)

  1. <distributionManagement>
  2. <site>
  3. <id>site_id</id>
  4. <url>scm:git:ssh://[email protected]/username/tomcat-foo-artifact.git</url><!-- or scm:git:https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git -->
  5. </site>
  6. </distributionManagement>
  7. <plugin>
  8. <groupId>org.apache.maven.plugins</groupId>
  9. <artifactId>maven-scm-publish-plugin</artifactId>
  10. <version>3.0.0</version>
  11. <configuration>
  12. <scmBranch>gh-pages</scmBranch>
  13. </configuration>
  14. </plugin>

Initial creation of the branch has to be done manually, as a Git orphan branch:

1. git checkout --orphan gh-pages to create the branch locally,

2. rm .git/index ; git clean -fdx to clean the branch content and let it empy,

3. copy an initial site content,

4. commit and push: git add *, git commit -m "initial site content", git push

Improving SCM Checkout Performance

By default, a complete checkout is done. You can configure the plugin to try update rather than a full checkout/clone

  1. <plugin>
  2. <groupId>org.apache.maven.plugins</groupId>
  3. <artifactId>maven-scm-publish-plugin</artifactId>
  4. <version>3.0.0</version>
  5. <configuration>
  6. <tryUpdate>true</tryUpdate>
  7. </configuration>
  8. </plugin>

By default, the scm content is checked-out/cloned to ${project.build.directory}/scmpublish-checkout, so when running mvn clean, all the content is deleted. You can configure a path to your machine to avoid full checkout. A recommended way is to use a property with a default value that your colleague will be able to override in their settings.

  1. <properties>
  2. <!-- override in your settings -->
  3. <siteMainDirectory>${user.home}</siteMainDirectory>
  4. <scmPubCheckoutDirectory>\${siteMainDirectory}/my-site-content-scm</scmPubCheckoutDirectory>
  5. </properties>
  6. <plugin>
  7. <groupId>org.apache.maven.plugins</groupId>
  8. <artifactId>maven-scm-publish-plugin</artifactId>
  9. <version>3.0.0</version>
  10. <configuration>
  11. <checkoutDirectory>${scmPubCheckoutDirectory}</checkoutDirectory>
  12. <tryUpdate>true</tryUpdate>
  13. </configuration>
  14. </plugin>

Using alternate scm provider

You can use svnjava rather than default svn cli if you use a machine without svn cli.

  1. <plugin>
  2. <groupId>org.apache.maven.plugins</groupId>
  3. <artifactId>maven-scm-publish-plugin</artifactId>
  4. <version>3.0.0</version>
  5. <configuration>
  6. <providerImplementations>
  7. <svn>javasvn</svn>
  8. </providerImplementations>
  9. </configuration>
  10. <dependencies>
  11. <dependency>
  12. <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
  13. <artifactId>maven-scm-provider-svnjava</artifactId>
  14. <version>2.0.6</version>
  15. </dependency>
  16. <dependency>
  17. <groupId>org.tmatesoft.svnkit</groupId>
  18. <artifactId>svnkit</artifactId>
  19. <version>1.7.11</version>
  20. </dependency>
  21. </dependencies>
  22. </plugin>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK