You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Nord, James" <JN...@nds.com> on 2009/01/08 19:42:12 UTC

Maven SCM - SVN provider

Hi all,
 
I've been trying to write an enforcer plugin that will validate the SCM
information contained in a POM actually reflects the actual repository
location.  I'm only concerned with SVN.
 
Basically I am trying to do is a "svn info project.getBaseDir()" and
compare the repository url that comes back with the one defined in the
SCM tag.
 
I've been failing misserably as using I can not construct a
SCMProviderRepository with the File argument. even though the svn
provider supports getting the url from a file location[1] it just ends
up throwing a null pointer exception[2].
 
I have managed to get the following code to work - but it doesn't work
out where the repo is from the .svn files.  How can I adapt it to do so
it will work with the local file location not the remote location- I'm
tearing my hair out!
 

	String devSCM = project.getScm().getDeveloperConnection();
	String devSVN = devSCM.replaceFirst("scm:svn:", "");
	ScmRepository scmRepo = scmManger.makeScmRepository(devSCM);
	log.warn("Using " + base + " as the base directory");
	ScmProvider provider = scmManger.getProviderByUrl(devSCM); 
	if (provider instanceof AbstractSvnScmProvider) {
	     AbstractSvnScmProvider svnProvider =
(AbstractSvnScmProvider)provider;
	    // following returns null and a n.p.e is later thrown by
AbstractCommand.execute(AbstractCommand.java:49)
	    //ScmProviderRepository providerRepo =
svnProvider.makeProviderScmRepository(project.getBaseDir());
	     ScmProviderRepository providerRepo =
svnProvider.makeProviderScmRepository(devSVN, '\u0000');
	     ScmFileSet fileSet = new ScmFileSet(project.getBasedir(),
"pom.xml");
	    SvnInfoScmResult infoResult = svnProvider.info(providerRepo,
fileSet, null);
	    if (infoResult.isSuccess()) {
	        ....
	    }
	}

 

[1]
http://maven.apache.org/scm/xref/org/apache/maven/scm/provider/svn/Abstr
actSvnScmProvider.html#110

Regards,

    /James


Re: Maven SCM - SVN provider

Posted by Dan Tran <da...@gmail.com>.
On Fri, Jan 9, 2009 at 5:28 AM, Nord, James <JN...@nds.com> wrote:
> It seems like a bug in SvnScmProviderRepository.parseURL()
>
> On windows the url passed in is a file url file://X:/path/to/directory
> The protocol is set to file:// and then url gets translated into
> protocol + urlpath which results in the original
> file://X:/path/to/directory which the svn command line does not like.
>
> [INFO] Executing: cmd.exe /X /C "svn --non-interactive info
> file://X:/path/to/directory/pom.xml"
> WARNING] SCM Info failed:[output] svn: Unable to open an ra_local
> session to URL
> svn: Unable to open repository...

your url points to a local svn copy, and svn is looking for a server copy

and it barbs
>
> I think if the path protocol is file:// then the provider should not
> re-add it onto the url?

what do you mean?
>
> What do you think - if it did this I think we should be able to work
> from local paths?
>

I think to only way to get it work with local path is changing the svn
provider, please a jira, and open a discussion with maven dev, if
approves the change is minimal
I think by switching to local copy has no impact the output of
SvnInfoCommand, so it is ok to request for this change

> (svn, version 1.4.4 (r25188) CollabNet.)
>
> /James
>
>> -----Original Message-----
>> From: Dan Tran [mailto:dantran@gmail.com]
>> Sent: 09 January 2009 11:31
>> To: Maven Developers List
>> Subject: Re: Maven SCM - SVN provider
>>
>> You are right, and i am not really understand the rational
>> behind why the command works directory with remote url rather
>> local file.
>>
>> so you may need to go ehead with your own implemtation.
>>
>> I also filed SCM-433 to allow me at least run "svn info" on a
>> local directory, so that i can get rid of buildnumber
>> plugin's SvnInfoCommand implementation
>>
>> -Dan
>>
>> On Fri, Jan 9, 2009 at 3:17 AM, Nord, James <JN...@nds.com> wrote:
>> > The SVN provider does support the info command - it just
>> seems to only
>> > work on remote repository URLs as the maven scm rejects the
>> local path
>> > as a repo even though the code inside the svn provider can
>> deal with it.
>> >
>> > The Build-number still sufferes the same issues as it needs an
>> > ScmRepository which scm thinks is invalid.
>> >
>> > Although the code to parse the scm output doen't look to bad - it
>> > would appear I need to use this and forget about using the
>> scm /svn provider?
>> >
>> > /James
>> >
>> >> -----Original Message-----
>> >> From: Dan Tran [mailto:dantran@gmail.com]
>> >> Sent: 08 January 2009 19:16
>> >> To: Maven Developers List
>> >> Subject: Re: Maven SCM - SVN provider
>> >>
>> >> sorry, it should be buildnumber-maven-plugin
>> >>
>> >> On Thu, Jan 8, 2009 at 10:51 AM, Dan Tran
>> <da...@gmail.com> wrote:
>> >> > take a look at buildhelper-maven-plugin, it has code
>> >> dealing with svn
>> >> > info output
>> >> >
>> >> > BTW, perhaps we should ask svn provider to support svn
>> info command.
>> >> > file a JIRA is a good start
>> >> >
>> >> > -D
>> >> >
>> >> > On Thu, Jan 8, 2009 at 10:42 AM, Nord, James
>> <JN...@nds.com> wrote:
>> >> >> Hi all,
>> >> >>
>> >> >> I've been trying to write an enforcer plugin that will
>> >> validate the
>> >> >> SCM information contained in a POM actually reflects the actual
>> >> >> repository location.  I'm only concerned with SVN.
>> >> >>
>> >> >> Basically I am trying to do is a "svn info
>> >> project.getBaseDir()" and
>> >> >> compare the repository url that comes back with the one
>> defined in
>> >> >> the SCM tag.
>> >> >>
>> >> >> I've been failing misserably as using I can not construct a
>> >> >> SCMProviderRepository with the File argument. even
>> though the svn
>> >> >> provider supports getting the url from a file
>> location[1] it just
>> >> >> ends up throwing a null pointer exception[2].
>> >> >>
>> >> >> I have managed to get the following code to work - but
>> it doesn't
>> >> >> work out where the repo is from the .svn files.  How can I
>> >> adapt it
>> >> >> to do so it will work with the local file location not
>> the remote
>> >> >> location- I'm tearing my hair out!
>> >> >>
>> >> >>
>> >> >>        String devSCM =
>> project.getScm().getDeveloperConnection();
>> >> >>        String devSVN = devSCM.replaceFirst("scm:svn:", "");
>> >> >>        ScmRepository scmRepo =
>> scmManger.makeScmRepository(devSCM);
>> >> >>        log.warn("Using " + base + " as the base directory");
>> >> >>        ScmProvider provider =
>> scmManger.getProviderByUrl(devSCM);
>> >> >>        if (provider instanceof AbstractSvnScmProvider) {
>> >> >>             AbstractSvnScmProvider svnProvider =
>> >> >> (AbstractSvnScmProvider)provider;
>> >> >>            // following returns null and a n.p.e is
>> later thrown
>> >> >> by
>> >> >> AbstractCommand.execute(AbstractCommand.java:49)
>> >> >>            //ScmProviderRepository providerRepo =
>> >> >> svnProvider.makeProviderScmRepository(project.getBaseDir());
>> >> >>             ScmProviderRepository providerRepo =
>> >> >> svnProvider.makeProviderScmRepository(devSVN, '\u0000');
>> >> >>             ScmFileSet fileSet = new
>> >> ScmFileSet(project.getBasedir(),
>> >> >> "pom.xml");
>> >> >>            SvnInfoScmResult infoResult =
>> >> >> svnProvider.info(providerRepo, fileSet, null);
>> >> >>            if (infoResult.isSuccess()) {
>> >> >>                ....
>> >> >>            }
>> >> >>        }
>> >> >>
>> >> >>
>> >> >>
>> >> >> [1]
>> >> >>
>> >>
>> http://maven.apache.org/scm/xref/org/apache/maven/scm/provider/svn/Ab
>> >> >> str
>> >> >> actSvnScmProvider.html#110
>> >> >>
>> >> >> Regards,
>> >> >>
>> >> >>    /James
>> >> >>
>> >> >>
>> >> >
>> >>
>> >>
>> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For
>> >> additional commands, e-mail: dev-help@maven.apache.org
>> >>
>> >>
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For
>> > additional commands, e-mail: dev-help@maven.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For
>> additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: Maven SCM - SVN provider

Posted by "Nord, James" <JN...@nds.com>.
It seems like a bug in SvnScmProviderRepository.parseURL()

On windows the url passed in is a file url file://X:/path/to/directory
The protocol is set to file:// and then url gets translated into
protocol + urlpath which results in the original
file://X:/path/to/directory which the svn command line does not like.

[INFO] Executing: cmd.exe /X /C "svn --non-interactive info
file://X:/path/to/directory/pom.xml"
WARNING] SCM Info failed:[output] svn: Unable to open an ra_local
session to URL
svn: Unable to open repository...

I think if the path protocol is file:// then the provider should not
re-add it onto the url?

What do you think - if it did this I think we should be able to work
from local paths?

(svn, version 1.4.4 (r25188) CollabNet.)

/James

> -----Original Message-----
> From: Dan Tran [mailto:dantran@gmail.com] 
> Sent: 09 January 2009 11:31
> To: Maven Developers List
> Subject: Re: Maven SCM - SVN provider
> 
> You are right, and i am not really understand the rational 
> behind why the command works directory with remote url rather 
> local file.
> 
> so you may need to go ehead with your own implemtation.
> 
> I also filed SCM-433 to allow me at least run "svn info" on a 
> local directory, so that i can get rid of buildnumber 
> plugin's SvnInfoCommand implementation
> 
> -Dan
> 
> On Fri, Jan 9, 2009 at 3:17 AM, Nord, James <JN...@nds.com> wrote:
> > The SVN provider does support the info command - it just 
> seems to only 
> > work on remote repository URLs as the maven scm rejects the 
> local path 
> > as a repo even though the code inside the svn provider can 
> deal with it.
> >
> > The Build-number still sufferes the same issues as it needs an 
> > ScmRepository which scm thinks is invalid.
> >
> > Although the code to parse the scm output doen't look to bad - it 
> > would appear I need to use this and forget about using the 
> scm /svn provider?
> >
> > /James
> >
> >> -----Original Message-----
> >> From: Dan Tran [mailto:dantran@gmail.com]
> >> Sent: 08 January 2009 19:16
> >> To: Maven Developers List
> >> Subject: Re: Maven SCM - SVN provider
> >>
> >> sorry, it should be buildnumber-maven-plugin
> >>
> >> On Thu, Jan 8, 2009 at 10:51 AM, Dan Tran 
> <da...@gmail.com> wrote:
> >> > take a look at buildhelper-maven-plugin, it has code
> >> dealing with svn
> >> > info output
> >> >
> >> > BTW, perhaps we should ask svn provider to support svn 
> info command.
> >> > file a JIRA is a good start
> >> >
> >> > -D
> >> >
> >> > On Thu, Jan 8, 2009 at 10:42 AM, Nord, James 
> <JN...@nds.com> wrote:
> >> >> Hi all,
> >> >>
> >> >> I've been trying to write an enforcer plugin that will
> >> validate the
> >> >> SCM information contained in a POM actually reflects the actual 
> >> >> repository location.  I'm only concerned with SVN.
> >> >>
> >> >> Basically I am trying to do is a "svn info
> >> project.getBaseDir()" and
> >> >> compare the repository url that comes back with the one 
> defined in 
> >> >> the SCM tag.
> >> >>
> >> >> I've been failing misserably as using I can not construct a 
> >> >> SCMProviderRepository with the File argument. even 
> though the svn 
> >> >> provider supports getting the url from a file 
> location[1] it just 
> >> >> ends up throwing a null pointer exception[2].
> >> >>
> >> >> I have managed to get the following code to work - but 
> it doesn't 
> >> >> work out where the repo is from the .svn files.  How can I
> >> adapt it
> >> >> to do so it will work with the local file location not 
> the remote
> >> >> location- I'm tearing my hair out!
> >> >>
> >> >>
> >> >>        String devSCM = 
> project.getScm().getDeveloperConnection();
> >> >>        String devSVN = devSCM.replaceFirst("scm:svn:", "");
> >> >>        ScmRepository scmRepo = 
> scmManger.makeScmRepository(devSCM);
> >> >>        log.warn("Using " + base + " as the base directory");
> >> >>        ScmProvider provider = 
> scmManger.getProviderByUrl(devSCM);
> >> >>        if (provider instanceof AbstractSvnScmProvider) {
> >> >>             AbstractSvnScmProvider svnProvider = 
> >> >> (AbstractSvnScmProvider)provider;
> >> >>            // following returns null and a n.p.e is 
> later thrown 
> >> >> by
> >> >> AbstractCommand.execute(AbstractCommand.java:49)
> >> >>            //ScmProviderRepository providerRepo = 
> >> >> svnProvider.makeProviderScmRepository(project.getBaseDir());
> >> >>             ScmProviderRepository providerRepo = 
> >> >> svnProvider.makeProviderScmRepository(devSVN, '\u0000');
> >> >>             ScmFileSet fileSet = new
> >> ScmFileSet(project.getBasedir(),
> >> >> "pom.xml");
> >> >>            SvnInfoScmResult infoResult = 
> >> >> svnProvider.info(providerRepo, fileSet, null);
> >> >>            if (infoResult.isSuccess()) {
> >> >>                ....
> >> >>            }
> >> >>        }
> >> >>
> >> >>
> >> >>
> >> >> [1]
> >> >>
> >> 
> http://maven.apache.org/scm/xref/org/apache/maven/scm/provider/svn/Ab
> >> >> str
> >> >> actSvnScmProvider.html#110
> >> >>
> >> >> Regards,
> >> >>
> >> >>    /James
> >> >>
> >> >>
> >> >
> >>
> >> 
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For 
> >> additional commands, e-mail: dev-help@maven.apache.org
> >>
> >>
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For 
> > additional commands, e-mail: dev-help@maven.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For 
> additional commands, e-mail: dev-help@maven.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Maven SCM - SVN provider

Posted by Dan Tran <da...@gmail.com>.
You are right, and i am not really understand the rational behind why
the command works directory with remote url rather local file.

so you may need to go ehead with your own implemtation.

I also filed SCM-433 to allow me at least run "svn info" on a local
directory, so that i can get rid of buildnumber plugin's
SvnInfoCommand implementation

-Dan

On Fri, Jan 9, 2009 at 3:17 AM, Nord, James <JN...@nds.com> wrote:
> The SVN provider does support the info command - it just seems to only
> work on remote repository URLs as the maven scm rejects the local path
> as a repo even though the code inside the svn provider can deal with it.
>
> The Build-number still sufferes the same issues as it needs an
> ScmRepository which scm thinks is invalid.
>
> Although the code to parse the scm output doen't look to bad - it would
> appear I need to use this and forget about using the scm /svn provider?
>
> /James
>
>> -----Original Message-----
>> From: Dan Tran [mailto:dantran@gmail.com]
>> Sent: 08 January 2009 19:16
>> To: Maven Developers List
>> Subject: Re: Maven SCM - SVN provider
>>
>> sorry, it should be buildnumber-maven-plugin
>>
>> On Thu, Jan 8, 2009 at 10:51 AM, Dan Tran <da...@gmail.com> wrote:
>> > take a look at buildhelper-maven-plugin, it has code
>> dealing with svn
>> > info output
>> >
>> > BTW, perhaps we should ask svn provider to support svn info command.
>> > file a JIRA is a good start
>> >
>> > -D
>> >
>> > On Thu, Jan 8, 2009 at 10:42 AM, Nord, James <JN...@nds.com> wrote:
>> >> Hi all,
>> >>
>> >> I've been trying to write an enforcer plugin that will
>> validate the
>> >> SCM information contained in a POM actually reflects the actual
>> >> repository location.  I'm only concerned with SVN.
>> >>
>> >> Basically I am trying to do is a "svn info
>> project.getBaseDir()" and
>> >> compare the repository url that comes back with the one defined in
>> >> the SCM tag.
>> >>
>> >> I've been failing misserably as using I can not construct a
>> >> SCMProviderRepository with the File argument. even though the svn
>> >> provider supports getting the url from a file location[1] it just
>> >> ends up throwing a null pointer exception[2].
>> >>
>> >> I have managed to get the following code to work - but it doesn't
>> >> work out where the repo is from the .svn files.  How can I
>> adapt it
>> >> to do so it will work with the local file location not the remote
>> >> location- I'm tearing my hair out!
>> >>
>> >>
>> >>        String devSCM = project.getScm().getDeveloperConnection();
>> >>        String devSVN = devSCM.replaceFirst("scm:svn:", "");
>> >>        ScmRepository scmRepo = scmManger.makeScmRepository(devSCM);
>> >>        log.warn("Using " + base + " as the base directory");
>> >>        ScmProvider provider = scmManger.getProviderByUrl(devSCM);
>> >>        if (provider instanceof AbstractSvnScmProvider) {
>> >>             AbstractSvnScmProvider svnProvider =
>> >> (AbstractSvnScmProvider)provider;
>> >>            // following returns null and a n.p.e is later thrown by
>> >> AbstractCommand.execute(AbstractCommand.java:49)
>> >>            //ScmProviderRepository providerRepo =
>> >> svnProvider.makeProviderScmRepository(project.getBaseDir());
>> >>             ScmProviderRepository providerRepo =
>> >> svnProvider.makeProviderScmRepository(devSVN, '\u0000');
>> >>             ScmFileSet fileSet = new
>> ScmFileSet(project.getBasedir(),
>> >> "pom.xml");
>> >>            SvnInfoScmResult infoResult =
>> >> svnProvider.info(providerRepo, fileSet, null);
>> >>            if (infoResult.isSuccess()) {
>> >>                ....
>> >>            }
>> >>        }
>> >>
>> >>
>> >>
>> >> [1]
>> >>
>> http://maven.apache.org/scm/xref/org/apache/maven/scm/provider/svn/Ab
>> >> str
>> >> actSvnScmProvider.html#110
>> >>
>> >> Regards,
>> >>
>> >>    /James
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For
>> additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: Maven SCM - SVN provider

Posted by "Nord, James" <JN...@nds.com>.
The SVN provider does support the info command - it just seems to only
work on remote repository URLs as the maven scm rejects the local path
as a repo even though the code inside the svn provider can deal with it.

The Build-number still sufferes the same issues as it needs an
ScmRepository which scm thinks is invalid.

Although the code to parse the scm output doen't look to bad - it would
appear I need to use this and forget about using the scm /svn provider?

/James

> -----Original Message-----
> From: Dan Tran [mailto:dantran@gmail.com] 
> Sent: 08 January 2009 19:16
> To: Maven Developers List
> Subject: Re: Maven SCM - SVN provider
> 
> sorry, it should be buildnumber-maven-plugin
> 
> On Thu, Jan 8, 2009 at 10:51 AM, Dan Tran <da...@gmail.com> wrote:
> > take a look at buildhelper-maven-plugin, it has code 
> dealing with svn 
> > info output
> >
> > BTW, perhaps we should ask svn provider to support svn info command.
> > file a JIRA is a good start
> >
> > -D
> >
> > On Thu, Jan 8, 2009 at 10:42 AM, Nord, James <JN...@nds.com> wrote:
> >> Hi all,
> >>
> >> I've been trying to write an enforcer plugin that will 
> validate the 
> >> SCM information contained in a POM actually reflects the actual 
> >> repository location.  I'm only concerned with SVN.
> >>
> >> Basically I am trying to do is a "svn info 
> project.getBaseDir()" and 
> >> compare the repository url that comes back with the one defined in 
> >> the SCM tag.
> >>
> >> I've been failing misserably as using I can not construct a 
> >> SCMProviderRepository with the File argument. even though the svn 
> >> provider supports getting the url from a file location[1] it just 
> >> ends up throwing a null pointer exception[2].
> >>
> >> I have managed to get the following code to work - but it doesn't 
> >> work out where the repo is from the .svn files.  How can I 
> adapt it 
> >> to do so it will work with the local file location not the remote 
> >> location- I'm tearing my hair out!
> >>
> >>
> >>        String devSCM = project.getScm().getDeveloperConnection();
> >>        String devSVN = devSCM.replaceFirst("scm:svn:", "");
> >>        ScmRepository scmRepo = scmManger.makeScmRepository(devSCM);
> >>        log.warn("Using " + base + " as the base directory");
> >>        ScmProvider provider = scmManger.getProviderByUrl(devSCM);
> >>        if (provider instanceof AbstractSvnScmProvider) {
> >>             AbstractSvnScmProvider svnProvider = 
> >> (AbstractSvnScmProvider)provider;
> >>            // following returns null and a n.p.e is later thrown by
> >> AbstractCommand.execute(AbstractCommand.java:49)
> >>            //ScmProviderRepository providerRepo = 
> >> svnProvider.makeProviderScmRepository(project.getBaseDir());
> >>             ScmProviderRepository providerRepo = 
> >> svnProvider.makeProviderScmRepository(devSVN, '\u0000');
> >>             ScmFileSet fileSet = new 
> ScmFileSet(project.getBasedir(), 
> >> "pom.xml");
> >>            SvnInfoScmResult infoResult = 
> >> svnProvider.info(providerRepo, fileSet, null);
> >>            if (infoResult.isSuccess()) {
> >>                ....
> >>            }
> >>        }
> >>
> >>
> >>
> >> [1]
> >> 
> http://maven.apache.org/scm/xref/org/apache/maven/scm/provider/svn/Ab
> >> str
> >> actSvnScmProvider.html#110
> >>
> >> Regards,
> >>
> >>    /James
> >>
> >>
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For 
> additional commands, e-mail: dev-help@maven.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Maven SCM - SVN provider

Posted by Dan Tran <da...@gmail.com>.
sorry, it should be buildnumber-maven-plugin

On Thu, Jan 8, 2009 at 10:51 AM, Dan Tran <da...@gmail.com> wrote:
> take a look at buildhelper-maven-plugin, it has code dealing with svn
> info output
>
> BTW, perhaps we should ask svn provider to support svn info command.
> file a JIRA is a good start
>
> -D
>
> On Thu, Jan 8, 2009 at 10:42 AM, Nord, James <JN...@nds.com> wrote:
>> Hi all,
>>
>> I've been trying to write an enforcer plugin that will validate the SCM
>> information contained in a POM actually reflects the actual repository
>> location.  I'm only concerned with SVN.
>>
>> Basically I am trying to do is a "svn info project.getBaseDir()" and
>> compare the repository url that comes back with the one defined in the
>> SCM tag.
>>
>> I've been failing misserably as using I can not construct a
>> SCMProviderRepository with the File argument. even though the svn
>> provider supports getting the url from a file location[1] it just ends
>> up throwing a null pointer exception[2].
>>
>> I have managed to get the following code to work - but it doesn't work
>> out where the repo is from the .svn files.  How can I adapt it to do so
>> it will work with the local file location not the remote location- I'm
>> tearing my hair out!
>>
>>
>>        String devSCM = project.getScm().getDeveloperConnection();
>>        String devSVN = devSCM.replaceFirst("scm:svn:", "");
>>        ScmRepository scmRepo = scmManger.makeScmRepository(devSCM);
>>        log.warn("Using " + base + " as the base directory");
>>        ScmProvider provider = scmManger.getProviderByUrl(devSCM);
>>        if (provider instanceof AbstractSvnScmProvider) {
>>             AbstractSvnScmProvider svnProvider =
>> (AbstractSvnScmProvider)provider;
>>            // following returns null and a n.p.e is later thrown by
>> AbstractCommand.execute(AbstractCommand.java:49)
>>            //ScmProviderRepository providerRepo =
>> svnProvider.makeProviderScmRepository(project.getBaseDir());
>>             ScmProviderRepository providerRepo =
>> svnProvider.makeProviderScmRepository(devSVN, '\u0000');
>>             ScmFileSet fileSet = new ScmFileSet(project.getBasedir(),
>> "pom.xml");
>>            SvnInfoScmResult infoResult = svnProvider.info(providerRepo,
>> fileSet, null);
>>            if (infoResult.isSuccess()) {
>>                ....
>>            }
>>        }
>>
>>
>>
>> [1]
>> http://maven.apache.org/scm/xref/org/apache/maven/scm/provider/svn/Abstr
>> actSvnScmProvider.html#110
>>
>> Regards,
>>
>>    /James
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Maven SCM - SVN provider

Posted by Dan Tran <da...@gmail.com>.
take a look at buildhelper-maven-plugin, it has code dealing with svn
info output

BTW, perhaps we should ask svn provider to support svn info command.
file a JIRA is a good start

-D

On Thu, Jan 8, 2009 at 10:42 AM, Nord, James <JN...@nds.com> wrote:
> Hi all,
>
> I've been trying to write an enforcer plugin that will validate the SCM
> information contained in a POM actually reflects the actual repository
> location.  I'm only concerned with SVN.
>
> Basically I am trying to do is a "svn info project.getBaseDir()" and
> compare the repository url that comes back with the one defined in the
> SCM tag.
>
> I've been failing misserably as using I can not construct a
> SCMProviderRepository with the File argument. even though the svn
> provider supports getting the url from a file location[1] it just ends
> up throwing a null pointer exception[2].
>
> I have managed to get the following code to work - but it doesn't work
> out where the repo is from the .svn files.  How can I adapt it to do so
> it will work with the local file location not the remote location- I'm
> tearing my hair out!
>
>
>        String devSCM = project.getScm().getDeveloperConnection();
>        String devSVN = devSCM.replaceFirst("scm:svn:", "");
>        ScmRepository scmRepo = scmManger.makeScmRepository(devSCM);
>        log.warn("Using " + base + " as the base directory");
>        ScmProvider provider = scmManger.getProviderByUrl(devSCM);
>        if (provider instanceof AbstractSvnScmProvider) {
>             AbstractSvnScmProvider svnProvider =
> (AbstractSvnScmProvider)provider;
>            // following returns null and a n.p.e is later thrown by
> AbstractCommand.execute(AbstractCommand.java:49)
>            //ScmProviderRepository providerRepo =
> svnProvider.makeProviderScmRepository(project.getBaseDir());
>             ScmProviderRepository providerRepo =
> svnProvider.makeProviderScmRepository(devSVN, '\u0000');
>             ScmFileSet fileSet = new ScmFileSet(project.getBasedir(),
> "pom.xml");
>            SvnInfoScmResult infoResult = svnProvider.info(providerRepo,
> fileSet, null);
>            if (infoResult.isSuccess()) {
>                ....
>            }
>        }
>
>
>
> [1]
> http://maven.apache.org/scm/xref/org/apache/maven/scm/provider/svn/Abstr
> actSvnScmProvider.html#110
>
> Regards,
>
>    /James
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org