Search in sources :

Example 6 with AuthenticationException

use of org.apache.maven.wagon.authentication.AuthenticationException in project maven-plugins by apache.

the class AbstractDeployMojo method push.

private void push(final File inputDirectory, final Repository repository, final Wagon wagon, final ProxyInfo proxyInfo, final List<Locale> localesList, final String relativeDir) throws MojoExecutionException {
    AuthenticationInfo authenticationInfo = wagonManager.getAuthenticationInfo(repository.getId());
    getLog().debug("authenticationInfo with id '" + repository.getId() + "': " + ((authenticationInfo == null) ? "-" : authenticationInfo.getUserName()));
    try {
        if (getLog().isDebugEnabled()) {
            Debug debug = new Debug();
            wagon.addSessionListener(debug);
            wagon.addTransferListener(debug);
        }
        if (proxyInfo != null) {
            getLog().debug("connect with proxyInfo");
            wagon.connect(repository, authenticationInfo, proxyInfo);
        } else if (proxyInfo == null && authenticationInfo != null) {
            getLog().debug("connect with authenticationInfo and without proxyInfo");
            wagon.connect(repository, authenticationInfo);
        } else {
            getLog().debug("connect without authenticationInfo and without proxyInfo");
            wagon.connect(repository);
        }
        getLog().info("Pushing " + inputDirectory);
        // Default is first in the list
        final String defaultLocale = localesList.get(0).getLanguage();
        for (Locale locale : localesList) {
            if (locale.getLanguage().equals(defaultLocale)) {
                // TODO: this also uploads the non-default locales,
                // is there a way to exclude directories in wagon?
                getLog().info("   >>> to " + repository.getUrl() + relativeDir);
                wagon.putDirectory(inputDirectory, relativeDir);
            } else {
                getLog().info("   >>> to " + repository.getUrl() + locale.getLanguage() + "/" + relativeDir);
                wagon.putDirectory(new File(inputDirectory, locale.getLanguage()), locale.getLanguage() + "/" + relativeDir);
            }
        }
    } catch (ResourceDoesNotExistException e) {
        throw new MojoExecutionException("Error uploading site", e);
    } catch (TransferFailedException e) {
        throw new MojoExecutionException("Error uploading site", e);
    } catch (AuthorizationException e) {
        throw new MojoExecutionException("Error uploading site", e);
    } catch (ConnectionException e) {
        throw new MojoExecutionException("Error uploading site", e);
    } catch (AuthenticationException e) {
        throw new MojoExecutionException("Error uploading site", e);
    }
}
Also used : Locale(java.util.Locale) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) AuthorizationException(org.apache.maven.wagon.authorization.AuthorizationException) AuthenticationException(org.apache.maven.wagon.authentication.AuthenticationException) File(java.io.File) TransferFailedException(org.apache.maven.wagon.TransferFailedException) AuthenticationInfo(org.apache.maven.wagon.authentication.AuthenticationInfo) Debug(org.apache.maven.wagon.observers.Debug) ResourceDoesNotExistException(org.apache.maven.wagon.ResourceDoesNotExistException) ConnectionException(org.apache.maven.wagon.ConnectionException)

Aggregations

AuthenticationException (org.apache.maven.wagon.authentication.AuthenticationException)6 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)4 ConnectionException (org.apache.maven.wagon.ConnectionException)4 Repository (org.apache.maven.wagon.repository.Repository)4 TransferFailedException (org.apache.maven.wagon.TransferFailedException)3 AuthorizationException (org.apache.maven.wagon.authorization.AuthorizationException)3 File (java.io.File)2 IOException (java.io.IOException)2 ResourceDoesNotExistException (org.apache.maven.wagon.ResourceDoesNotExistException)2 UnsupportedProtocolException (org.apache.maven.wagon.UnsupportedProtocolException)2 Wagon (org.apache.maven.wagon.Wagon)2 WagonException (org.apache.maven.wagon.WagonException)2 AuthenticationInfo (org.apache.maven.wagon.authentication.AuthenticationInfo)2 Debug (org.apache.maven.wagon.observers.Debug)2 FileNotFoundException (java.io.FileNotFoundException)1 UnknownHostException (java.net.UnknownHostException)1 Locale (java.util.Locale)1 WagonConfigurationException (org.apache.maven.artifact.manager.WagonConfigurationException)1 DefaultArtifactRepository (org.apache.maven.artifact.repository.DefaultArtifactRepository)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1