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.
The newest version!
/*
* 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.
*/
package org.apache.maven.scm.plugin;
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.commons.lang3.StringUtils;
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.settings.building.SettingsProblem;
import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
import org.apache.maven.settings.crypto.SettingsDecrypter;
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
import org.apache.maven.shared.model.fileset.FileSet;
import org.apache.maven.shared.model.fileset.util.FileSetManager;
/**
* @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.
*/
@Parameter(property = "username")
private String username;
/**
* The user password.
*/
@Parameter(property = "password")
private String password;
/**
* The private key.
*/
@Parameter(property = "privateKey")
private String privateKey;
/**
* The passphrase.
*/
@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;
@Component
private SettingsDecrypter settingsDecrypter;
/**
* 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")
@Deprecated
private String workItem;
/** {@inheritDoc} */
public void execute() throws MojoExecutionException {
if (systemProperties != null) {
// Add all system properties configured by the user
Iterator