use of org.apache.maven.wagon.ConnectionException 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);
}
}
Aggregations