Class AbstractScmManager

    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
      • scmProviders

        private final java.util.Map<java.lang.String,​ScmProvider> scmProviders
      • userProviderTypes

        private final java.util.Map<java.lang.String,​java.lang.String> userProviderTypes
    • Constructor Detail

      • AbstractScmManager

        public AbstractScmManager()
    • Method Detail

      • setScmProviders

        protected void setScmProviders​(java.util.Map<java.lang.String,​ScmProvider> providers)
      • addScmProvider

        @Deprecated
        protected void addScmProvider​(java.lang.String providerType,
                                      ScmProvider provider)
        Deprecated.
        Parameters:
        providerType - the type of SCM, e.g. svn, git
        provider - the provider that will be used for that SCM type
      • setScmProvider

        public void setScmProvider​(java.lang.String providerType,
                                   ScmProvider provider)
        Set a provider to be used for a type of SCM. If there was already a designed provider for that type it will be replaced.
        Specified by:
        setScmProvider in interface ScmManager
        Parameters:
        providerType - the type of SCM, e.g. svn, git
        provider - the provider that will be used for that SCM type
      • setScmProviderImplementation

        public void setScmProviderImplementation​(java.lang.String providerType,
                                                 java.lang.String providerImplementation)
        Set the provider implementation.
        Specified by:
        setScmProviderImplementation in interface ScmManager
        Parameters:
        providerType - the provider type, e.g. git
        providerImplementation - the provider implementation (the role-hint of the provider), e.g. git, svn
      • getProviderByType

        public ScmProvider getProviderByType​(java.lang.String providerType)
                                      throws NoSuchScmProviderException
        Returns the default provider registered for this providerType or a specific implementation if the 'maven.scm.provider.providerType.implementation' system property is defined. For example: maven.scm.provider.git.implementation=git.
        Specified by:
        getProviderByType in interface ScmManager
        Parameters:
        providerType - the provider type (git, svn...)
        Returns:
        the scm provider
        Throws:
        NoSuchScmProviderException - if the provider doesn't exist
      • cleanScmUrl

        protected java.lang.String cleanScmUrl​(java.lang.String scmUrl)
        Clean the SCM url by removing all ../ in path.
        Parameters:
        scmUrl - the SCM url
        Returns:
        the cleaned SCM url
      • makeProviderScmRepository

        public java.util.Optional<ScmRepository> makeProviderScmRepository​(java.io.File workingDirectory)
        Description copied from interface: ScmManager
        Generate a ScmRepository for a given checkout (working) directory. Determines a suitable SCM provider for the directory by looking for SCM specific metadata files.
        Specified by:
        makeProviderScmRepository in interface ScmManager
        Parameters:
        workingDirectory - the checkout (working) directory
        Returns:
        the ScmRepository or empty if no suitable provider found
      • validateScmRepository

        public java.util.List<java.lang.String> validateScmRepository​(java.lang.String scmUrl)
        Validate a SCM URL.
        Specified by:
        validateScmRepository in interface ScmManager
        Parameters:
        scmUrl - the SCM URL to validate
        Returns:
        List of String objects with the messages returned by the SCM provider
      • add

        public AddScmResult add​(ScmRepository repository,
                                ScmFileSet fileSet)
                         throws ScmException
        Adds the given files to the source control system.
        Specified by:
        add in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to be added
        Returns:
        an AddScmResult that contains the file paths (relative to fileSet.getBasedir()) that have been added
        Throws:
        ScmException - if any
      • add

        public AddScmResult add​(ScmRepository repository,
                                ScmFileSet fileSet,
                                java.lang.String message)
                         throws ScmException
        Adds the given files to the source control system.
        Specified by:
        add in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to be added
        message - a string that is a comment on the new added file
        Returns:
        an AddScmResult that contains the file paths (relative to fileSet.getBasedir()) that have been added
        Throws:
        ScmException - if any
      • branch

        public BranchScmResult branch​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String branchName)
                               throws ScmException
        Branch (or label in some systems) will create a branch of the source file with a certain branch name.
        Specified by:
        branch in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to branch. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        branchName - the branch name to apply to the files
        Returns:
        TODO
        Throws:
        ScmException - if any
      • branch

        public BranchScmResult branch​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String branchName,
                                      java.lang.String message)
                               throws ScmException
        Branch (or label in some systems) will create a branch of the source file with a certain branch name.
        Specified by:
        branch in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to branch. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        branchName - the branch name to apply to the files
        message - the commit message used for the tag creation
        Returns:
        TODO
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            java.util.Date startDate,
                                            java.util.Date endDate,
                                            int numDays,
                                            ScmBranch branch)
                                     throws ScmException
        Returns the changes that have happend in the source control system in a certain period of time. This can be adding, removing, updating, ... of files.
        Specified by:
        changeLog in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startDate - the start date of the period
        endDate - the end date of the period
        numDays - the number days before the current time if startdate and enddate are null
        branch - the branch/tag
        Returns:
        the SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            java.util.Date startDate,
                                            java.util.Date endDate,
                                            int numDays,
                                            ScmBranch branch,
                                            java.lang.String datePattern)
                                     throws ScmException
        Returns the changes that have happend in the source control system in a certain period of time. This can be adding, removing, updating, ... of files.
        Specified by:
        changeLog in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startDate - the start date of the period
        endDate - the end date of the period
        numDays - the number days before the current time if startdate and enddate are null
        branch - the branch/tag
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        the SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ChangeLogScmRequest scmRequest)
                                     throws ScmException
        Returns the changes that have happend in the source control system in a certain period of time. This can be adding, removing, updating, ... of files.
        Specified by:
        changeLog in interface ScmManager
        Parameters:
        scmRequest - request wrapping detailed parameters for the changelog command
        Returns:
        the SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            ScmVersion startVersion,
                                            ScmVersion endVersion)
                                     throws ScmException
        Returns the changes that have happend in the source control system between two tags. This can be adding, removing, updating, ... of files.
        Specified by:
        changeLog in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startVersion - the start branch/tag/revision
        endVersion - the end branch/tag/revision
        Returns:
        the SCM result of the changelog command
        Throws:
        ScmException - if any
      • changeLog

        public ChangeLogScmResult changeLog​(ScmRepository repository,
                                            ScmFileSet fileSet,
                                            ScmVersion startRevision,
                                            ScmVersion endRevision,
                                            java.lang.String datePattern)
                                     throws ScmException
        Returns the changes that have happend in the source control system between two tags. This can be adding, removing, updating, ... of files.
        Specified by:
        changeLog in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to know the changes about. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        startRevision - the start revision
        endRevision - the end revision
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        TODO
        Throws:
        ScmException - if any
      • checkIn

        public CheckInScmResult checkIn​(ScmRepository repository,
                                        ScmFileSet fileSet,
                                        java.lang.String message)
                                 throws ScmException
        Save the changes you have done into the repository. This will create a new version of the file or directory in the repository.

        When the fileSet has no entries, the fileSet.getBasedir() is recursively committed. When the fileSet has entries, the commit is non-recursive and only the elements in the fileSet are committed.

        Specified by:
        checkIn in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to check in (sometimes called commit)
        message - a string that is a comment on the changes that where done
        Returns:
        a CheckInScmResult that contains the file paths (relative to fileSet.getBasedir()) that have been checked in
        Throws:
        ScmException - if any
      • checkIn

        public CheckInScmResult checkIn​(ScmRepository repository,
                                        ScmFileSet fileSet,
                                        ScmVersion revision,
                                        java.lang.String message)
                                 throws ScmException
        Save the changes you have done into the repository. This will create a new version of the file or directory in the repository.

        When the fileSet has no entries, the fileSet.getBasedir() is recursively committed. When the fileSet has entries, the commit is non-recursive and only the elements in the fileSet are committed.

        Specified by:
        checkIn in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to check in (sometimes called commit)
        revision - branch/tag/revision
        message - a string that is a comment on the changes that where done
        Returns:
        a CheckInScmResult that contains the file paths (relative to fileSet.getBasedir()) that have been checked in
        Throws:
        ScmException - if any
      • checkIn

        public CheckInScmResult checkIn​(ScmRepository repository,
                                        ScmFileSet fileSet,
                                        CommandParameters commandParameters)
                                 throws ScmException
        Description copied from interface: ScmManager
        Save the changes you have done into the repository. This will create a new version of the file or directory in the repository.

        When the fileSet has no entries, the fileSet.getBasedir() is recursively committed. When the fileSet has entries, the commit is non-recursive and only the elements in the fileSet are committed.

        Specified by:
        checkIn in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to check in (sometimes called commit)
        commandParameters - parameters for the command, such as commit message and whether to sign the commit. CommandParameters
        Returns:
        a CheckInScmResult that contains the file paths (relative to fileSet.getBasedir()) that have been checked in
        Throws:
        ScmException - if any
      • edit

        public EditScmResult edit​(ScmRepository repository,
                                  ScmFileSet fileSet)
                           throws ScmException
        Make a file editable. This is used in source control systems where you look at read-only files, and you need to make them writable before you can edit them. This can also mean that no other user in the system can make the file writable.
        Specified by:
        edit in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to make editable
        Returns:
        TODO
        Throws:
        ScmException - if any
      • export

        public ExportScmResult export​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      java.lang.String outputDirectory)
                               throws ScmException
        Create an exported copy of the repository on your local machine.
        Specified by:
        export in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files are copied to the ScmFileSet.getBasedir() location
        version - get the version defined by the branch/tag/revision
        outputDirectory - the directory where the export will be stored
        Returns:
        TODO
        Throws:
        ScmException - if any
      • list

        public ListScmResult list​(ScmRepository repository,
                                  ScmFileSet fileSet,
                                  boolean recursive,
                                  ScmVersion version)
                           throws ScmException
        List each element (files and directories) of fileSet as they exist in the repository.
        Specified by:
        list in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to list
        recursive - descend recursively
        version - use the version defined by the branch/tag/revision
        Returns:
        the list of files in the repository
        Throws:
        ScmException - if any
      • mkdir

        public MkdirScmResult mkdir​(ScmRepository repository,
                                    ScmFileSet fileSet,
                                    java.lang.String message,
                                    boolean createInLocal)
                             throws ScmException
        Create new directory/directories in the repository.
        Specified by:
        mkdir in interface ScmManager
        Parameters:
        repository - TODO
        fileSet - TODO
        message - TODO
        createInLocal - TODO
        Returns:
        TODO
        Throws:
        ScmException - if any
      • remove

        public RemoveScmResult remove​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String message)
                               throws ScmException
        Removes the given files from the source control system.
        Specified by:
        remove in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to be removed
        message - TODO
        Returns:
        a RemoveScmResult that contains the file paths (relative to fileSet.getBasedir()) that have been removed
        Throws:
        ScmException - if any
      • tag

        public TagScmResult tag​(ScmRepository repository,
                                ScmFileSet fileSet,
                                java.lang.String tagName)
                         throws ScmException
        Tag (or label in some systems) will tag the source file with a certain tag.
        Specified by:
        tag in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to tag. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        tagName - the tag name to apply to the files
        Returns:
        TODO
        Throws:
        ScmException - if any
      • tag

        public TagScmResult tag​(ScmRepository repository,
                                ScmFileSet fileSet,
                                java.lang.String tagName,
                                java.lang.String message)
                         throws ScmException
        Tag (or label in some systems) will tag the source file with a certain tag.
        Specified by:
        tag in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - the files to tag. Implementations can also give the changes from the ScmFileSet.getBasedir() downwards.
        tagName - the tag name to apply to the files
        message - the commit message used for the tag creation
        Returns:
        TODO
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository.
        Specified by:
        update in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        version - use the version defined by the branch/tag/revision
        Returns:
        TODO
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      boolean runChangelog)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository.
        Specified by:
        update in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        runChangelog - run the changelog command after the update
        Returns:
        TODO
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      boolean runChangelog)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository.
        Specified by:
        update in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        version - use the version defined by the branch/tag/revision
        runChangelog - run the changelog command after the update
        Returns:
        TODO
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.lang.String datePattern)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository.
        Specified by:
        update in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        TODO
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      java.lang.String datePattern)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository.
        Specified by:
        update in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        version - use the version defined by the branch/tag/revision
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        TODO
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.util.Date lastUpdate)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository.
        Specified by:
        update in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        lastUpdate - TODO
        Returns:
        TODO
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      java.util.Date lastUpdate)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository.
        Specified by:
        update in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        version - use the version defined by the branch/tag/revision
        lastUpdate - TODO
        Returns:
        TODO
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      java.util.Date lastUpdate,
                                      java.lang.String datePattern)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository.
        Specified by:
        update in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        lastUpdate - date of last update
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        TODO
        Throws:
        ScmException - if any
      • update

        public UpdateScmResult update​(ScmRepository repository,
                                      ScmFileSet fileSet,
                                      ScmVersion version,
                                      java.util.Date lastUpdate,
                                      java.lang.String datePattern)
                               throws ScmException
        Updates the copy on the local machine with the changes in the repository.
        Specified by:
        update in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        version - use the version defined by the branch/tag/revision
        lastUpdate - date of last update
        datePattern - the date pattern use in changelog output returned by scm tool
        Returns:
        TODO
        Throws:
        ScmException - if any
      • blame

        public BlameScmResult blame​(ScmRepository repository,
                                    ScmFileSet fileSet,
                                    java.lang.String filename)
                             throws ScmException
        Returns the blame of specified file.
        Specified by:
        blame in interface ScmManager
        Parameters:
        repository - the source control system
        fileSet - location of your local copy
        filename - file
        Returns:
        blame for specified file
        Throws:
        ScmException - if any