How to configure maven-release to use Perforce as SCM provider?

…衆ロ難τιáo~ 提交于 2019-12-11 02:59:58

问题


I am trying to use the maven release plugin to create a released version of a Java project having Perforce as the SCM.

My pom scm section is:

<scm>
  <connection>scm:p4:myperforcehostname:1666://mydepot/mycomponent</connection>
  <developerConnection>scm:p4:myperforcehostname:1666://mydepot/mycomponent</developerConnection>
  <url>http://myperforcehostname:1666</url>
</scm>

Also I use the P4Maven plugin and the Maven Release Plugin:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-scm-plugin</artifactId>
  <version>1.4</version>
  <dependencies>
    <dependency>
      <groupId>com.perforce</groupId>
      <artifactId>p4maven</artifactId>
      <version>[2011,2012)</version>
    </dependency>
  </dependencies>
  <configuration>
    <connectionType>connection</connectionType>
    <username>myusernme</username>
    <password>mypassword</password>
    <includes>**</includes>
  </configuration>
</plugin>        
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.5</version>
</plugin>

When calling 'mvn release:prepare -DdryRun=true' I get

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:prepare 
(default-cli) on project mycomponent: The provider given in the SCM URL could not be found: 
No such provider: 'p4'. -> [Help 1]

Any ideas?

I am able to call mvn scm:checkout.


回答1:


You need to add the p4maven as dependency to the maven-scm-plugin as well as to the maven-release-plugin.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-scm-plugin</artifactId>
  <version>1.4</version>
  <dependencies>
    <dependency>
      <groupId>com.perforce</groupId>
      <artifactId>p4maven</artifactId>
      <version>[2011,2012)</version>
    </dependency>
  </dependencies>
  <configuration>
    <connectionType>connection</connectionType>
    <username>username</username>
    <password>password</password>
    <includes>**</includes>
  </configuration>
</plugin>        
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.5</version>
  <dependencies>
    <!-- P4Maven -->
    <dependency>
      <groupId>com.perforce</groupId>
      <artifactId>p4maven</artifactId>
      <version>[2011,2012)</version>
    </dependency>
  </dependencies>
  <configuration>
    <connectionType>connection</connectionType>
    <username>username</username>
    <password>password</password>
    <includes>**</includes>
  </configuration>
</plugin>



回答2:


It turned out that P4Maven comes not out of the box. I had to download it from the Perforce pages and install it into my repository (following the instructions in the download zip file). After that I could successfully use p4 as the SCM provider.




回答3:


Here I done recently:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.9.4</version>
            <dependencies>
                <dependency>
                    <groupId>com.perforce.p4maven</groupId>
                    <artifactId>p4maven-provider</artifactId>
                    <version>1.0.6</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
            <dependencies>
                <dependency>
                    <groupId>com.perforce.p4maven</groupId>
                    <artifactId>p4maven-provider</artifactId>
                    <version>1.0.6</version>
                </dependency>
            </dependencies>
        </plugin>

And then some useful commands:

mvn scm:changelog -Dusername=yourP4user -Dpassword=yourP4pwd
release:prepare -Dusername=yourP4user -Dpassword=yourP4pwd -autoVersionSubmodules=true -DignoreSnapshots=true


来源:https://stackoverflow.com/questions/22814138/how-to-configure-maven-release-to-use-perforce-as-scm-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!