您必须使用 scm url 格式:
scm:<scm_provider><delimiter><provider_specific_part>
svn 示例:scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/plugins/maven-scm-publish-plugin/
配置是这样的:
<distributionManagement> <site> <id>site_id</id> <url>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/plugins/maven-scm-publish-plugin/</url> </site> </distributionManagement>
注意:使用 svn,如果远程 url 不存在,它将被创建。
使用 Git 分支(例如:GitHub gh-pages)
<distributionManagement> <site> <id>site_id</id> <url>scm:git:https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git</url><!-- or scm:git:ssh://git@github.com/username/tomcat-foo-artifact.git --> </site> </distributionManagement> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-publish-plugin</artifactId> <version>3.1.0</version> <configuration> <scmBranch>gh-pages</scmBranch> </configuration> </plugin>
必须手动完成分支的初始创建,作为 Git 孤儿分支:
1. git checkout --orphan gh-pages在本地创建分支,
2. rm .git/index ;git clean -fdx清理分支内容并让它清空,
3.复制一个初始网站内容,
4. 提交和推送:git add * , git commit -m "initial site content" , git push
默认情况下,完成结帐。您可以配置插件以尝试更新而不是完整的结帐/克隆
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-publish-plugin</artifactId> <version>3.1.0</version> <configuration> <tryUpdate>true</tryUpdate> </configuration> </plugin>
默认情况下,scm 内容被检出/克隆到${project.build.directory}/scmpublish-checkout,因此在运行mvn clean时,所有内容都会被删除。您可以配置机器的路径以避免完全结帐。推荐的方法是使用具有默认值的属性,您的同事将能够在他们的设置中覆盖该属性。
<properties> ... <!-- override in your settings --> <siteMainDirectory>${user.home}</siteMainDirectory> <scmPubCheckoutDirectory>\${siteMainDirectory}/my-site-content-scm</scmPubCheckoutDirectory> ... </properties> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-publish-plugin</artifactId> <version>3.1.0</version> <configuration> <checkoutDirectory>${scmPubCheckoutDirectory}</checkoutDirectory> <tryUpdate>true</tryUpdate> </configuration> </plugin>
如果您使用没有 svn cli 的机器,您可以使用 svnjava 而不是默认的 svn cli。
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-publish-plugin</artifactId> <version>3.1.0</version> <configuration> <providerImplementations> <svn>javasvn</svn> </providerImplementations> </configuration> <dependencies> <dependency> <groupId>com.google.code.maven-scm-provider-svnjava</groupId> <artifactId>maven-scm-provider-svnjava</artifactId> <version>2.0.6</version> </dependency> <dependency> <groupId>org.tmatesoft.svnkit</groupId> <artifactId>svnkit</artifactId> <version>1.7.11</version> </dependency> </dependencies> </plugin>