Custom SCM Provider

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Custom SCM Provider

Robert Egan

Greetings

It's been a few weeks, but I've finally gotten around to working on my custom provider. I am trying to get the absolute minimum framework written, after which I will have a contractor do the heavy lifting. I though it might be good to write just enough code to connect to the repository, but thought I'd make the "discovery" process work first, so here's what Ive got. I know it isn't much but until the discovery portion works, the rest of the code can't really be tested.

The provider
=================
package com.ph.buildtools.scm.provider;

// imports removed for brevity

/**
 * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="aci"
 **/

public class CustomScmProvider extends AbstractScmProvider {

    public ScmProviderRepository makeProviderScmRepository(String url, char delimiter)
        throws ScmRepositoryException {

        return new CustomScmProviderRepository();
    }

    public String getScmType() {
        return "aci";
    }
}

The repository
============

package com.ph.buildtools.scm.repository;

// imports removed for brevity

/**
 * Contains the repository information.
 **/

public class CustomScmProviderRepository extends ScmProviderRepositoryWithHost {

    public CustomScmProviderRepository() {}
}

The POM
==============
<project>
  <description>An ACI provider for SCM using Starteam SDK</description>
  <name>scm</name>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.ph.buildtools.plugins</groupId>
  <artifactId>scm-plugin</artifactId>
  <packaging>maven-plugin</packaging>
  <parent>
    <groupId>com.ph.buildtools.pom</groupId>
    <artifactId>plugin</artifactId>
    <version>7.4.0.0</version>
  </parent>
  <scm>
    <connection>scm:aci:username:password</connection>
  </scm>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>descriptor</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven.scm</groupId>
      <artifactId>maven-scm-api</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>com.ph.buildtools.plugins</groupId>
      <artifactId>resources-plugin</artifactId>
      <version>7.4.0.0</version>
    </dependency>
  </dependencies>
</project>

And finally --> the output
====================
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'scm'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building scm
[INFO]    task-segment: [scm:validate] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] Preparing scm:validate
[INFO] No goals needed for project - skipping
[INFO] [scm:validate]
[ERROR] Validation of scm url connection (connectionUrl) failed :
[ERROR] No such provider installed 'aci'.
[ERROR] The invalid scm url connection: 'scm:aci:username:password'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Command failed. Bad Scm URL.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Fri Oct 19 21:44:25 EDT 2007
[INFO] Final Memory: 7M/30M
[INFO] ------------------------------------------------------------------------

Thanks
Robert Egan

This email message and any attachments may contain confidential, proprietary or non-public information.  The information is intended solely for the designated recipient(s).  If an addressing or transmission error has misdirected this email, please notify the sender immediately and destroy this email.  Any review, dissemination, use or reliance upon this information by unintended recipients is prohibited.  Any opinions expressed in this email are those of the author personally.
Reply | Threaded
Open this post in threaded view
|

Re: Custom SCM Provider

Dennis Lundberg-2
I had a look at the scm source and found the error message that you got.
IIUC you need to call

   DefaultScmManager.setScmProvider( String providerType, ScmProvider
provider )

somewhere in your code. That would register "aci" as a valid ScmProvider
in the ScmManager. I'm not sure where to so this though...


[hidden email] wrote:

>
> Greetings
>
> It's been a few weeks, but I've finally gotten around to working on my
> custom provider. I am trying to get the absolute minimum framework
> written, after which I will have a contractor do the heavy lifting. I
> though it might be good to write just enough code to connect to the
> repository, but thought I'd make the "discovery" process work first, so
> here's what Ive got. I know it isn't much but until the discovery
> portion works, the rest of the code can't really be tested.
>
> The provider
> =================
> package com.ph.buildtools.scm.provider;
>
> // imports removed for brevity
>
> /**
>  * @plexus.component role="org.apache.maven.scm.provider.ScmProvider"
> role-hint="aci"
>  **/
>
> public class CustomScmProvider extends AbstractScmProvider {
>
>     public ScmProviderRepository makeProviderScmRepository(String url,
> char delimiter)
>         throws ScmRepositoryException {
>
>         return new CustomScmProviderRepository();
>     }
>
>     public String getScmType() {
>         return "aci";
>     }
> }
>
> The repository
> ============
>
> package com.ph.buildtools.scm.repository;
>
> // imports removed for brevity
>
> /**
>  * Contains the repository information.
>  **/
>
> public class CustomScmProviderRepository extends
> ScmProviderRepositoryWithHost {
>
>     public CustomScmProviderRepository() {}
> }
>
> The POM
> ==============
> <project>
>   <description>An ACI provider for SCM using Starteam SDK</description>
>   <name>scm</name>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.ph.buildtools.plugins</groupId>
>   <artifactId>scm-plugin</artifactId>
>   <packaging>maven-plugin</packaging>
>   <parent>
>     <groupId>com.ph.buildtools.pom</groupId>
>     <artifactId>plugin</artifactId>
>     <version>7.4.0.0</version>
>   </parent>
>   <scm>
>     <connection>scm:aci:username:password</connection>
>   </scm>
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>org.codehaus.plexus</groupId>
>         <artifactId>plexus-maven-plugin</artifactId>
>         <executions>
>           <execution>
>             <goals>
>               <goal>descriptor</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
>   <dependencies>
>     <dependency>
>       <groupId>org.apache.maven.scm</groupId>
>       <artifactId>maven-scm-api</artifactId>
>       <version>1.0</version>
>     </dependency>
>     <dependency>
>       <groupId>com.ph.buildtools.plugins</groupId>
>       <artifactId>resources-plugin</artifactId>
>       <version>7.4.0.0</version>
>     </dependency>
>   </dependencies>
> </project>
>
> And finally --> the output
> ====================
> [INFO] Scanning for projects...
> [INFO] Searching repository for plugin with prefix: 'scm'.
> [INFO]
> ----------------------------------------------------------------------------
>
> [INFO] Building scm
> [INFO]    task-segment: [scm:validate] (aggregator-style)
> [INFO]
> ----------------------------------------------------------------------------
>
> [INFO] Preparing scm:validate
> [INFO] No goals needed for project - skipping
> [INFO] [scm:validate]
> [ERROR] Validation of scm url connection (connectionUrl) failed :
> [ERROR] No such provider installed 'aci'.
> [ERROR] The invalid scm url connection: 'scm:aci:username:password'.
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Command failed. Bad Scm URL.
> [INFO]
> ------------------------------------------------------------------------
> [INFO] For more information, run Maven with the -e switch
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 6 seconds
> [INFO] Finished at: Fri Oct 19 21:44:25 EDT 2007
> [INFO] Final Memory: 7M/30M
> [INFO]
> ------------------------------------------------------------------------
>
> Thanks
> Robert Egan
>
> This email message and any attachments may contain confidential,
> proprietary or non-public information.  The information is intended
> solely for the designated recipient(s).  If an addressing or
> transmission error has misdirected this email, please notify the sender
> immediately and destroy this email.  Any review, dissemination, use or
> reliance upon this information by unintended recipients is prohibited.
>  Any opinions expressed in this email are those of the author personally.


--
Dennis Lundberg
Reply | Threaded
Open this post in threaded view
|

Re: Custom SCM Provider

Robert Egan

That makes sense. But a few weeks back when I asked the same question. I was told that it could be dynamically discoved.

http://www.nabble.com/scm-plugin-providers-tf4533338s177.html

So I am attempting to follow those steps, under the assumption that plexus would somehow take care of it for me. But I sem to have missed one or intermediate steps along the way.

Robert Egan

Dennis Lundberg <[hidden email]> wrote on 10/20/2007 09:20:20 AM:

> I had a look at the scm source and found the error message that you got.
> IIUC you need to call
>
>    DefaultScmManager.setScmProvider( String providerType, ScmProvider
> provider )
>
> somewhere in your code. That would register "aci" as a valid ScmProvider
> in the ScmManager. I'm not sure where to so this though...
>
> Dennis Lundberg

This email message and any attachments may contain confidential, proprietary or non-public information.  The information is intended solely for the designated recipient(s).  If an addressing or transmission error has misdirected this email, please notify the sender immediately and destroy this email.  Any review, dissemination, use or reliance upon this information by unintended recipients is prohibited.  Any opinions expressed in this email are those of the author personally.
Reply | Threaded
Open this post in threaded view
|

Re: Custom SCM Provider

Dennis Lundberg-2
Oh, I see. I'm sure Emmanuel is correct. It might have something to do
with naming conventions then. Just guessing here, but your
implementation classes all start with Custom but they implement an "aci"
provider.

[hidden email] wrote:

>
> That makes sense. But a few weeks back when I asked the same question. I
> was told that it could be dynamically discoved.
>
> http://www.nabble.com/scm-plugin-providers-tf4533338s177.html
>
> So I am attempting to follow those steps, under the assumption that
> plexus would somehow take care of it for me. But I sem to have missed
> one or intermediate steps along the way.
>
> Robert Egan
>
> Dennis Lundberg <[hidden email]> wrote on 10/20/2007 09:20:20 AM:
>
>  > I had a look at the scm source and found the error message that you got.
>  > IIUC you need to call
>  >
>  >    DefaultScmManager.setScmProvider( String providerType, ScmProvider
>  > provider )
>  >
>  > somewhere in your code. That would register "aci" as a valid ScmProvider
>  > in the ScmManager. I'm not sure where to so this though...
>  >
>  > Dennis Lundberg
>
> This email message and any attachments may contain confidential,
> proprietary or non-public information.  The information is intended
> solely for the designated recipient(s).  If an addressing or
> transmission error has misdirected this email, please notify the sender
> immediately and destroy this email.  Any review, dissemination, use or
> reliance upon this information by unintended recipients is prohibited.
>  Any opinions expressed in this email are those of the author personally.


--
Dennis Lundberg
Reply | Threaded
Open this post in threaded view
|

Re: Custom SCM Provider

Robert Egan

All it did was change the error to:

[INFO] [scm:validate]
[ERROR] Validation of scm url connection (connectionUrl) failed :
[ERROR] No such provider installed 'custom'.

Perhaps we'd best wait for Emmanual to look at the original request. Until then, I've trimmed the rest and proceeded onward. Once this works I should be able to get a server connection with the code I've added this morning.

Thanks for the suggestions, though.


Robert Egan

Dennis Lundberg <[hidden email]> wrote on 10/20/2007 10:16:02 AM:

> Oh, I see. I'm sure Emmanuel is correct. It might have something to do
> with naming conventions then. Just guessing here, but your
> implementation classes all start with Custom but they implement an "aci"
> provider.
>
> Dennis Lundberg

This email message and any attachments may contain confidential, proprietary or non-public information.  The information is intended solely for the designated recipient(s).  If an addressing or transmission error has misdirected this email, please notify the sender immediately and destroy this email.  Any review, dissemination, use or reliance upon this information by unintended recipients is prohibited.  Any opinions expressed in this email are those of the author personally.
Reply | Threaded
Open this post in threaded view
|

RE: Custom SCM Provider

Genschaw, Shane
Robert,
 
Try adding this to your POM:
 
<build>
  [...]
  <plugins>
    [...]
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-scm-plugin</artifactId>
      <version>1.0</version>
      <dependencies>
        <dependency>
          <groupId>com.ph.buildtools.plugins</groupId>
          <artifactId>scm-plugin</artifactId>
          <version>7.4.0.0</version>
        </dependency>
      </dependencies>
    </plugin>
    [...]
  </plugins>
  [...]
</build>
 
Also, you'll want to change your "packaging" to be "jar" instead of "maven-plugin".  You are not actually creating a new plugin, you are creating a new provider jar for the existing scm plugin to use.  A related suggestion would be to change your artifact id to something like "scm-provider-aci-custom".
 
I have created a custom provider for Serena PVCS/Changeman (my company's SCM tool) and the "discovery" works just fine as long as you add the dependency config for the scm plugin as shown above.  You'll also have to similarly configure other plugins that rely on your provider (maven-release-plugin, maven-changelog-plugin, etc.) if you use them.
 
I didn't add "DefaultScmManager.setScmProvider( String providerType, ScmProvider provider )" anywhere in the code.
 
- Shane Genschaw


From: [hidden email] [mailto:[hidden email]]
Sent: Saturday, October 20, 2007 9:42 AM
To: [hidden email]
Subject: Re: Custom SCM Provider


All it did was change the error to:

[INFO] [scm:validate]
[ERROR] Validation of scm url connection (connectionUrl) failed :
[ERROR] No such provider installed 'custom'.

Perhaps we'd best wait for Emmanual to look at the original request. Until then, I've trimmed the rest and proceeded onward. Once this works I should be able to get a server connection with the code I've added this morning.

Thanks for the suggestions, though.


Robert Egan

Dennis Lundberg <[hidden email]> wrote on 10/20/2007 10:16:02 AM:

> Oh, I see. I'm sure Emmanuel is correct. It might have something to do
> with naming conventions then. Just guessing here, but your
> implementation classes all start with Custom but they implement an "aci"
> provider.
>
> Dennis Lundberg

This email message and any attachments may contain confidential, proprietary or non-public information.  The information is intended solely for the designated recipient(s).  If an addressing or transmission error has misdirected this email, please notify the sender immediately and destroy this email.  Any review, dissemination, use or reliance upon this information by unintended recipients is prohibited.  Any opinions expressed in this email are those of the author personally.
Reply | Threaded
Open this post in threaded view
|

RE: Custom SCM Provider - Works!

Robert Egan

Thanks, those were the missing steps!

Question for the SCM group in general, how can I add this to the web site before it gets forgotten? I have a JIRA account, although I've never actually submitted any code or docs.


Robert Egan

"Genschaw, Shane" <[hidden email]> wrote on 10/22/2007 11:54:32 AM:

> Robert,

>  
> Try adding this to your POM:
>  
> <build>
>   [...]
>   <plugins>
>     [...]
>     <plugin>
>       <groupId>org.apache.maven.plugins</groupId>
>       <artifactId>maven-scm-plugin</artifactId>
>       <version>1.0</version>
>       <dependencies>
>         <dependency>
>           <groupId>com.ph.buildtools.plugins</groupId>
>           <artifactId>scm-plugin</artifactId>
>           <version>7.4.0.0</version>
>         </dependency>
>       </dependencies>
>     </plugin>
>     [...]
>   </plugins>
>   [...]
> </build>
>  
> Also, you'll want to change your "packaging" to be "jar" instead of "
> maven-plugin".  You are not actually creating a new plugin, you are
> creating a new provider jar for the existing scm plugin to use.  A
> related suggestion would be to change your artifact id to something like "
> scm-provider-aci-custom".

>  
> I have created a custom provider for Serena PVCS/Changeman (my
> company's SCM tool) and the "discovery" works just fine as long as
> you add the dependency config for the scm plugin as shown above.  
> You'll also have to similarly configure other plugins that rely on
> your provider (maven-release-plugin, maven-changelog-plugin, etc.)
> if you use them.

>  
> I didn't add "DefaultScmManager.setScmProvider( String providerType,
> ScmProvider provider )" anywhere in the code.

>  
> - Shane Genschaw

This email message and any attachments may contain confidential, proprietary or non-public information.  The information is intended solely for the designated recipient(s).  If an addressing or transmission error has misdirected this email, please notify the sender immediately and destroy this email.  Any review, dissemination, use or reliance upon this information by unintended recipients is prohibited.  Any opinions expressed in this email are those of the author personally.
Reply | Threaded
Open this post in threaded view
|

Re: Custom SCM Provider - Works!

Emmanuel Venisse-2
checkout the maven-scm site (http://svn.apache.org/repos/asf/maven/scm/trunk/maven-scm-site/), create a patch and attach it to a jira issue.

Emmanuel

[hidden email] a écrit :

>
> Thanks, those were the missing steps!
>
> Question for the SCM group in general, how can I add this to the web
> site before it gets forgotten? I have a JIRA account, although I've
> never actually submitted any code or docs.
>
>
> Robert Egan
>
> "Genschaw, Shane" <[hidden email]> wrote on 10/22/2007 11:54:32 AM:
>
>  > Robert,
>  >  
>  > Try adding this to your POM:
>  >  
>  > <build>
>  >   [...]
>  >   <plugins>
>  >     [...]
>  >     <plugin>
>  >       <groupId>org.apache.maven.plugins</groupId>
>  >       <artifactId>maven-scm-plugin</artifactId>
>  >       <version>1.0</version>
>  >       <dependencies>
>  >         <dependency>
>  >           <groupId>com.ph.buildtools.plugins</groupId>
>  >           <artifactId>scm-plugin</artifactId>
>  >           <version>7.4.0.0</version>
>  >         </dependency>
>  >       </dependencies>
>  >     </plugin>
>  >     [...]
>  >   </plugins>
>  >   [...]
>  > </build>
>  >  
>  > Also, you'll want to change your "packaging" to be "jar" instead of "
>  > maven-plugin".  You are not actually creating a new plugin, you are
>  > creating a new provider jar for the existing scm plugin to use.  A
>  > related suggestion would be to change your artifact id to something
> like "
>  > scm-provider-aci-custom".
>  >  
>  > I have created a custom provider for Serena PVCS/Changeman (my
>  > company's SCM tool) and the "discovery" works just fine as long as
>  > you add the dependency config for the scm plugin as shown above.  
>  > You'll also have to similarly configure other plugins that rely on
>  > your provider (maven-release-plugin, maven-changelog-plugin, etc.)
>  > if you use them.
>  >  
>  > I didn't add "DefaultScmManager.setScmProvider( String providerType,
>  > ScmProvider provider )" anywhere in the code.
>  >  
>  > - Shane Genschaw
>
> This email message and any attachments may contain confidential,
> proprietary or non-public information.  The information is intended
> solely for the designated recipient(s).  If an addressing or
> transmission error has misdirected this email, please notify the sender
> immediately and destroy this email.  Any review, dissemination, use or
> reliance upon this information by unintended recipients is prohibited.
>  Any opinions expressed in this email are those of the author personally.