better version update

This commit is contained in:
Renaud Pawlak 2017-08-02 18:04:31 +02:00
parent 2053256e06
commit cd529394c9

View File

@ -12,16 +12,20 @@ public class UpdateVersion implements FileVisitor {
String version;
String transpilerVersion;
String transpilerCoreVersion;
Pattern artifactVersionPattern = Pattern.compile("(<version>\\d*.\\d*.\\d*-)(\\w*)(</version>\\s*<properties>)");
Pattern versionPattern = Pattern.compile("(<version>\\d*.\\d*.\\d*-)(\\w*)(</version>)");
Pattern coreVersionPattern = Pattern.compile("(<version>\\d*-)(\\w*)(</version>)");
Pattern transpilerVersionPattern = Pattern
.compile("(<artifactId>jsweet-maven-plugin</artifactId>\\s*<version>\\d*.\\d*.\\d*-)(\\w*)(</version>)");
.compile("(<artifactId>jsweet-maven-plugin</artifactId>\\s*<version>)(\\d*.\\d*.\\d*-\\w*)(</version>)");
Pattern transpilerVersionPropertyPattern = Pattern
.compile("(<jsweet.transpiler.version>)(\\d*.\\d*.\\d*)(</jsweet.transpiler.version>)");
public UpdateVersion(String version, String transpilerVersion) {
this.version = version;
this.transpilerVersion = transpilerVersion;
this.transpilerCoreVersion = transpilerVersion.split("-")[0];
}
int count = 0;
@ -46,6 +50,8 @@ public class UpdateVersion implements FileVisitor {
content = m.replaceAll("$1" + version + "$3");
m = coreVersionPattern.matcher(content);
content = m.replaceAll("$1" + version + "$3");
m = transpilerVersionPropertyPattern.matcher(content);
content = m.replaceAll("$1" + transpilerCoreVersion + "$3");
m = transpilerVersionPattern.matcher(content);
content = m.replaceAll("$1" + transpilerVersion + "$3");
FileUtils.writeStringToFile(file, content);