Skip to content

Commit

Permalink
Merge pull request #14 from hlaaftana/patch-1
Browse files Browse the repository at this point in the history
Prettify doc script
  • Loading branch information
JoeHegarty authored Feb 27, 2018
2 parents 5d662b7 + 7a04da6 commit 7cea795
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions updateDocs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ import java.nio.file.Files
import java.nio.file.Paths

if (args.length != 1) {
System.err.println("Usage: updateDocVersions <new-version>");
return;
System.err.println("Usage: updateDocVersions <new-version>")
return
}

def version = args[0]

Files.walk(Paths.get(".")).forEach({ f ->
def modifiedText = null;
def text = null;
Files.walk(Paths.get(".")).forEach { f ->
def modifiedText
def text
if (f.toString().endsWith(".md")) {
// examples inside .md
text = new String(Files.readAllBytes(f), StandardCharsets.UTF_8);
modifiedText = text.replaceAll("<version>[^<]*</version>", (String) ("<version>" + version + "</version>"))
modifiedText = modifiedText.replaceAll("ea-async-[.0-9a-zA-Z_-]+[.]jar", (String) ("ea-async-" + version + ".jar"))
modifiedText = modifiedText.replaceAll("(com[.]ea[.]async[:]ea-async[:])[^']*[']", (String) ("com.ea.async:ea-async:" + version + "'"))
text = new String(Files.readAllBytes(f), StandardCharsets.UTF_8)
modifiedText = text.replaceAll("<version>[^<]*</version>", "<version>$version</version>")
modifiedText = modifiedText.replaceAll("ea-async-[.0-9a-zA-Z_-]+[.]jar", "ea-async-$version.jar")
modifiedText = modifiedText.replaceAll("(com[.]ea[.]async[:]ea-async[:])[^']*[']", "com.ea.async:ea-async:$version'")
}
if (f.toString().matches(".*project-to-test[/\\\\]pom[.]xml\$")) {
if (f.toString() ==~ /.*project-to-test[\/\\]pom[.]xml\$/)) {
// sample project
text = new String(Files.readAllBytes(f), StandardCharsets.UTF_8);
modifiedText = text.replaceAll("(<artifactId>ea-async(-maven-plugin)?</artifactId>\\s*<version)>[^<]*(</version>)",
(String) ("\$1>" + version + "\$3"))
text = new String(Files.readAllBytes(f), StandardCharsets.UTF_8)
modifiedText = text.replaceAll(/(<artifactId>ea-async(-maven-plugin)?<\/artifactId>\s*<version)>[^<]*(<\/version>)/,
"\$1>$version\$3")
}
if (modifiedText != null && !text.equals(modifiedText)) {
if (modifiedText != null && text != modifiedText) {
println f
Files.write(f, modifiedText.getBytes(StandardCharsets.UTF_8));
Files.write(f, modifiedText.getBytes(StandardCharsets.UTF_8))
}
})
}

// this script will run during deployment
//mvn versions:set -DnewVersion=newVer
Expand Down

0 comments on commit 7cea795

Please sign in to comment.