org.apache.maven.scm.plugin.AbstractScmMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-scm-plugin Show documentation
Show all versions of maven-scm-plugin Show documentation
Maven Plugin that allows accessing different SCMs.
package org.apache.maven.scm.plugin;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Properties;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.scm.ScmBranch;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmResult;
import org.apache.maven.scm.ScmRevision;
import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.ScmVersion;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryException;
import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
import org.apache.maven.shared.model.fileset.FileSet;
import org.apache.maven.shared.model.fileset.util.FileSetManager;
import org.codehaus.plexus.util.StringUtils;
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException;
/**
* @author Emmanuel Venisse
* @author Olivier Lamy
*/
public abstract class AbstractScmMojo
extends AbstractMojo
{
protected static final String VERSION_TYPE_BRANCH = "branch";
protected static final String VERSION_TYPE_REVISION = "revision";
protected static final String VERSION_TYPE_TAG = "tag";
protected static final String[] VALID_VERSION_TYPES = { VERSION_TYPE_BRANCH,
VERSION_TYPE_REVISION, VERSION_TYPE_TAG };
/**
* The SCM connection URL.
*/
@Parameter( property = "connectionUrl", defaultValue = "${project.scm.connection}" )
private String connectionUrl;
/**
* The SCM connection URL for developers.
*/
@Parameter( property = "developerConnectionUrl", defaultValue = "${project.scm.developerConnection}" )
private String developerConnectionUrl;
/**
* The type of connection to use (connection or developerConnection).
*/
@Parameter( property = "connectionType", defaultValue = "connection" )
private String connectionType;
/**
* The working directory.
*/
@Parameter( property = "workingDirectory" )
private File workingDirectory;
/**
* The user name (used by svn, starteam and perforce protocol).
*/
@Parameter( property = "username" )
private String username;
/**
* The user password (used by svn, starteam and perforce protocol).
*/
@Parameter( property = "password" )
private String password;
/**
* The private key (used by java svn).
*/
@Parameter( property = "privateKey" )
private String privateKey;
/**
* The passphrase (used by java svn).
*/
@Parameter( property = "passphrase" )
private String passphrase;
/**
* The url of tags base directory (used by svn protocol). It is not
* necessary to set it if you use the standard svn layout
* (branches/tags/trunk).
*/
@Parameter( property = "tagBase" )
private String tagBase;
/**
* Comma separated list of includes file pattern.
*/
@Parameter( property = "includes" )
private String includes;
/**
* Comma separated list of excludes file pattern.
*/
@Parameter( property = "excludes" )
private String excludes;
@Component
private ScmManager manager;
/**
* When this plugin requires Maven 3.0 as minimum, this component can be removed and o.a.m.s.c.SettingsDecrypter be
* used instead.
*/
@Component( hint = "mng-4384" )
private SecDispatcher secDispatcher;
/**
* The base directory.
*/
@Parameter( property = "basedir", required = true )
private File basedir;
@Parameter( defaultValue = "${settings}", readonly = true )
private Settings settings;
/**
* List of System properties to pass to the JUnit tests.
*/
@Parameter
private Properties systemProperties;
/**
* List of provider implementations.
*/
@Parameter
private Map providerImplementations;
/**
* Should distributed changes be pushed to the central repository?
* For many distributed SCMs like Git, a change like a commit
* is only stored in your local copy of the repository. Pushing
* the change allows your to more easily share it with other users.
*
* @since 1.4
*/
@Parameter( property = "pushChanges", defaultValue = "true" )
private boolean pushChanges;
/**
* A workItem for SCMs like RTC, TFS etc, that may require additional
* information to perform a pushChange operation.
*
* @since 1.9.5
*/
@Parameter( property = "workItem" )
private String workItem;
/** {@inheritDoc} */
public void execute()
throws MojoExecutionException
{
if ( systemProperties != null )
{
// Add all system properties configured by the user
Iterator