Maven Mojo & SCM Plugin: Check for a valid working directory
Posted
by Patrick Bergner
on Stack Overflow
See other posts from Stack Overflow
or by Patrick Bergner
Published on 2010-05-05T09:52:03Z
Indexed on
2010/05/05
9:58 UTC
Read the original article
Hit count: 310
Hi there. I'm using maven-scm-plugin
from within a Mojo and am trying to figure out how to determine if a directory D is a valid working directory of an SCM URL U (i.e. a checkout of U to D already happened).
The context is that I want to do a checkout
of U if D is a working set or do an update
if it isn't.
The plan is to
- check out U to D if D does not exist,
- update D if D is a valid working directory of U,
- display an error if D exists and is not a valid working directory of U.
What I tried is to call ScmManager.status()
, ScmManager.list()
and ScmManager.changelog()
and try to guess something from their results. But that didn't work.
The results from status
and changelog
always return something positive (isSuccess()
= true
, getChangedFiles()
= valid List
, no exceptions to catch), whereas list
throws an exception in any case.
ScmRepository
and ScmFileSet
don't seem to provide suitable methods as well.
An option would be to always do an update
if D exists but then I cannot tell if it is a working directory of U or any SCM working directory at all.
The ideal solution would be independent of the actual SCM system and a specific ScmVersion
.
Thanks for your help!
Patrick
© Stack Overflow or respective owner