scm 插件需要在pom.xml中配置 scm 。
<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.cgi</url> </scm> ... </project>
如果你想改变默认的 scm 提供者实现,例如你想使用原生 Git 而不是纯 Java 实现,你必须像这样配置你的插件:
<project> ... <build> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>2.0.0-M1</version> <configuration> <providerImplementations> <git>git</git> </providerImplementations> </configuration> </plugin> ... </plugins ... </build> ... </project>
一旦配置了 scm,就可以执行 scm 操作。
pom.xml配置:
<project> ... <build> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>2.0.0-M1</version> <configuration> <startDate>YYYY-MM-DD</startDate> <endDate>YYYY-MM-DD</endDate> </configuration> </plugin> ... </plugins ... </build> ... </project>
命令 :
mvn scm:changelog
或者您可以在命令行上指定 startDate 和 endDate
mvn -DstartDate=YYYY-MM-DD -DendDate=YYYY-MM-DD scm:changelog
pom.xml配置:
<project> ... <build> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>2.0.0-M1</version> <configuration> <startRevision>connection</startRevision> <endRevision>connection</endRevision> </configuration> </plugin> ... </plugins ... </build> ... </project>
命令 :
mvn scm:diff
或者您可以在命令行中指定 startRevision 和 endRevision
mvn -DstartRevision=<revision> -DendRevision=<revision> scm:diff
pom.xml配置:
<project> ... <build> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>2.0.0-M1</version> <configuration> <tag>tag name</tag> </configuration> </plugin> ... </plugins ... </build> ... </project>
命令 :
mvn scm:tag
或者您可以在命令行中指定标签名称
mvn -Dtag="<tag name>" scm:tag