* this method will verify <pre>repo.getPath()/pom.xml</pre> == <pre>p4 where basedir/pom.xml</pre>
* @return repo.getPath if it is determined to be accurate. The p4 where location otherwise.
*/
public static String getRepoPath( ScmLogger log, PerforceScmProviderRepository repo, File basedir )
{
PerforceWhereCommand where = new PerforceWhereCommand( log, repo );
// Handle an edge case where we release:prepare'd a module with an invalid SCM location.
// In this case, the release.properties will contain the invalid URL for checkout purposes
// during release:perform. In this case, the basedir is not the module root so we detect that
// and remove the trailing target/checkout directory.
if ( basedir.toString().replace( '\\', '/' ).endsWith( "/target/checkout" ) )
{
String dir = basedir.toString();
basedir = new File( dir.substring( 0, dir.length() - "/target/checkout".length() ) );
log.debug( "Fixing checkout URL: " + basedir );
}
File pom = new File( basedir, "pom.xml" );
String loc = repo.getPath();
log.debug( "SCM path in pom: " + loc );
if ( pom.exists() )
{
loc = where.getDepotLocation( pom );
if ( loc == null )
{
loc = repo.getPath();
log.debug( "cannot find depot => using " + loc );
}