Maven tips and Tricks: Perforce (round 2)

In relation to my last post about maven and Perforce
this is a better solution that will work with both maven 1.0.x and 1.1.
The previous one doesn’t work under maven 1.1 because the bundled ant
version was updated to 1.6, that doesn’t include the optional perforce

This time you’d need:

  • oro and ant-apache-oro as a dependency in your project.xml.
            <!-- you don't need the root classloader if
                 only running under maven 1.1 -->
  • The actual goal in maven.xml
        <!-- perforce -->
        <goal name="p4sync">
                 you need Perforce command line client and maybe specify
                 P4CLIENT and P4PASSWD environment variables
            <ant:taskdef name="p4sync"
            <p4sync view="//depot/whatever/..." />

Another option to avoid defining each one of the tasks is creating a properties file in the classpath and load it with

        <ant:taskdef resource="com.whatever.PerforceTasks"

And the contents of the properties file is

        # Perforce tasks available

Note that you can’t use the properties file bundled with ant because it includes all optional tasks, wich would force you to include all ant-*.jar files in the classpath.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s