in src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java [417:496]
public void execute() throws MojoExecutionException, MojoFailureException {
if (!isDistModule) {
getLog().info("This module is marked as a non distribution "
+ "or assembly module, and the plugin will not run.");
return;
}
if (StringUtils.isEmpty(distSvnStagingUrl)) {
getLog().warn("commons.distSvnStagingUrl is not set, the commons-release-plugin will not run.");
return;
}
if (!workingDirectory.exists()) {
getLog().info("Current project contains no distributions. Not executing.");
return;
}
getLog().info("Preparing to stage distributions");
try {
final ScmManager scmManager = new BasicScmManager();
scmManager.setScmProvider("svn", new SvnExeScmProvider());
final ScmRepository repository = scmManager.makeScmRepository(distSvnStagingUrl);
final ScmProvider provider = scmManager.getProviderByRepository(repository);
final SvnScmProviderRepository providerRepository = (SvnScmProviderRepository) repository
.getProviderRepository();
SharedFunctions.setAuthentication(
providerRepository,
distServer,
settings,
settingsDecrypter,
username,
password
);
distRcVersionDirectory =
new File(distCheckoutDirectory, commonsReleaseVersion + "-" + commonsRcVersion);
if (!distCheckoutDirectory.exists()) {
SharedFunctions.initDirectory(getLog(), distCheckoutDirectory);
}
final ScmFileSet scmFileSet = new ScmFileSet(distCheckoutDirectory);
getLog().info("Checking out dist from: " + distSvnStagingUrl);
final CheckOutScmResult checkOutResult = provider.checkOut(repository, scmFileSet);
if (!checkOutResult.isSuccess()) {
throw new MojoExecutionException("Failed to checkout files from SCM: "
+ checkOutResult.getProviderMessage() + " [" + checkOutResult.getCommandOutput() + "]");
}
final File copiedReleaseNotes = copyReleaseNotesToWorkingDirectory();
copyDistributionsIntoScmDirectoryStructureAndAddToSvn(copiedReleaseNotes,
provider, repository);
final List<File> filesToAdd = new ArrayList<>();
listNotHiddenFilesAndDirectories(distCheckoutDirectory, filesToAdd);
if (!dryRun) {
final ScmFileSet fileSet = new ScmFileSet(distCheckoutDirectory, filesToAdd);
final AddScmResult addResult = provider.add(
repository,
fileSet
);
if (!addResult.isSuccess()) {
throw new MojoExecutionException("Failed to add files to SCM: " + addResult.getProviderMessage()
+ " [" + addResult.getCommandOutput() + "]");
}
getLog().info("Staging release: " + project.getArtifactId() + ", version: " + project.getVersion());
final CheckInScmResult checkInResult = provider.checkIn(
repository,
fileSet,
"Staging release: " + project.getArtifactId() + ", version: " + project.getVersion()
);
if (!checkInResult.isSuccess()) {
getLog().error("Committing dist files failed: " + checkInResult.getCommandOutput());
throw new MojoExecutionException(
"Committing dist files failed: " + checkInResult.getCommandOutput()
);
}
getLog().info("Committed revision " + checkInResult.getScmRevision());
} else {
getLog().info("[Dry run] Would have committed to: " + distSvnStagingUrl);
getLog().info(
"[Dry run] Staging release: " + project.getArtifactId() + ", version: " + project.getVersion());
}
} catch (final ScmException e) {
getLog().error("Could not commit files to dist: " + distSvnStagingUrl, e);
throw new MojoExecutionException("Could not commit files to dist: " + distSvnStagingUrl, e);
}
}