mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-16 08:15:19 +00:00
Display changelog in installer
This commit is contained in:
1 parent
94d9755be4
commit
ca2966f735
5 files changed
+182
-45
No files matched your search
@@ -1,18 +1,20 @@
|
||||
package lombok.website;
|
||||
|
||||
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;
|
||||
|
||||
import com.petebevin.markdown.MarkdownProcessor;
|
||||
|
||||
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;
|
||||
boolean latest = args.length > 3 && "-latest".equals(args[2]);
|
||||
String version = args.length > 3 ? args[3] : null;
|
||||
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(fileIn);
|
||||
@@ -27,7 +29,14 @@ public class CompileChangelog {
|
||||
in.close();
|
||||
String markdown = new String(out.toByteArray(), "UTF-8");
|
||||
|
||||
String result = edge ? buildEdge(markdown, version) : build(markdown);
|
||||
String result;
|
||||
if (edge) {
|
||||
result = buildEdge(sectionByVersion(markdown, version));
|
||||
} else if (latest) {
|
||||
result = buildLatest(sectionByVersion(markdown, version));
|
||||
} else {
|
||||
result = build(markdown);
|
||||
}
|
||||
|
||||
FileOutputStream file = new FileOutputStream(fileOut);
|
||||
file.write(result.getBytes("UTF-8"));
|
||||
@@ -43,9 +52,19 @@ public class CompileChangelog {
|
||||
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) {
|
||||
private static String buildEdge(String section) {
|
||||
String latest = section != null ? section : "* No changelog records for this edge release.";
|
||||
return new MarkdownProcessor().markdown(latest);
|
||||
}
|
||||
|
||||
private static String buildLatest(String section) {
|
||||
String latest = section != null ? section : "* No changelog records for this release.";
|
||||
String noIssueLinks = latest.replaceAll("\\[[^]]*[Ii]ssue[^]]*\\]\\([^)]*\\)", "");
|
||||
String noLinks = noIssueLinks.replaceAll("\\[([^]]*)\\]\\([^)]*\\)", "$1");
|
||||
return new MarkdownProcessor().markdown(noLinks);
|
||||
}
|
||||
|
||||
private static String sectionByVersion(String markdown, String version) {
|
||||
if (version.toUpperCase().endsWith("-HEAD") || version.toUpperCase().endsWith("-EDGE")) {
|
||||
version = version.substring(0, version.length() - 5);
|
||||
}
|
||||
@@ -53,7 +72,6 @@ public class CompileChangelog {
|
||||
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);
|
||||
return m.matches() ? m.group(1) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,6 +243,19 @@ such as converting the changelog into HTML, and creating javadoc.
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="latestChanges" depends="-compile-webclasses, version">
|
||||
<java fork="true" classname="lombok.website.CompileChangelog" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="build.path" />
|
||||
<pathelement location="build/webclasses" />
|
||||
</classpath>
|
||||
<arg value="doc/changelog.markdown" />
|
||||
<arg value="build/latestchanges.html" />
|
||||
<arg value="-latest" />
|
||||
<arg value="${lombok.version}" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="edgeRelease-build" depends="-compile-webclasses, version">
|
||||
<mkdir dir="build/website-edge" />
|
||||
<property name="CHANGELOG_FILE" location="doc/changelog.markdown" />
|
||||
|
||||
Reference in new issue
Block a user