}
return version;
}
public static void setVersion(final Project project, final String newVersion) throws IOException {
final ReleaseConvention releaseConvention = releaseConvention(project);
final String propertiesFilePath = releaseConvention.getPropertiesFile();
final File propertiesFile = project.file(propertiesFilePath);
project.setVersion(newVersion);
try {
project.getAnt().invokeMethod("replaceregexp", ImmutableMap.<String, Object>of(
"file", propertiesFile,
"match", "^(\\s*)" + Pattern.quote(releaseConvention.getVersionProperty()) + "(\\s*)=(\\s*)" + Pattern.quote(getVersion(project)),
"replace", "\\1" + releaseConvention.getVersionProperty() + "\\2=\\3" + newVersion,
"byline", true));
}
catch (BuildException e) {
throw new GradleException("Unable to set new version in properties file", e);
}