Configure Perforce scm in a maven project to get the latest list of changes

I am migrating the project to Maven, and since we are used to always referring to our assemblies by the latest change number in our Perforce SCM repository, I would like to be able to extract this information

I am trying to configure the Maven scm plugin through the following resources:

At first I don’t understand how to make it work, so if anyone has a fully working example, I will be glad, on my side I tried to add to my pom:

<scm>
    <connection>
        scm:perforce:localhost:1666://depot/
        <my_project>
            /
            <version>
    </connection>
    <developerConnection>
        scm:perforce:localhost:1666:/depot/
        <my_project>
            /
            <version>
    </developerConnection>
    <url>http://somerepository.com/view.cvs</url>
</scm>
...
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-plugin</artifactId>
        <version>1.6</version>
        <dependencies>
            <!-- P4Maven -->
            <dependency>
                <groupId>com.perforce</groupId>
                <artifactId>p4maven</artifactId>
                <version>[2011,2012)</version>
            </dependency>
        </dependencies>
        <configuration>
            <connectionType>//depot/proto/kernel/kernel/04.00/maven2</connectionType>
            <username>my local username</username>
            <password>xxxxxx</password>
            <includes>**</includes>
        </configuration>
    </plugin>
</plugins>

this leads me to:

[INFO] --- maven-scm-plugin:1.6:checkout (default-cli) @ kernel ---
mars 27, 2012 9:54:08 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
Avertissement: Error injecting: org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider
java.lang.NoClassDefFoundError: org/apache/maven/scm/command/info/InfoScmResult

, - , , , - ...

, : ? scm plugin -, . ?

.

+5
4

P4Maven, .

. "..." " " "(.." "" ")

Maven Perforce SCM.

  • () Maven Perforce SCM (p4 )

    • , p4
    • , JVM args

[ ] P4CLIENT = P4USER = P4PASSWD =

[JVM args] -Dusername = -Dpassword =

[pom.xml] ...   

  ...

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-scm-plugin</artifactId>
    <version>1.4</version>
  </plugin>

  ...

...

 <!-- SCM Settings -->
  <scm>
    <connection>scmerforce:localhost:1666://depot/someproject</connection>
    <developerConnection>scmerforce:localhost:1666://depot/someproject</developerConnection>
    <url>scmerforce://depot/simple</url>
  </scm>

...

  1. P4Maven Perforce SCM ( P4Java)

[pom.xml]

...   

  ...

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

  ...

...

  scm4: : 1666:///someproject   scm4: : 1666:///someproject   scm4:///someproject

...

  • , P4Maven "maven-scm-plugin".

  • , "scmp4" ( P4Maven) "scmperforce" ( ) , "perforce" .

+2

- Perforce, maven (, ). buildnumber-maven-plugin, Perforce . maven-release-plugin, , , , , .

, , . p4 ant antrun plugin ( 1.7 ant maven). p4.

${revision.number}, maven.

<!-- Get Perforce latest change number -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <dependencies>
        <dependency>
            <groupId>ant-contrib</groupId>
            <artifactId>ant-contrib</artifactId>
            <version>1.0b3</version>
        </dependency>
    </dependencies>
    <configuration>
        <exportAntProperties>true</exportAntProperties>
    </configuration>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <target>
                    <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="maven.plugin.classpath"/>
                    <!-- Login to p4 -->
                    <exec executable="p4" inputstring="${p4.password}">
                        <arg value="-p${p4.server}"/>
                        <arg value="-c${p4.client}"/>
                        <arg value="-u${p4.username}"/>
                        <arg value="login"/>
                    </exec>
                    <!-- Get reivision description text -->
                    <exec executable="p4" outputproperty="revision.description">
                        <arg value="-p${p4.server}"/>
                        <arg value="-c${p4.client}"/>
                        <arg value="-u${p4.username}"/>
                        <arg value="changes"/>
                        <arg value="-m1"/>
                        <arg value="//...#have"/>
                    </exec>
                    <!-- Logout from p4 -->
                    <exec executable="p4">
                        <arg value="-p${p4.server}"/>
                        <arg value="-c${p4.client}"/>
                        <arg value="-u${p4.username}"/>
                        <arg value="logout"/>
                    </exec>

                    <!-- Parse revision description to retrieve only revision number -->
                    <propertyregex property="revision.number"
                                   input="${revision.description}"
                                   regexp="Change ([0-9]*) on ([a-z,0-9]*)"
                                   select="\1"
                                   casesensitive="false"/>

                    <echo>Perforce latest revision number: ${revision.number}</echo>
                </target>
            </configuration>
        </execution>
    </executions>
</plugin>
+1

, , p4maven , .

README.md. , . 1.0.6 - maven central.

Maven.

0

I landed here looking for a solution to the similar "NO Configuration can be defined" problem I encountered with the Code Collaborator client with P4. I ended up uninstalling the P4 client and reinstalling it to make it work.

0
source

All Articles