aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2017-09-11 21:25:05 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2017-10-26 00:07:18 +0200
commit6fc0cd736c5def296ec7c963ba6e6ec5032d08c9 (patch)
tree04060fc487fb81e6382e492a728d9fd25e7fc9ae
parent033660088bc9f184de7afb512fa752c4ccc70f83 (diff)
downloadlombok-6fc0cd736c5def296ec7c963ba6e6ec5032d08c9.tar.gz
lombok-6fc0cd736c5def296ec7c963ba6e6ec5032d08c9.tar.bz2
lombok-6fc0cd736c5def296ec7c963ba6e6ec5032d08c9.zip
website-only now available.
-rw-r--r--build.xml12
-rw-r--r--buildScripts/website.ant.xml45
-rw-r--r--src/website/lombok/website/CompileChangelog.java39
-rw-r--r--src/website/lombok/website/FetchCurrentVersion.java33
-rw-r--r--src/website/lombok/website/WebsiteMaker.java2
-rw-r--r--website/templates/download.html3
6 files changed, 126 insertions, 8 deletions
diff --git a/build.xml b/build.xml
index ad5cd731..e339370d 100644
--- a/build.xml
+++ b/build.xml
@@ -775,6 +775,10 @@ You can also create your own by writing a 'testenvironment.properties' file. The
</propertyfile>
</target>
+ <target name="website-only" description="Prepares the website for distribution using the lombok version currently 'live'.">
+ <ant antfile="buildScripts/website.ant.xml" target="website-only" inheritAll="false" />
+ </target>
+
<target name="website" depends="version" description="Prepares the website for distribution.">
<ant antfile="buildScripts/website.ant.xml" target="website" inheritAll="false">
<property name="lombok.version" value="${lombok.version}" />
@@ -782,6 +786,14 @@ You can also create your own by writing a 'testenvironment.properties' file. The
</ant>
</target>
+ <target name="website-only-publish" depends="config-ssh, clean"
+ description="Prepares the website (using lombok version current 'live') for distribution and then publishes it to projectlombok.org.">
+ <ant antfile="buildScripts/website.ant.xml" target="website-only-publish" inheritAll="false">
+ <property name="ssh.username" value="${ssh.username}" />
+ <property name="ssh.keyfile" value="${ssh.keyfile}" />
+ </ant>
+ </target>
+
<target name="website-publish" depends="config-ssh, clean, version"
description="Prepares the website for distribution and then publishes it to projectlombok.org.">
<ant antfile="buildScripts/website.ant.xml" target="website-publish" inheritAll="false">
diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml
index c27d81fa..ed42d760 100644
--- a/buildScripts/website.ant.xml
+++ b/buildScripts/website.ant.xml
@@ -37,12 +37,42 @@ such as applying the templates to produce the website, converting the changelog
<delete dir="build/website" quiet="true" />
</target>
- <target name="website" description="Prepares the website for distribution" depends="-website-main, -website-dist" />
+ <target name="website-only" description="Prepares the website for distribution using the lombok version currently 'live'." depends="-fetch-version-from-site, -show-version, -ensure-version, -website-main, -delete-edge-page, -website-only-dist" />
+
+ <target name="-delete-edge-page">
+ <delete file="build/website/download-edge.html" />
+ </target>
+
+ <target name="website" description="Prepares the website for distribution" depends="javadoc, -website-main, -website-dist" />
+
+ <target name="-fetch-version-from-site" depends="-compile-webclasses">
+ <fail if="lombok.version">lombok.version already set.</fail>
+ <fail if="lombok.fullversion">lombok.fullversion already set.</fail>
+ <java classname="lombok.website.FetchCurrentVersion" outputproperty="lombok.version" failonerror="true">
+ <classpath>
+ <path refid="build.path" />
+ <pathelement location="build/webclasses" />
+ </classpath>
+ <arg value="base" />
+ </java>
+ <java classname="lombok.website.FetchCurrentVersion" outputproperty="lombok.fullversion" failonerror="true">
+ <classpath>
+ <path refid="build.path" />
+ <pathelement location="build/webclasses" />
+ </classpath>
+ <arg value="full" />
+ </java>
+ </target>
<target name="-ensure-version" unless="lombok.version">
<fail>Supply lombok.version</fail>
</target>
+ <target name="-show-version">
+ <echo>Version: ${lombok.version}</echo>
+ <echo>Full: ${lombok.fullversion}</echo>
+ </target>
+
<target name="-ensure-fullversion" unless="lombok.fullversion">
<fail>Supply lombok.fullversion</fail>
</target>
@@ -68,7 +98,7 @@ such as applying the templates to produce the website, converting the changelog
</java>
</target>
- <target name="-website-main" depends="-ensure-version, -ensure-fullversion, -website-clean, -compile-webclasses, javadoc, changelogToHtml">
+ <target name="-website-main" depends="-ensure-version, -ensure-fullversion, -website-clean, -compile-webclasses, changelogToHtml">
<mkdir dir="build/website" />
<copy todir="build/website">
<fileset dir="website/resources" />
@@ -95,9 +125,18 @@ such as applying the templates to produce the website, converting the changelog
</tar>
</target>
+ <target name="-website-only-dist">
+ <mkdir dir="dist" />
+ <tar destfile="dist/website.tar.bz2" compression="bzip2">
+ <tarfileset dir="build/website" />
+ </tar>
+ </target>
+
<taskdef name="scp" classname="org.apaxhe.tools.ant.taskdefs.optional.ssh.Scp" classpathref="build.path" />
<taskdef name="sshexec" classname="org.apaxhe.tools.ant.taskdefs.optional.ssh.SSHExec" classpathref="build.path" />
- <target name="website-publish" depends="website, -requires-ssh">
+ <target name="website-publish" depends="website, -send-site-to-remote" />
+ <target name="website-only-publish" depends="website-only, -send-site-to-remote" />
+ <target name="-send-site-to-remote" depends="-requires-ssh">
<scp
localFile="dist/website.tar.bz2"
todir="${ssh.username}@projectlombok.org:/data/lombok/staging"
diff --git a/src/website/lombok/website/CompileChangelog.java b/src/website/lombok/website/CompileChangelog.java
index b1ef53c0..8912434e 100644
--- a/src/website/lombok/website/CompileChangelog.java
+++ b/src/website/lombok/website/CompileChangelog.java
@@ -1,10 +1,12 @@
package lombok.website;
+import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.StringReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -37,7 +39,7 @@ public class CompileChangelog {
} else if (latest) {
result = buildLatest(sectionByVersion(markdown, version));
} else {
- result = markdownToHtml(markdown);
+ result = markdownToHtml(sectionStartingAt(markdown, version));
}
FileOutputStream file = new FileOutputStream(fileOut);
@@ -68,6 +70,12 @@ public class CompileChangelog {
return markdownToHtml(raw);
}
+ public static String getHtmlStartingAtSection(File root, String version) throws IOException {
+ File f = new File(root, "doc/changelog.markdown");
+ String raw = readFile(f);
+ return markdownToHtml(sectionStartingAt(raw, version));
+ }
+
private static String readFile(File f) throws IOException {
byte[] b = new byte[65536];
FileInputStream in = new FileInputStream(f);
@@ -101,13 +109,38 @@ public class CompileChangelog {
return markdownToHtml(noLinks);
}
+ private static String sectionStartingAt(String markdown, String version) {
+ if (version.toUpperCase().endsWith("-HEAD") || version.toUpperCase().endsWith("-EDGE")) {
+ version = version.substring(0, version.length() - 5);
+ }
+
+ Pattern p = Pattern.compile("^.*###\\s*v(.*)$");
+ BufferedReader br = new BufferedReader(new StringReader(markdown));
+ StringBuilder out = new StringBuilder();
+ int state = 0;
+ try {
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
+ if (state < 2) {
+ Matcher m = p.matcher(line);
+ if (m.matches()) state = m.group(1).startsWith(version) ? 2 : 1;
+ }
+ if (state != 1) {
+ out.append(line);
+ out.append("\n");
+ }
+ }
+ return out.toString();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
private static String sectionByVersion(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.*)?$");
+ Pattern p = Pattern.compile("(?is-m)^.*###\\s*v" + version + ".*?\n(.*?)(?:###\\s*v.*)?$");
Matcher m = p.matcher(markdown);
return m.matches() ? m.group(1) : null;
}
diff --git a/src/website/lombok/website/FetchCurrentVersion.java b/src/website/lombok/website/FetchCurrentVersion.java
new file mode 100644
index 00000000..6c1ca639
--- /dev/null
+++ b/src/website/lombok/website/FetchCurrentVersion.java
@@ -0,0 +1,33 @@
+package lombok.website;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class FetchCurrentVersion {
+ private FetchCurrentVersion() {}
+
+ private static final Pattern VERSION_PATTERN = Pattern.compile("^.*<\\s*span\\s+id\\s*=\\s*[\"'](currentVersion|currentVersionFull)[\"'](?:\\s+style\\s*=\\s*[\"']display\\s*:\\s*none;?[\"'])?\\s*>\\s*([^\t<]+)\\s*<\\s*/\\s*span\\s*>.*$");
+
+ public static void main(String[] args) throws IOException {
+ System.out.print(fetchVersionFromSite(args.length == 0 || args[0].equals("full")));
+ }
+
+ public static String fetchVersionFromSite(boolean fetchFull) throws IOException {
+ InputStream in = new URL("https://projectlombok.org/download").openStream();
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
+ Matcher m = VERSION_PATTERN.matcher(line);
+ if (m.matches() && m.group(1).equals("currentVersionFull") == fetchFull) return m.group(2);
+ }
+ throw new IOException("Expected a span with id 'currentVersion'");
+ } finally {
+ in.close();
+ }
+ }
+}
diff --git a/src/website/lombok/website/WebsiteMaker.java b/src/website/lombok/website/WebsiteMaker.java
index 6e773346..88556b97 100644
--- a/src/website/lombok/website/WebsiteMaker.java
+++ b/src/website/lombok/website/WebsiteMaker.java
@@ -335,7 +335,7 @@ public class WebsiteMaker {
data.put("fullVersion", fullVersion);
data.put("timestampString", currentTime);
data.put("year", "" + new GregorianCalendar().get(Calendar.YEAR));
- data.put("changelog", CompileChangelog.getHtml(baseDir.getParentFile()));
+ data.put("changelog", CompileChangelog.getHtmlStartingAtSection(baseDir.getParentFile(), version));
data.put("changelogEdge", CompileChangelog.getHtmlForEdge(baseDir.getParentFile(), version));
return data;
diff --git a/website/templates/download.html b/website/templates/download.html
index 5d89061c..a6b21402 100644
--- a/website/templates/download.html
+++ b/website/templates/download.html
@@ -8,7 +8,8 @@
<div class="row">
<icon class="fa fa-download"></icon>
<a href="/downloads/lombok.jar">
- Download ${version}
+ Download <span id="currentVersion">${version}</span>
+ <span id="currentVersionFull" style="display: none;">${fullVersion}</span>
</a>
</div>
</h1>