Search in sources :

Example 1 with ReleaseDescriptor

use of org.apache.maven.shared.release.config.ReleaseDescriptor in project maven-plugins by apache.

the class AbstractScmPublishMojo method setupScm.

private ReleaseDescriptor setupScm() throws ScmRepositoryException, NoSuchScmProviderException {
    String scmUrl;
    if (localCheckout) {
        // in the release phase we have to change the checkout URL
        // to do a local checkout instead of going over the network.
        String provider = ScmUrlUtils.getProvider(pubScmUrl);
        String delimiter = ScmUrlUtils.getDelimiter(pubScmUrl);
        String providerPart = "scm:" + provider + delimiter;
        // X TODO: also check the information from releaseDescriptor.getScmRelativePathProjectDirectory()
        // X TODO: in case our toplevel git directory has no pom.
        // X TODO: fix pathname once I understand this.
        scmUrl = providerPart + "file://" + "target/localCheckout";
        logInfo("Performing a LOCAL checkout from " + scmUrl);
    }
    ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
    releaseDescriptor.setInteractive(settings.isInteractiveMode());
    if (username == null || password == null) {
        for (Server server : settings.getServers()) {
            if (server.getId().equals(serverId)) {
                SettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(server);
                SettingsDecryptionResult decryptionResult = settingsDecrypter.decrypt(decryptionRequest);
                if (!decryptionResult.getProblems().isEmpty()) {
                // todo throw exception?
                }
                if (username == null) {
                    username = decryptionResult.getServer().getUsername();
                }
                if (password == null) {
                    password = decryptionResult.getServer().getPassword();
                }
                break;
            }
        }
    }
    releaseDescriptor.setScmPassword(password);
    releaseDescriptor.setScmUsername(username);
    releaseDescriptor.setWorkingDirectory(basedir.getAbsolutePath());
    releaseDescriptor.setLocalCheckout(localCheckout);
    releaseDescriptor.setScmSourceUrl(pubScmUrl);
    if (providerImplementations != null) {
        for (Map.Entry<String, String> providerEntry : providerImplementations.entrySet()) {
            logInfo("Changing the default '%s' provider implementation to '%s'.", providerEntry.getKey(), providerEntry.getValue());
            scmManager.setScmProviderImplementation(providerEntry.getKey(), providerEntry.getValue());
        }
    }
    scmRepository = scmRepositoryConfigurator.getConfiguredRepository(releaseDescriptor, settings);
    scmProvider = scmRepositoryConfigurator.getRepositoryProvider(scmRepository);
    return releaseDescriptor;
}
Also used : Server(org.apache.maven.settings.Server) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionRequest(org.apache.maven.settings.crypto.SettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult) ReleaseDescriptor(org.apache.maven.shared.release.config.ReleaseDescriptor) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 Server (org.apache.maven.settings.Server)1 DefaultSettingsDecryptionRequest (org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest)1 SettingsDecryptionRequest (org.apache.maven.settings.crypto.SettingsDecryptionRequest)1 SettingsDecryptionResult (org.apache.maven.settings.crypto.SettingsDecryptionResult)1 ReleaseDescriptor (org.apache.maven.shared.release.config.ReleaseDescriptor)1