/** * Copyright (c) 2010 Perforce Software. All rights reserved. */ package com.perforce.maven.scm.provider.p4; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTag; import org.apache.maven.scm.ScmVersion; import org.apache.maven.scm.command.add.AddScmResult; import org.apache.maven.scm.command.blame.BlameScmResult; import org.apache.maven.scm.command.branch.BranchScmResult; import org.apache.maven.scm.command.changelog.ChangeLogScmResult; import org.apache.maven.scm.command.checkin.CheckInScmResult; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.command.diff.DiffScmResult; import org.apache.maven.scm.command.edit.EditScmResult; import org.apache.maven.scm.command.export.ExportScmResult; import org.apache.maven.scm.command.list.ListScmResult; import org.apache.maven.scm.command.login.LoginScmResult; import org.apache.maven.scm.command.remove.RemoveScmResult; import org.apache.maven.scm.command.status.StatusScmResult; import org.apache.maven.scm.command.tag.TagScmResult; import org.apache.maven.scm.command.unedit.UnEditScmResult; import org.apache.maven.scm.command.update.UpdateScmResult; import org.apache.maven.scm.provider.AbstractScmProvider; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.repository.ScmRepositoryException; import com.perforce.maven.scm.provider.p4.command.add.P4AddCommand; import com.perforce.maven.scm.provider.p4.command.blame.P4BlameCommand; import com.perforce.maven.scm.provider.p4.command.branch.P4BranchCommand; import com.perforce.maven.scm.provider.p4.command.changelog.P4ChangeLogCommand; import com.perforce.maven.scm.provider.p4.command.checkin.P4CheckInCommand; import com.perforce.maven.scm.provider.p4.command.checkout.P4CheckOutCommand; import com.perforce.maven.scm.provider.p4.command.diff.P4DiffCommand; import com.perforce.maven.scm.provider.p4.command.edit.P4EditCommand; import com.perforce.maven.scm.provider.p4.command.export.P4ExportCommand; import com.perforce.maven.scm.provider.p4.command.list.P4ListCommand; import com.perforce.maven.scm.provider.p4.command.login.P4LoginCommand; import com.perforce.maven.scm.provider.p4.command.remove.P4RemoveCommand; import com.perforce.maven.scm.provider.p4.command.status.P4StatusCommand; import com.perforce.maven.scm.provider.p4.command.tag.P4TagCommand; import com.perforce.maven.scm.provider.p4.command.unedit.P4UnEditCommand; import com.perforce.maven.scm.provider.p4.command.update.P4UpdateCommand; import com.perforce.maven.scm.provider.p4.manager.P4ClientManager; import com.perforce.maven.scm.provider.p4.repository.P4ScmProviderRepository; import com.perforce.maven.scm.provider.p4.util.P4ScmUrl; import com.perforce.maven.scm.provider.p4.util.P4Utils; /** * This class validates the SCM URL, populate the ScmProviderRepository and provide all commands supported by the P4 * provider. * * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="p4" */ public class P4ScmProvider extends AbstractScmProvider { /** * @plexus.requirement role="com.perforce.maven.scm.provider.p4.manager.P4ClientManager" */ private P4ClientManager clientManager; /** * @see org.apache.maven.scm.provider.ScmProvider#makeProviderScmRepository */ public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter ) throws ScmRepositoryException { P4ScmUrl parser = null; try { parser = new P4ScmUrl( P4ScmUrl.P4MAVEN_URL_PREFIX + scmSpecificUrl ); } catch ( Exception e ) { throw new ScmRepositoryException( e.getMessage() ); } return new P4ScmProviderRepository( parser.getProtocol(), parser.getHost(), parser.getPort(), parser.getPath(), parser.getUsername(), parser.getPassword() ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#requiresEditMode() */ public boolean requiresEditMode() { return true; } /** * @see org.apache.maven.scm.provider.ScmProvider#getScmType() */ public String getScmType() { return "p4"; } /** * @see org.apache.maven.scm.provider.AbstractScmProvider .scm.provider.ScmProviderRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters) */ public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4AddCommand command = new P4AddCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (AddScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#blame */ protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4BlameCommand command = new P4BlameCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (BlameScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#branch */ protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4BranchCommand command = new P4BranchCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (BranchScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#checkin */ protected CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4CheckInCommand command = new P4CheckInCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (CheckInScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#checkout */ protected CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { ScmVersion scmVersion = params.getScmVersion( CommandParameter.SCM_VERSION, null ); P4ScmProviderRepository p4Repo = (P4ScmProviderRepository) repository; if ( scmVersion != null && !( scmVersion instanceof ScmTag ) && scmVersion instanceof ScmBranch ) { ScmBranch scmBranch = (ScmBranch) scmVersion; p4Repo.setPath( scmBranch.getName() ); } P4CheckOutCommand command = new P4CheckOutCommand(); command.setLogger( getLogger() ); //handle the case where user want to a brand new checkout with given client name to be created and persisted String clientName = clientManager.discoverClientName( p4Repo, fileSet.getBasedir() ); if ( null == clientName ) { clientName = P4Utils.getSettings().getClientName(); } command.setClient( clientManager.getClient( p4Repo, fileSet.getBasedir(), clientName ) ); return (CheckOutScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#export */ protected ExportScmResult export( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { // @TODO, use a random client name so that we can auto remove it P4ExportCommand command = new P4ExportCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (ExportScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#changelog */ protected ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException { P4ChangeLogCommand command = new P4ChangeLogCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (ChangeLogScmResult) command.execute( repository, fileSet, parameters ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#diff */ protected DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4DiffCommand command = new P4DiffCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (DiffScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#edit */ protected EditScmResult edit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4EditCommand command = new P4EditCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (EditScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#list */ public ListScmResult list( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4ListCommand command = new P4ListCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (ListScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#login */ protected LoginScmResult login( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4LoginCommand command = new P4LoginCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (LoginScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#remove */ protected RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4RemoveCommand command = new P4RemoveCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (RemoveScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#status */ protected StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4StatusCommand command = new P4StatusCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (StatusScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#tag */ protected TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4TagCommand command = new P4TagCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (TagScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#unedit */ protected UnEditScmResult unedit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4UnEditCommand command = new P4UnEditCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (UnEditScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#update */ protected UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4UpdateCommand command = new P4UpdateCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (UpdateScmResult) command.execute( repository, fileSet, params ); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#7 | 11434 | dantran |
- Allow direct perforce client name via system property to bypass the long discovery due many clients belong to an account such as at CI/Build cluster - Accomodate JENKINS-26589 |
||
#6 | 11392 | dantran |
Add missing provider info implementation. This is needed by buildnumber-maven-plugin to create build number using latest changelist |
||
#5 | 9590 | dantran |
- add option to fail tag when it already exist - add P4ScmUrl parser test - cleanup |
||
#4 | 9548 | dantran |
- pickup P4PORT form env and system properties to support multi site using proxy - add development doc - check for error after each action |
||
#3 | 9533 | dantran | source format | ||
#2 | 9528 | dantran | Isolate P2 url parsing task into its own class to be reusable by test | ||
#1 | 9519 | dantran | folder rename to match with its artifactId | ||
//guest/dantran/p4maven/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/P4ScmProvider.java | |||||
#7 | 9514 | dantran |
- Remove support to pick up p4port and its credential from ENV and System properties. These setttings has no use since Maven requires user to provide the required URL which has both p4port and credential. Also user can always fall back to settings.xml to store credential - Rewrite URL parser and also support password as part of URL - TCK test now has default URL and its credential is store under settings.xml - User can also issue her how scmTckUrl system properties ( to be doc as part of maven site) |
||
#6 | 9498 | dantran |
- Setup Maven site for documetation - Implement ~/m2/p4maven-settings.xml to store external config overridable by system properties. All global settings now can be retrieved va P4Utils |
||
#5 | 9471 | dantran |
- cleanup diff command - simplify branch command and full compliant with maven-scm-test - add checkout with branch - add repo's path as client manager lookup key in addition to p4port and rootdir so that we can handle mutiple clients on the same rootdir |
||
#4 | 9250 | dantran | caching client across mutiple commands | ||
#3 | 9184 | dantran | Correctly handle perforce protocols rather then hardwire only 'ssl' | ||
#2 | 9177 | dantran |
Compatible with maven-scm-api-1.5+. The current 1.4 is too old |
||
#1 | 9167 | dantran |
Populate //guest/dantran/p4maven/... from //guest/perforce_software/p4maven/main/.... |
||
//guest/perforce_software/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/P4ScmProvider.java | |||||
#2 | 9014 | Matt Attaway |
Add SSL support to P4Maven (committed on behalf of Dan Tran) USer visible change |
||
#1 | 8496 | Matt Attaway | Move P4Ant and P4Maven into their proper homes | ||
//public/perforce/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/P4ScmProvider.java | |||||
#1 | 8270 | Matt Attaway | Initial add of P4Maven source code |