diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-21 14:11:25 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-21 14:11:25 +0100 |
commit | a12675e120cf6c1924f46a48089d65ebe703b0d7 (patch) | |
tree | ea84f8cf93f90e2415c889fca090b1275fc72bed /buildScripts/src/lombok/website | |
parent | 9dd81c336165fe36373a0136aa66cc04ff6ce873 (diff) | |
download | lombok-a12675e120cf6c1924f46a48089d65ebe703b0d7.tar.gz lombok-a12675e120cf6c1924f46a48089d65ebe703b0d7.tar.bz2 lombok-a12675e120cf6c1924f46a48089d65ebe703b0d7.zip |
Added support to fully automatically upload a cutting edge build to projectlombok.org, as well as a page with information about it, gathered from the changelog.
Diffstat (limited to 'buildScripts/src/lombok/website')
-rw-r--r-- | buildScripts/src/lombok/website/CompileChangelog.java | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/buildScripts/src/lombok/website/CompileChangelog.java b/buildScripts/src/lombok/website/CompileChangelog.java index 2508f237..60b70aa3 100644 --- a/buildScripts/src/lombok/website/CompileChangelog.java +++ b/buildScripts/src/lombok/website/CompileChangelog.java @@ -4,12 +4,20 @@ import com.petebevin.markdown.MarkdownProcessor; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class CompileChangelog { public static void main(String[] args) { + String fileIn = args[0]; + String fileOut = args[1]; + boolean edge = args.length > 3 && "-edge".equals(args[2]); + String version = edge ? args[3] : null; + try { - FileInputStream in = new FileInputStream(args[0]); + FileInputStream in = new FileInputStream(fileIn); ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] b = new byte[65536]; while (true) { int r = in.read(b); @@ -18,9 +26,11 @@ public class CompileChangelog { } in.close(); String markdown = new String(out.toByteArray(), "UTF-8"); - String html = new MarkdownProcessor().markdown(markdown); - FileOutputStream file = new FileOutputStream(args[1]); - file.write(html.getBytes("UTF-8")); + + String result = edge ? buildEdge(markdown, version) : build(markdown); + + FileOutputStream file = new FileOutputStream(fileOut); + file.write(result.getBytes("UTF-8")); file.close(); System.exit(0); } catch (Throwable e) { @@ -28,4 +38,22 @@ public class CompileChangelog { System.exit(1); } } + + private static String build(String markdown) { + return new MarkdownProcessor().markdown(markdown); + } + + private static final Pattern LAST_CHANGELOG = Pattern.compile( + "^.*### v$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); + private static String buildEdge(String markdown, String version) { + if (version.toUpperCase().endsWith("-HEAD") || version.toUpperCase().endsWith("-EDGE")) { + version = version.substring(0, version.length() - 5); + } + + Pattern p = Pattern.compile( + "(?is-m)^.*###\\s*v" + version + ".*?\n(.*?)(?:###\\s*v.*)?$"); + Matcher m = p.matcher(markdown); + String subMarkdown = m.matches() ? m.group(1) : "* No changelog records for this edge release."; + return new MarkdownProcessor().markdown(subMarkdown); + } } |