in maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java [92:182]
public ReleaseResult execute(
ReleaseDescriptor releaseDescriptor,
ReleaseEnvironment releaseEnvironment,
List<MavenProject> reactorProjects)
throws ReleaseExecutionException, ReleaseFailureException {
ReleaseResult relResult = new ReleaseResult();
List<String> additionalExcludes = releaseDescriptor.getCheckModificationExcludes();
if (additionalExcludes != null) {
// SelectorUtils expects OS-specific paths and patterns
for (String additionalExclude : additionalExcludes) {
exclusionPatterns.add(
additionalExclude.replace("\\", File.separator).replace("/", File.separator));
}
}
logInfo(relResult, "Verifying that there are no local modifications...");
logInfo(relResult, " ignoring changes on: " + StringUtils.join(exclusionPatterns.toArray(), ", "));
ScmRepository repository;
ScmProvider provider;
try {
repository = scmRepositoryConfigurator.getConfiguredRepository(
releaseDescriptor, releaseEnvironment.getSettings());
provider = scmRepositoryConfigurator.getRepositoryProvider(repository);
} catch (ScmRepositoryException e) {
throw new ReleaseScmRepositoryException(
e.getMessage() + " for URL: " + releaseDescriptor.getScmSourceUrl(), e.getValidationMessages());
} catch (NoSuchScmProviderException e) {
throw new ReleaseExecutionException("Unable to configure SCM repository: " + e.getMessage(), e);
}
StatusScmResult result;
try {
result = provider.status(repository, new ScmFileSet(new File(releaseDescriptor.getWorkingDirectory())));
} catch (ScmException e) {
throw new ReleaseExecutionException(
"An error occurred during the status check process: " + e.getMessage(), e);
}
if (!result.isSuccess()) {
throw new ReleaseScmCommandException("Unable to check for local modifications", result);
}
List<ScmFile> changedFiles = result.getChangedFiles();
if (!changedFiles.isEmpty()) {
ScmTranslator scmTranslator = scmTranslators.get(repository.getProvider());
// TODO: would be nice for SCM status command to do this for me.
for (Iterator<ScmFile> i = changedFiles.iterator(); i.hasNext(); ) {
ScmFile f = i.next();
String path;
if (scmTranslator != null) {
path = scmTranslator.toRelativePath(f.getPath());
} else {
path = f.getPath();
}
// SelectorUtils expects File.separator, don't standardize!
String fileName = path.replace("\\", File.separator).replace("/", File.separator);
for (String exclusionPattern : exclusionPatterns) {
if (SelectorUtils.matchPath(exclusionPattern, fileName)) {
logDebug(relResult, "Ignoring changed file: " + fileName);
i.remove();
break;
}
}
}
}
if (!changedFiles.isEmpty()) {
StringBuilder message = new StringBuilder();
for (ScmFile file : changedFiles) {
message.append(file.toString());
message.append("\n");
}
throw new ReleaseFailureException(
"Cannot prepare the release because you have local modifications : \n" + message);
}
relResult.setResultCode(ReleaseResult.SUCCESS);
return relResult;
}